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 |
phyxe
Starting Member
13 Posts |
Posted - 2012-05-23 : 23:42:18
|
Hi there,I just want to have someone look at my query on generating monthly reports from my database. I have this txnlog table where it captures every transaction with reference to server time. so i build this query to generate a monthly report select COUNT (*) as [TOTAL Transaction for the day],txndate as [Date]from TxnLog where user_name ='user'and txnDate between '2012-05-01' and '2012-05-30 11:59:59 PM'groub by txndate but with this code i get this table quote: TOTAL Captured for the day date-------------------------- -----------------------1 2012-05-07 08:10:52.4471 2012-05-07 08:15:31.2501 2012-05-07 09:08:32.4771 2012-05-07 09:15:48.8501 2012-05-07 11:08:56.3871 2012-05-07 11:18:12.9971 2012-05-07 11:22:14.8871 2012-05-07 11:31:00.9931 2012-05-07 11:37:09.0131 2012-05-07 11:43:49.5171 2012-05-07 11:46:54.090
but i what i need as a result would be like this quote: TOTAL Captured for the day date-------------------------- -----------------------18 2012-05-0721 2012-05-0861 2012-05-09
is there a possible way to do this?thank you in advance for any help :) |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-05-24 : 00:49:41
|
[code]select COUNT (*) as [TOTAL Transaction for the day], dateadd(day, datediff(day, 0, txndate), 0) as [Date]from TxnLog where user_name ='user'and txnDate >= '2012-05-01' and txnDate < '2012-06-01'groub by dateadd(day, datediff(day, 0, txndate), 0)[/code]EDIT :Monthly ? shouldn't it be up to 31st of May ? KH[spoiler]Time is always against us[/spoiler] |
|
|
mani_12345
Starting Member
35 Posts |
Posted - 2012-05-24 : 01:12:53
|
i guesss it's wrkng fine ...select count(*) 'Count ',date_user from prbm where user_name ='user' and date_user between '2012-05-24' and '2012-05-29'group by date_user |
|
|
phyxe
Starting Member
13 Posts |
Posted - 2012-05-24 : 02:26:36
|
thank you so much khtan! the query worked perfectly :) |
|
|
|
|
|
|
|