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 |
|
g_r_a_robinson
Starting Member
45 Posts |
Posted - 2004-03-25 : 19:19:19
|
| I need to return the following from my db, egDate User (Count)12/01/04 2313/01/04 1714/01/04 1215/01/04 916/01/04 32Basically I just need to return a list count of all users that cancelled orders with a specified date range on the given dates. I'm just not sure how to do it. Any help would be most appreciated |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-03-25 : 19:21:07
|
| Got a table layout and sample data? What you've posted is the expected result set but we need table information and what the data looks like?Tara |
 |
|
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
Posted - 2004-03-25 : 19:57:50
|
Without knowing the layout of your tables, and with inputting my own column/table names.SELECT TRUNC(cancel_date) as "Cancel Date", COUNT(TRUNC(cancel_date)) as "User Count"FROM table_nameWHERE cancel_date BETWEEN '01-JAN-2004' and sysdateGROUP BY TRUNC(cancel_date)ORDER By TRUNC(cancel_date) You may or may not have to use the TRUNC function here. TRUNC strips off the time component so you can make date comparisons just on the day, not down to the second. If your cancel_date is that granular (down to minutes and seconds for example) and you don't use TRUNC, the GROUP BY operation will fail to roll your data up to the day.-ec |
 |
|
|
|
|
|