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:
I believe the dates are chars because it is actually a full date/time like 11/14/2008 8:48:43 AM. I was looking into some nested select statements, but I will try your suggestion, thanks!
SELECT NAME,
(select SUM(QTY) AS QTY
FROM TEST_VIEW tv1
WHERE tv1.NAME = tv.NAME
GROUP BY NAME) AS QTY,
LOCATION,
DATETIME
FROM TEST_VIEW tv
WHERE DATETIME in (SELECT MAX(DATETIME) from TEST_VIEW tv2 where tv2.NAME = tv.NAME )
ORDER by NAME;
I want to get the same results...I know how to parse the name field, like below
SELECT SUBSTR(NAME, 0, INSTR(NAME,'/')-1) AS NAME,
QTY,
LOCATION,
DATETIME
FROM TEST_TABLE;
But I would like to parse the name column, and also do the stuff in the first SQL Statement (sum up qty and grab the latest datetime and location of that datetime row). Any ideas of merging the two SQL statements?