Home » SQL & PL/SQL » SQL & PL/SQL » union (oracle)
union [message #330492] Mon, 30 June 2008 05:11 Go to next message
convey05
Messages: 43
Registered: December 2007
Location: CHENNAI
Member
Hi,
I have two tables like the below mentioned structure.
CREATE TABLE TEST_DUMMY1(NO NUMBER,NAME VARCHAR2(40),AGE NUMBER,ID NUMBER);
CREATE TABLE TEST_DUMMY2(NOO NUMBER,NAMEE VARCHAR2(40),MARK1 NUMBER);

I have inserted record in both the tables
when i queried the table using union
SELECT NO,NAME,AGE,ID,NULL MARK1 FROM TEST_DUMMY1 WHERE NO=1
UNION
SELECT null NO, null NAME,NULL AGE,NULL,MARK1 FROM TEST_DUMMY2 WHERE NOO=1
I got the output as
NO NAME AGE ID MARK1
1 a 1 1
100
The output is shown in 2 rows. i need the output in one row.
what to be done?
kindly provide me a solution
Thanks in advance
Re: union [message #330495 is a reply to message #330492] Mon, 30 June 2008 05:17 Go to previous messageGo to next message
Michel Cadot
Messages: 68737
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
1/
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) and align the columns in result.
Use the "Preview Message" button to verify.

2/
Always post your Oracle version (4 decimals).

3/
"The output is shown in 2 rows. i need the output in one row."
Which one?

4/
I think "pivot" may be what you're searching for.

Regards
Michel
Re: union [message #330500 is a reply to message #330495] Mon, 30 June 2008 05:21 Go to previous message
rajatratewal
Messages: 507
Registered: March 2008
Location: INDIA
Senior Member
convey05 tell me one thing what UNION clause actually do??

Why you are using UNION in this.

Regards,
Rajat Ratewal
Previous Topic: Is it possibe to Update 2 or more table in single query ?
Next Topic: Query Totals with Rollup Question
Goto Forum:
  


Current Time: Mon Feb 17 18:25:36 CST 2025