Home » SQL & PL/SQL » SQL & PL/SQL » compare two columns in same table
compare two columns in same table [message #424758] Mon, 05 October 2009 20:16 Go to next message
radhavijaym
Messages: 65
Registered: December 2008
Location: singapore
Member
Hi All,
i had a table i need to retreive previous value and current value from a table based on time stamp and when the transaction type is update.

below i attached the excel file.
gl_code_combinations_ac1 is the table
in this table i had audit_timestamp,audit_transaction_type,enabled_flag,preserve_flag,start_date_active ....

i need to retreive values when transaction type is update and for particular time stamp which columns are update that must be displayed.
suppose if
time transaction type enabled_flag preserve flag
6thoct10.10.10 insert y
6thoct10.11.20 update n
6thoct 10.12.30 update y
when i run the script for particular time then it should display enabled flag values as

time transaction type enabled_new enabled_old
6thoct10.11.20 update n y
6thoct 10.12.30 update y n

but it should not display preserve flag

please help me how to do this

thanks
radha
Re: compare two columns in same table [message #424759 is a reply to message #424758] Mon, 05 October 2009 20:32 Go to previous messageGo to next message
BlackSwan
Messages: 24912
Registered: January 2009
Senior Member
You need to help us by following the Posting Guidelines as stated below.
http://www.orafaq.com/forum/t/88153/0/
Go to the URL above click the link "Posting Guidelines"
Go to the section labeled "Practice" & do as directed.

use LAG analytic function
Re: compare two columns in same table [message #424760 is a reply to message #424759] Mon, 05 October 2009 20:34 Go to previous messageGo to next message
radhavijaym
Messages: 65
Registered: December 2008
Location: singapore
Member
I USED LAG BUT IT IS NOT WORKING FINE.
Re: compare two columns in same table [message #424761 is a reply to message #424760] Mon, 05 October 2009 20:39 Go to previous messageGo to next message
BlackSwan
Messages: 24912
Registered: January 2009
Senior Member
radhavijaym wrote on Mon, 05 October 2009 18:34
I USED LAG BUT IT IS NOT WORKING FINE.

shouting is NOT appreciated.

so change SQL until it does work fine.

PLEASE follow Posting Guidelines!
Re: compare two columns in same table [message #424762 is a reply to message #424761] Mon, 05 October 2009 21:38 Go to previous messageGo to next message
radhavijaym
Messages: 65
Registered: December 2008
Location: singapore
Member
Hi,
sorry i will follow the posting guide lines.

Thanks,
Radha
Re: compare two columns in same table [message #424767 is a reply to message #424762] Mon, 05 October 2009 23:23 Go to previous message
Michel Cadot
Messages: 63812
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
From your previous topic:
radhavijaym wrote on Fri, 20 February 2009 02:50
sorry ,
i didnt see your reply and i posted my reply.
next time i wont use caps.


From another one:
Michel Cadot wrote on Fri, 09 January 2009 09:51
From your previous SQL topic:
Michel Cadot wrote on Tue, 06 January 2009 12:33
Before Please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter), use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).

Regards
Michel



Can we trust you?

Post a working Test case: create table and insert statements along with the result you want with these data.

[Updated on: Mon, 05 October 2009 23:23]

Report message to a moderator

Previous Topic: Sql error: 1795 - ORA-01795: maximum number of expressions in a list is 254
Next Topic: need help Column to rows
Goto Forum:
  


Current Time: Fri Sep 30 09:01:00 CDT 2016

Total time taken to generate the page: 0.12168 seconds