Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
i have table with :date,personalidi want to count for each day 1)how many rows there are2)how many distinct personalid in a daywhat the best way to do it?
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts
Posted - 2013-01-08 : 09:26:57
select count(*), count(distinct personalid), datefrom tblgroup by date==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy.
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2013-01-08 : 23:49:01
does date field store timepart too? if yes,
select count(*), count(distinct personalid), dateadd(dd,datediff(dd,0,[date]),0)from tblgroup by dateadd(dd,datediff(dd,0,[date]),0)
------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/