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 |
|
lynda
Starting Member
21 Posts |
Posted - 2009-08-06 : 12:51:42
|
Howdy folks. I am trying to produce a simple output that would look like this:Date of access | Count of hits on that dateMy query is this: Use lyndaselect cast(datepart(month, accessdate) as nvarchar(2)) + '-' + cast(datepart(day, accessdate) as nvarchar(2)) + '-' + cast(datepart(year, accessdate) as nvarchar(4)) as [Access Date], count(accessdate) as [Access Count]from lyndalog.dbo.accessedproductsleft join products on products.externalid=accessedproducts.productexternalidleft join users on users.externalid=accessedproducts.userexternalidwhere userexternalid in(select externalidfrom userswhere users.id in(select gi.useridfrom groupinvitations gileft join groups on groups.id=gi.groupidleft join users on users.id=groups.owneruseridwhere users.email='bentr001'))group by accessdate What I get back is like this:Date of access | Count of hits on that date05-01-2009 | 105-01-2009 | 105-01-2009 | 105-01-2009 | 105-01-2009 | 105-01-2009 | 1Where what I need is this:Date of access | Count of hits on that date05-01-2009 | 6Any help appreciated!Thanks! |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-08-06 : 13:24:25
|
Use your cast in group by too and it will work. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
lynda
Starting Member
21 Posts |
Posted - 2009-08-06 : 13:35:40
|
| You rock. Thank you sir. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-08-07 : 03:10:23
|
welcome  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|