I am an amateur when it comes to Advanced SQL but here is the situation.
I have a Test Table with data such as below:
Name(char) Qty(number) Date (char) Location (char)
Test1 1 11/14/08 10000 20050
Test1 1 11/14/08 10000 20100
Test1 1 11/14/08 10000 20000
Test1 1 11/15/08 10000 20200
Test1 1 11/14/08 10000 20020
Test2 1 11/14/08 10000 31000
Test2 1 11/16/08 10000 30300
Test2 1 11/3/08 10000 30020
I would like to combine the rows, sum up the qty, take the max date, and take the location of the max date row. The resulting view should look like the view below:
Name(char) Qty(number) Date (char) Location (char)
Test1 5 11/15/08 10000 20200
Test2 3 11/16/08 10000 30300
I run into the problem of getting the Location from the row with the Max date.
So far I have
SELECT Name,
SUM("QTY") AS "Qty",
MAX("Date") AS "Date",
"Location"
FROM TEST_VIEW
GROUP BY Name, Location;
But since there are different locations, it does not combine the rows. Any help would be appreciated.