Home » SQL & PL/SQL » SQL & PL/SQL » Pivot like this using DECODE???
Pivot like this using DECODE??? [message #275405] Fri, 19 October 2007 15:36 Go to next message
nkrzywonski
Messages: 1
Registered: October 2007
Location: Austin, TX
Junior Member
I am new to sql and pl/sql and I am trying to create a cross-tab or pivot query to flatten relational tables for reports (from one-to-many relationship to one-to-one). I've searched pivot and cross-tab and have not been able to find quite the right code snip...I'm wondering if I can use DECODE, but I do not want to specify a value...all I want is to take the existing value and place it into a renamed field. I tried this...

decode(field_name_a, not null, field_name_a, null) field_name_b

but am getting a missing expression error

Any help would be appreciated...please be gentle!
Re: Pivot like this using DECODE??? [message #275407 is a reply to message #275405] Fri, 19 October 2007 15:58 Go to previous messageGo to next message
Kevin Meade
Messages: 2101
Registered: December 1999
Location: Connecticut USA
Senior Member
try using CASE instead of decode for this.

Kevin
Re: Pivot like this using DECODE??? [message #275409 is a reply to message #275405] Fri, 19 October 2007 16:08 Go to previous message
vamsi kasina
Messages: 2107
Registered: October 2003
Location: Riyadh, Saudi Arabia
Senior Member
Quote:

decode(field_name_a, not null, field_name_a, null) field_name_b
What are you trying to achieve here? field_name_a??

If you directly assign / use field_name_a, if it is not null then field_name_a will go, otherwise null will go means field_name_a will go.

What is the difference in using field_name_a and decode(field_name_a, not null, field_name_a, null) field_name_b (this kind of logic). I only see you have used a alias decode(field_name_a, not null, field_name_a, null) field_name_b. Cool

By
Vamsi
Previous Topic: which dbms_job is running
Next Topic: Using an Index
Goto Forum:
  


Current Time: Sun Dec 04 18:30:29 CST 2016

Total time taken to generate the page: 0.06499 seconds