Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Again
Message
From
05/05/2000 04:50:26
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
04/05/2000 23:39:01
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00366421
Message ID:
00366454
Views:
15
>Hi,
> I need to do the query as the following:
>
>
>Table User
>UserID              UserName
>0001                John
>0002                Jones
>0003                PDRM
>
>TableSales
>UserID              SalesAmt       InvoiseNo
>0001                1000           00001
>0001                2000           00002
>0002                 500           00003
>
>TableTopup
>UserID              TopupAmt       TranNo
>0001                1000           000001
>0002                1100           000002
>
>Expected Result
>UserID: 0001
>UserName: John
>     SalesAmt        3000       (SUM)
>     TopupAmt        1000       (SUM)
>
>UserID: 0002
>UserName: Jones
>     SalesAmt         500       (SUM)
>     TopupAmt        1100       (SUM)
>
>
>Seem there are not any transaction involve User 0003, therefore, it should not be displayed.
>
>Any ideas with how the SQL statement should be look like?
>
>Thank you


select a.userid, a.username, sum(b.SalesAmt), sum(c.TopupAmt) ;
  from tableA a ;
 inner join tableB b on a.userid = b.userid ;
 inner join tableC c on b.userid = c.userid ;
 group by 1
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
Previous
Reply
Map
View

Click here to load this message in the networking platform