|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi,
These are my tables auth: id, level, base info: aid, name store: aid, itemID aid is the ID that comes from the auth table. The final output that I plan to get is Name Number of Items where name comes from the info table, and number of items comes from the store table. Query something like: show the total number of items for all those users (in the fashion Name, Number of items)from the store table, for all those whose level=something and base=something in the auth table. For example, if there are 10 users whom match level=something and base=something in the auth table, What I want displayed is: ------------------------ Name Number of Items ------------------------ user1 10 user2 15 user3 20 .... user10 30 ----------------------- which if broken up is: select name from info where aid=X select count(*) from store where aid=X .. for all those whose base=something and level=something from auth. Thanks, Shashi |
|
#2
|
||||
|
||||
|
Code:
select auth.name as Name
, count(*) as "Number of Items"
from auth
inner
join info
on auth.id = info.aid
inner
join store
on auth.id = store.aid
group
by auth.name
|
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > summarized report from one table based on information from other tables |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|