[Solved] getting previous data (one less running column)


Try this Query:-

SELECT CMPI_PRCINX AS CURRENT_PRICE, (SELECT MAX(CMPI_PRCINX) FROM CMD_MTRL_PRICE_INF 
WHERE CMPI_PRCINX<(SELECT MAX(CMPI_PRCINX) FROM CMD_MTRL_PRICE_INF)) AS PRIVIOUS_PRICE
FROM CMD_MTRL_PRICE_INF WHERE CMPI_PRCINX = (SELECT MAX(CMPI_PRCINX) 
FROM CMD_MTRL_PRICE_INF GROUP BY CMI_CODE)

here is the SQL Fiddle Code.

http://sqlfiddle.com/#!4/46a23/2

solved getting previous data (one less running column)