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 |
|
itpriyesh88
Starting Member
13 Posts |
Posted - 2012-05-22 : 06:05:38
|
| I want to return an output from a subquery as datetime.select SUM(Total) from Orders where OrderDateTime in ( select distinct(datename(month,OrderDateTime)) from Orders where OrderDateTime between '2011-05-01' and '2012-05-01')Error message is:Conversion failed when converting date and/or time from character string.Plz Help!! |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-05-22 : 06:15:32
|
What you want is it just simplyselect SUM(Total) from Orders where OrderDateTime >= '2011-05-01' and OrderDateTime < '2012-05-02' KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
itpriyesh88
Starting Member
13 Posts |
Posted - 2012-05-22 : 06:19:55
|
| Yes. But I want to display the output as month wise like,Month TotalApril 11000.00May 12678.00June 97344.00etc... |
 |
|
|
itpriyesh88
Starting Member
13 Posts |
Posted - 2012-05-22 : 06:23:36
|
| Output should be month wise total sum of the orders...Is this possible? |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-05-22 : 06:25:37
|
[code]select datename(month, OrderDateTime), SUM(Total) from Orders where OrderDateTime >= '2011-05-01' and OrderDateTime < '2012-05-01'group by datename(month, OrderDateTime)[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
itpriyesh88
Starting Member
13 Posts |
Posted - 2012-05-22 : 07:26:53
|
| Thanks..It works.. :) |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|
|
|