How to get the previous column value?
IIf id1 = id2 then show previous column id1 value id1 id2 1001 1001 1002 1002 1003 1003
so on ...
ID1, id2, iff id2 = id 1, then erase the previous id value 1 Idadjusted
output
Id1 id2 id3 (expected) 1001 1001 ** 1000 ** 1002 1002 ** 1001 ** 1003 1003 ** 1002 **
So on ...
I want to sell the last column value id1
My query
LastDate - I Lasttime I want to display the last column cardeventdate value - I want to display the previous column outtime
Previous ID, I have tested it and works fine. This solution will work if the solution is missiing the intermediate ID ie i.e. IDs are not persistent
select t1.id, t1.column1, t1.column2, when the case is (t1.column1 = t1.column2) so T2kcolumnl Mytable Join T2 other zero as in column 3 as mytable T1 left outer t1.id = (select max (id) from my Teble where id & lt; t1.id) < / Code>
Complex query, you can create a view and then use the above sql format for your view:
For my view A. Create a view:
select cards, NAME, TITLENAME, CARDEVENTDATE, MIN (out of the Mean (CARDEVENTTIME) as CARDEVENTTIME) (SELECT T_PERSON.CARDNO, T_PERSON. Join T_TITLE INNER TVI from NAME, T_TITLE.TITLENAME, T_CARDEVENT.CARDEVENTDATE, T_CARDEVENT.CARDEVENTTIME to TITLE.TITLE.TITLECODE = T_PERSON.TITLECODE INNER T_PERSON.PERSONID Join T_CARDEVENT = T_CARDEVENT.PROSONID by Order T_PERSON.TITLECODE] Group by Card, NAME, TITLENAME, CARDEVENTDATE
and then the query will be:
Select v1.CARDNO, v1.NAME, v1.TITLENAME, v1.CARDEVENTDATE, v1. INTIME, v1.OUTTIME, when is the case (v1.NAME = v1.TITLENAME) then v2.CARDEVENTDATE - LASTDATE, MA LA when (v1.NAME = v1.TITLENAME) then your reqd condn as V 2 replace it with someone else null end v1.NAME = v1.TITLENAME. OUTTIME - External table1 from MyView v1 where CARDNO & lt to v2.CARDNO = (Selection Max (CARDNO) left to join MyView V2 with your reqd condn left as any other null end v1 In the case of v1.name = v1.TITLENAME, STMT should be replaced with appropriate label: .NAME = v1.TITLENAME; V1.CARDNO)
v1.name = v1.TITLENAME I was not skeptical because it has not been mentioned in the question.
Comments
Post a Comment