Solved

How to repeat rows over and over again

Posted on 2007-11-15
4
758 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 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

11 Experts available now in Live!

Get 1:1 Help Now