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 |
|
pushp82
Yak Posting Veteran
83 Posts |
Posted - 2012-01-17 : 05:23:24
|
| Hi Friends,I have a table (CTE output) as Date MobileNo orderno amountJan 6 2012 La9tit870 2 1318.32Jan 06 2012 9311808518 1 448.32Jan 06 2012 9820257071 1 870Jan 9 2012 La9tit870 1 576.96Jan 09 2012 9897080841 1 576.96I need to sum the values for each date for other than MobileNo 'La9tit870' (This is static value).OutPut:Date orderno amount SourceJan 6 2012 2 1318.32 La9tit870Jan 6 2012 2 1318.32 OthersI'm in dark please show me a taurch........ASAP please |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-01-17 : 07:16:11
|
| [code]select Date, sum(amount) as Amount, 'Others' as Sourcefrom yourTablewhere MobileNo <> 'La9tit870'group by Date, MobileNoUNION ALLselect Date, Amount, MobileNofrom YourTablewhere MobileNo = 'La9tit870'[/code] |
 |
|
|
pushp82
Yak Posting Veteran
83 Posts |
Posted - 2012-01-18 : 01:26:50
|
quote: Originally posted by sunitabeck
select Date, sum(amount) as Amount, 'Others' as Sourcefrom yourTablewhere MobileNo <> 'La9tit870'group by Date, MobileNoUNION ALLselect Date, Amount, MobileNofrom YourTablewhere MobileNo = 'La9tit870'
Thank you sunita this worked for me... |
 |
|
|
|
|
|