Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need select statement
Message
From
30/04/2002 08:14:33
 
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00650340
Message ID:
00650794
Views:
14
Thanks Mike - I also found that
select A.Name, count(C.PKey) from A
left join B on B.Fkey = A.PKey
left join C on C.Fkey = B.PKey
group by A.Name
works good

Thanks for your help!
Ken

>Do it with a subquery.
>
>SELECT a.*, (
> SELECT ISNULL(count(*), 0)
> FROM b INNER JOIN c ON b.id = c.b_id
> WHERE b.a_id = a.id) AS c_count
>FROM
>a
>
>-Mike
>
>>Hi,
>>
>>What is easiest way to accomplish the following?
>>
>>Straight Parent.Child relationsships A -> B -> C
>>- records may or may not exist in B that belong to A (0-n)
>>- records may or may not exist in C that belong to B (0-n)
>>
>>What I want is slick little select statement that will list ALL the 'A' records and a count of how many records exist downstream in 'C' for each 'A' record, whether that be 0,1, or whatever
>>
>>What is best way to accomplish this?
>>
>>TIA,
Ken B. Matson
GCom2 Solutions
Previous
Reply
Map
View

Click here to load this message in the networking platform