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 |
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2013-05-01 : 04:10:25
|
Hi, How can i apply the max date and get the total amount?date amount ID2013-01-01 $10 123452013-05-05 $20 12345I tried as below but it still return the same output as above.Select sum(amount), ID, case when date is not null then max(date) endfrom tableThe result I wanted are as below:date amount ID2013-05-05 $30 12345 |
|
ahmeds08
Aged Yak Warrior
737 Posts |
Posted - 2013-05-01 : 04:48:11
|
select MAX(date1),sum(amount),ID from tablegroup by idmohammad.javeed.ahmed@gmail.com |
|
|
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2013-05-01 : 04:55:20
|
I apply the the convert to date:max(Convert(date,date))It still appear twice.Is the convert apply correctly? |
|
|
ahmeds08
Aged Yak Warrior
737 Posts |
Posted - 2013-05-01 : 05:02:32
|
why do you want to convert the date column?mohammad.javeed.ahmed@gmail.com |
|
|
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2013-05-01 : 05:05:29
|
i actually want to standardise the date to +8 hours.I should use dateadd right. And also would want just the date. That's why convert the date.Is it wrong? |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2013-05-01 : 11:14:29
|
What is the datatype of your date column? |
|
|
|
|
|