I have this problem with a SQL query (SQL Server 2008)
SELECT id, client, SUM(debt), date
FROM Table GROUP BY id, client, date
Returned from the query is
id client debt date
1 jim x 500 05/05/2012
2 jack a 900 06/06/2012
2 jack a 500 null
Is there a way to add in this scenario Jack a’s debt (1400) and display the non null date i.e. 06/06/2012.
A person can only have 2 records max and 1 record is always date null so is there a way to do the sum and use the date that is not null?
Thanks
To group by client you have to remove
idanddatefrom your GROUP BY: