now that you have finally revealed that you’re not interested in the collective MAXes of your data columns, but rather, want consecutive rows compared, i’m afraid i just don’t have the time to walk you through a complete rebuilding of your query
if you have specific issues, like a syntax error or something, maybe i can take a look
otherwise, you’re going to have to rebuild the query yourself
one other factor to consider is that comparing consecutive rows is something that is often accomplished far more efficiently in the application, i.e. you just return sorted rows to the application and the application compares one row to the next
I think use MAX in my data column for execution comparison of dates in the row with same code_A.
If I need complete rebuilding the query I don’t have idea to start …
SELECT a.CODE_A
, b.myDate
, b.ID
, PERIOD_DIFF(EXTRACT(YEAR_MONTH FROM b.myDate)
, EXTRACT(YEAR_MONTH FROM a.myDate)) DIFF_MONTH
, b.H2_PPM
, a.H2_PPM
, (b.H2_PPM-a.H2_PPM)/PERIOD_DIFF(EXTRACT(YEAR_MONTH FROM b.myDate)
, EXTRACT(YEAR_MONTH FROM a.myDate)) INC_H2
FROM listfiles_2011_11_25 a
JOIN listfiles_2011_11_25 b
ON a.CODE_A = b.CODE_A
WHERE 1
AND a.CODE_A = '5550'
GROUP BY CODE_A, myDate
ORDER BY ID DESC;
SELECT a.CODE_A
, b.myDate
, b.ID
, PERIOD_DIFF(EXTRACT(YEAR_MONTH FROM b.myDate)
, EXTRACT(YEAR_MONTH FROM a.myDate)) DIFF
, b.H2_PPM
, a.H2_PPM
, (b.H2_PPM-a.H2_PPM)/PERIOD_DIFF(EXTRACT(YEAR_MONTH FROM b.myDate)
, EXTRACT(YEAR_MONTH FROM a.myDate)) INC_H2
FROM listfiles_2011_11_25 a
JOIN listfiles_2011_11_25 b
ON a.CODE_A = b.CODE_A
WHERE 1
AND a.CODE_A = '5550'
ORDER BY ID DESC;
no, i meant, return the entire table, a new/different query, using ORDER BY to get the rows into the right sequence, and then detect the consecutive rows with ASP logic