Home » SQL & PL/SQL » SQL & PL/SQL » I want to Convert rows to columns (merged 3)
I want to Convert rows to columns (merged 3) [message #432221] Mon, 23 November 2009 01:25 Go to next message
esam2002
Messages: 2
Registered: November 2009
Location: cairo
Junior Member
hallo every people
i have 2 select i join him by UNION and the Result is
order no Product1 Product2
131000100 70 0
131000100 0 45


but i want the result is
131000100 70 45

what i can do


Re: I want to Convert rows to columns (merged 3) [message #432225 is a reply to message #432221] Mon, 23 November 2009 01:42 Go to previous messageGo to next message
Michel Cadot
Messages: 68718
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Group by order_no and take the max.

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 with 4 decimals.

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

Regards
Michel
Re: I want to Convert rows to columns (merged 3) [message #432528 is a reply to message #432221] Tue, 24 November 2009 16:50 Go to previous message
Kevin Meade
Messages: 2103
Registered: December 1999
Location: Connecticut USA
Senior Member
Example of Data Pivots in SQL (rows to columns and columns to rows)

In the end nothing is free. You often have to do reading and research if you want to answer a question.

Good luck, Kevin
Previous Topic: ORA-00936 coming in execute immediate
Next Topic: Row Generator And Serial Number
Goto Forum:
  


Current Time: Thu Dec 05 00:16:35 CST 2024