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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Occurences of occurrences - with a subquery??

Author  Topic 

landau66
Yak Posting Veteran

61 Posts

Posted - 2008-08-27 : 16:00:17
hi everyone!

I want to see how often specific prices occured during a day. For example 6498.04 occured 27 times, 6505.99 also 27 times and hundred other prices occured as well 27 times. following query helps me finding out the occurence of prices and their occurrence:

select count(price)as occ from tbl group by price order by occ

Now i want to extend this query to find out how often occured the occurrence. In my table I have just the fields: id, datetime, price.

Maybe u know how to solve my problem.

Many thanks in advance and greetings from Vienna

landau

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-08-27 : 16:12:54
maybe:
select count(occ) as occOcc
from
( select count(price) as occ from tbl group by price ) t
group by occ


_______________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.0 out!
Go to Top of Page
   

- Advertisement -