Solved

How to repeat rows over and over again

Posted on 2007-11-15
4
759 Views
Last Modified: 2008-02-01
I have this query that lists a given list of codes for a project

76011
76013
76015
76016

I want to have this query repeat 3 times so it comes out like this

76011
76013
76015
76016
76011
76013
76015
76016
etc..

0
Comment
Question by:PROJHOPE
  • 2
  • 2
4 Comments
 
LVL 27

Accepted Solution

by:
MikeToole earned 125 total points
ID: 20290333
A new query wil the following SQL:

select Code from MyQuery
Union
select Code from MyQuery
Union
select Code from MyQuery
0
 

Author Comment

by:PROJHOPE
ID: 20290360
Sorry not explaining this correctly

Here is my query

select cost_element_id from DBSproj.dbo.component_cost_element
where component_id = '8933'
and project_id = 'INTL WITH TAS'

Results are this:

70573    
76013    
76023    
76033    
76053    
76063    
76093    
76313    
76333    
76353    
76373    
76393    
76473    
76493    
76613    
86013    
86033    
86933    

I want it to be

70573    
76013    
76023    
76033    
76053    
76063    
76093    
76313    
76333    
76353    
76373    
76393    
76473    
76493    
76613    
86013    
86033    
86933
70573    
76013    
76023    
76033    
76053    
76063    
76093    
76313    
76333    
76353    
76373    
76393    
76473    
76493    
76613    
86013    
86033    
86933    

etc...

If I do the union I simply retrieve only the 18

0
 

Author Comment

by:PROJHOPE
ID: 20290374
Ok I got it...UNION ALL not just UNION
0
 
LVL 27

Expert Comment

by:MikeToole
ID: 20290416
Oops, you got it!, I forget that my unions usually retrieve distinct rows, so no requirement for ALL.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
query help 18 57
return result by latest date - oracle query 21 70
SQL Query - Oracle 10g - Subract date from next data row 4 53
Join multiple pivot queries 2 9
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now