Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Aggregate from multipl tables
Message
From
15/01/2000 11:40:07
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Aggregate from multipl tables
Miscellaneous
Thread ID:
00318566
Message ID:
00318566
Views:
66
Hi folks,
I have brain dead by now :)
I have a parent table say myParent with PK "iid". There are few child tables (not really childs but have "pid" as FK referencing "iid"), say T1, T2, T3, T4.
I need to collect rowcounts in each table per "iid" (CrossTab).
myParent.iid   t1.pid   t2.pid    t3.pid   t4.pid
------------   ------   ------    ------   ------
1                 1        2         1        1
2                 1        3         5        2
3                 1        3         5        3
4                 2        4         7        4
5                 4                  7        6
6                 4                           6
7
8
9

* Desired output 

pid   Cnt1  Cnt2  Cnt3  Cnt4
---   ----  ----  ----  ----
 1      3          1     1
 2      1     1          1
 3            2          1
 4      2     1          1
 5                 2
 6                       2
 7                 2
 8
 9
Any idea how I could do this just with one SQL ? TIA
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Next
Reply
Map
View

Click here to load this message in the networking platform