Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
dbaz
Starting Member
5 Posts |
Posted - 2005-10-18 : 08:10:22
|
DEAR ALL.I have below table:VID SID1 11 21 32 12 32 52 63 23 34 54 6First : select VID, Count(*) AS CountOfSID from Table1group by VIDResult :VID CountOFSID1 32 43 24 2Now From this result I want to get below result wtih query:select CountOFSID, count(*)As F FROM "Result"GROUP BY CountOFSIDResult:CountOFSID F2 23 14 1-------I can do if with Oracle with one sql select:select CountOFSID, count(*)As F FROM(select VID, Count(*) AS CountOfSID from Table1group by VID)group by CountOFSIDCan it be coverted to SQL as one select statement?Thanks advance. |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2005-10-18 : 08:11:14
|
Ummmm, yeah, just paste it into Query Analyzer and run it.Actually, you do have to make one small change:select CountOFSID, count(*)As F FROM(select VID, Count(*) AS CountOfSID from Table1group by VID ) AS myQuerygroup by CountOFSIDWhen SELECTing from a subquery in SQL Server, the subquery must be aliased (in blue). |
|
|
|
|
|