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