Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
cancel
Showing results for 
Search instead for 
Did you mean: 

Display result record twice

karthik_25
Occasional Contributor

Display result record twice

Hi
Pardon me, if this is an old question.
How to get the output the twice ( or number of times ) of a sql statement.

eg.,
select * from colors
where color_desc in ('BLUE','BLUE')

When executing the above statement, i want the result twice ( since BLUE appears twice ), if more times, that number of result display.

Can you please help me.
1 REPLY
TwoProc
Honored Contributor

Re: Display result record twice

Probably lots of ways to do this,
one cheap one that I can think of:

select * from colors
where color_desc ='BLUE'
union all
select * from colors
where color_desc ='BLUE';

or my test:
(select * from dual)
union all
(select * from dual);

DUMMY
-------
X
X


"UNION" with the "ALL" modifier keeps the data from being coalesced down to a single row, and stops the UNION command from removing common rows.

We are the people our parents warned us about --Jimmy Buffett