I have two tables
tblData
ID Name
1 ABC
2 XYZ
tblDetails
ID DataID PayDate Amount ApprovedDate
1 1 15-08-2015 200 20-18-2015
2 1 16-08-2015 300 20-18-2015
3 1 17-08-2015 50 20-18-2015
4 2 18-08-2015 100 21-18-2015
5 2 19-08-2015 500 21-18-2015
I need to get the result like the following
ID Duration TotalAmount ApprovedDate
1 15-08-2015 - 17-08-2015 550 20-18-2015
2 18-08-2015 - 19-08-2015 600 21-18-2015
How can I accomplish this?
tblDatafit in?SELECT somecolumn, AGGREGATEVALUEOF(someothercolumn), ANOTHER_AGGREGATE_VALUE_OF(another_column), AND_YET_ANOTHER_AGGREGATEVALUE_OF(yet_another_column) FROM some_table GROUP BY somecolumn;