I have a column A which displays values corresponding to the input Date SYSDATE
. I want to bifurcate that column into two parts such that one part displays the data corresponding to SYSDATE
and the other part displays data corresponding to SYSDATE-1
i.e. previous day .
Now the issue is that output columns are same for both the parts,its just the change in the processing of the query where one part takes input Date SYSDATE
and other takes input SYSDATE-1
.
I am stuck at the implementation of this requirement .
Select A, B,C from Table -- Generalised query , now Column A has to be split into two columns A1 , A2 ,Issue is how to display A1,A2 .
I have no clue of how to proceed .
You could try a self join here:
SELECT
t1.value,
t2.value,
t1.dt,
t2.dt
FROM yourTable t1
INNER JOIN yourTable t2
ON t2.dt = t1.dt - 1
WHERE
t1.dt >= TRUNC(SYSDATE);
This would pair up records from today only to corresponding records at the same time one day earlier.