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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-01-15 : 08:05:56
|
ernest writes "Hi I got a real trouble. My boss asked me to make a report. He wants to see a total of each day orders. Therefore, I make this query:
Create Procedure sp_orders @varMonth int @varYear int AS SELECT COUNT(giftordDetail.itemNumber) AS tItem, SUM(product.shippingCost) AS tCost, giftordDetail.ordtime FROM giftordDetail, product WHERE giftordDetail.itemNumber = product.itemNum AND Month(ordtime) = @varMonth AND Year(ordtime) = @varYear GROUP BY giftordDetail.ordtime ORDER BY giftordDetail.ordtime ASC
Since the giftordDetail.ordtime fields is in '2000/11/14 23:00:00' format, the GROUP BY cannot work. It display all records in that month. The boss cannot let me change the date format to '2000/11/14' because he also wants me to work out the number of orders in each time period of a day.
Can anyone help me out?
Thank you very much in advacne.
Ernest" |
|
|
|
|
|