I thought subqueries in sense of commad inside the command (in my example
two select commands). It works as you proposed an I thought in this case
(subqueries) that I need different syntax for sqlQury function combining SQL
query and paste.

But now I have another problem and again sorry if it is to general and basic
but I just can't find the right option to set up.
Namely, when I import table from SQL server into R, columns that are defined
in SQL table as char (with leading zeros as 001, 002,...) are imported as
integers.

Could you, please,  guide me on some options that should be set up to solve
this problem?
On Wed, Aug 10, 2011 at 10:16 AM, Prof Brian Ripley
<ripley@stats.ox.ac.uk>wrote:

> In what sense is this a 'subquery'?  It is just an SQL command (write it on
> one line, no terminating ;, which is not part of the query).
>
>
> On Wed, 10 Aug 2011, andrija djurovic wrote:
>
>   Hi R users.
>>
>> sorry for missing example and if question is to general but I am wondering
>> if it is possible to execute subqueries in function sqlQuery (package
>> RODBC)
>> with opened connection with Excel or SQL server 2000. I couldn't find any
>> example of this.
>>
>> And if it is possible what should be a correct syntax for this query:
>>
>> SELECT ct,COUNT(*) as n
>> FROM (SELECT COUNT(*) AS ct FROM children
>> GROUP BY family_id) AS x
>> GROUP BY ct;
>>
>> sqlQuery(connecton, "     CORRECT SYNTAX     ")
>>
>> (This query is an example from book Data Manipulation with R, Phil
>> Spector,
>> page 47)
>>
>> Thanks for any help
>>
>> Andrija
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________**________________
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>> PLEASE do read the posting guide http://www.R-project.org/**
>> posting-guide.html <http://www.r-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
> --
> Brian D. Ripley,                  ripley@stats.ox.ac.uk
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~**ripley/<http://www.stats.ox.ac.uk/~ripley/>
> University of Oxford,             Tel:  +44 1865 272861 (self)
> 1 South Parks Road,                     +44 1865 272866 (PA)
> Oxford OX1 3TG, UK                Fax:  +44 1865 272595
>

	[[alternative HTML version deleted]]

