SlideShare a Scribd company logo
1 of 1
Download to read offline
1. We are going to create a recursive CTE to count from 1 to 99. with numbers (n) as ( <INSERT
ANCHOR HERE> union all select <WHAT COMES NEXT> from numbers where <WHAT IS THE
TERMINATOR?> ) select * from numbers
What is the anchor? That is, what is the select that would return the first value?
What goes in the middle? Think about what you would return next once the numbers table is
defined.
Finally, what ends your recursion so you dont have an infinite loop? Include a screenshot of your
SQL statement and the results and submit as Week7_Q1.sql
2. What needs to be changed to display the even numbers from 2 to 180 ? Edit your query and
submit it and the results as Week7_Q2.sql.
3. Change your query to loop from 2 to 400. If you get an error, google it and add the correct
OPTION (big hint) to fix the query. Submit the query and result as Week7_Q3.sql
4. Write two T-SQL statements against the AdventureWorks database that use non-recursive
CTEs.

More Related Content

Similar to 1 We are going to create a recursive CTE to count from 1 to.pdf

Integer Representation
Integer RepresentationInteger Representation
Integer Representation
gavhays
 
Page 5 of 7Delete this text and type your name hereThis fi.docx
Page 5 of 7Delete this text and type your name hereThis fi.docxPage 5 of 7Delete this text and type your name hereThis fi.docx
Page 5 of 7Delete this text and type your name hereThis fi.docx
alfred4lewis58146
 
Excel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for MerchandisersExcel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for Merchandisers
webhostingguy
 

Similar to 1 We are going to create a recursive CTE to count from 1 to.pdf (20)

Oracle OCP 1Z0-007题库
Oracle OCP 1Z0-007题库Oracle OCP 1Z0-007题库
Oracle OCP 1Z0-007题库
 
How To Automate Part 2
How To Automate Part 2How To Automate Part 2
How To Automate Part 2
 
Excel formulas
Excel formulasExcel formulas
Excel formulas
 
Sql modifying data - MYSQL part I
Sql modifying data - MYSQL part ISql modifying data - MYSQL part I
Sql modifying data - MYSQL part I
 
Integer Representation
Integer RepresentationInteger Representation
Integer Representation
 
Python for Machine Learning
Python for Machine LearningPython for Machine Learning
Python for Machine Learning
 
Excel Function Training
Excel Function TrainingExcel Function Training
Excel Function Training
 
Number Systems.pdf .
Number Systems.pdf                        .Number Systems.pdf                        .
Number Systems.pdf .
 
Page 5 of 7Delete this text and type your name hereThis fi.docx
Page 5 of 7Delete this text and type your name hereThis fi.docxPage 5 of 7Delete this text and type your name hereThis fi.docx
Page 5 of 7Delete this text and type your name hereThis fi.docx
 
Computer paper 3 may june 2004 9691 cambridge General Certificate of educatio...
Computer paper 3 may june 2004 9691 cambridge General Certificate of educatio...Computer paper 3 may june 2004 9691 cambridge General Certificate of educatio...
Computer paper 3 may june 2004 9691 cambridge General Certificate of educatio...
 
Number System
Number SystemNumber System
Number System
 
CIS 115 Become Exceptional--cis115.com
CIS 115 Become Exceptional--cis115.comCIS 115 Become Exceptional--cis115.com
CIS 115 Become Exceptional--cis115.com
 
Excel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for MerchandisersExcel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for Merchandisers
 
ADE UNIT-III (Digital Fundamentals).pptx
ADE UNIT-III (Digital Fundamentals).pptxADE UNIT-III (Digital Fundamentals).pptx
ADE UNIT-III (Digital Fundamentals).pptx
 
CIS 115 Exceptional Education - snaptutorial.com
CIS 115   Exceptional Education - snaptutorial.comCIS 115   Exceptional Education - snaptutorial.com
CIS 115 Exceptional Education - snaptutorial.com
 
Cis 115 Enhance teaching / snaptutorial.com
Cis 115  Enhance teaching / snaptutorial.comCis 115  Enhance teaching / snaptutorial.com
Cis 115 Enhance teaching / snaptutorial.com
 
90 Informatics Practices.pdf
90 Informatics Practices.pdf90 Informatics Practices.pdf
90 Informatics Practices.pdf
 
Cis 115 Effective Communication / snaptutorial.com
Cis 115  Effective Communication / snaptutorial.comCis 115  Effective Communication / snaptutorial.com
Cis 115 Effective Communication / snaptutorial.com
 
Cis 115 Education Organization / snaptutorial.com
Cis 115 Education Organization / snaptutorial.comCis 115 Education Organization / snaptutorial.com
Cis 115 Education Organization / snaptutorial.com
 
Digital Electronics Notes
Digital Electronics Notes Digital Electronics Notes
Digital Electronics Notes
 

More from abhishek483040

1 Yeni bir kltrel deneyim yaratmak iin yerli ve yabanc.pdf
1 Yeni bir kltrel deneyim yaratmak iin yerli ve yabanc.pdf1 Yeni bir kltrel deneyim yaratmak iin yerli ve yabanc.pdf
1 Yeni bir kltrel deneyim yaratmak iin yerli ve yabanc.pdf
abhishek483040
 
1 Which wariable is the dependent wariable Choose a Amou.pdf
1 Which wariable is the dependent wariable Choose a Amou.pdf1 Which wariable is the dependent wariable Choose a Amou.pdf
1 Which wariable is the dependent wariable Choose a Amou.pdf
abhishek483040
 

More from abhishek483040 (20)

1 Write a python code that initializes a list called Number.pdf
1 Write a python code that initializes a list called Number.pdf1 Write a python code that initializes a list called Number.pdf
1 Write a python code that initializes a list called Number.pdf
 
1 Ykc bir yeniliki olan bir firma rnei verin Teknoloji .pdf
1 Ykc bir yeniliki olan bir firma rnei verin Teknoloji .pdf1 Ykc bir yeniliki olan bir firma rnei verin Teknoloji .pdf
1 Ykc bir yeniliki olan bir firma rnei verin Teknoloji .pdf
 
1 Yeni bir kltrel deneyim yaratmak iin yerli ve yabanc.pdf
1 Yeni bir kltrel deneyim yaratmak iin yerli ve yabanc.pdf1 Yeni bir kltrel deneyim yaratmak iin yerli ve yabanc.pdf
1 Yeni bir kltrel deneyim yaratmak iin yerli ve yabanc.pdf
 
1 Yava iddet kavramn Shannon OLearn Climate science and.pdf
1 Yava iddet kavramn Shannon OLearn Climate science and.pdf1 Yava iddet kavramn Shannon OLearn Climate science and.pdf
1 Yava iddet kavramn Shannon OLearn Climate science and.pdf
 
1 Write briefly about the difference between feature select.pdf
1 Write briefly about the difference between feature select.pdf1 Write briefly about the difference between feature select.pdf
1 Write briefly about the difference between feature select.pdf
 
1 Write the hypothesis being addressed by the data displaye.pdf
1 Write the hypothesis being addressed by the data displaye.pdf1 Write the hypothesis being addressed by the data displaye.pdf
1 Write the hypothesis being addressed by the data displaye.pdf
 
1 wwwsecgov web sitesine gidin ve General Electric GE d.pdf
1 wwwsecgov web sitesine gidin ve General Electric GE d.pdf1 wwwsecgov web sitesine gidin ve General Electric GE d.pdf
1 wwwsecgov web sitesine gidin ve General Electric GE d.pdf
 
1 Why is cell division important for both single cellular a.pdf
1 Why is cell division important for both single cellular a.pdf1 Why is cell division important for both single cellular a.pdf
1 Why is cell division important for both single cellular a.pdf
 
1 Write a program that creates an Integer class Date which .pdf
1 Write a program that creates an Integer class Date which .pdf1 Write a program that creates an Integer class Date which .pdf
1 Write a program that creates an Integer class Date which .pdf
 
1 Write a function named time that has an integer parame.pdf
1 Write a function named time  that has an integer parame.pdf1 Write a function named time  that has an integer parame.pdf
1 Write a function named time that has an integer parame.pdf
 
1 Write a paper on the topic The impact of the implementat.pdf
1 Write a paper on the topic The impact of the implementat.pdf1 Write a paper on the topic The impact of the implementat.pdf
1 Write a paper on the topic The impact of the implementat.pdf
 
1 Write a function to add the integers from a to b a and b.pdf
1 Write a function to add the integers from a to b a and b.pdf1 Write a function to add the integers from a to b a and b.pdf
1 Write a function to add the integers from a to b a and b.pdf
 
1 Write a detailed comprehensive brand strategy report for .pdf
1 Write a detailed comprehensive brand strategy report for .pdf1 Write a detailed comprehensive brand strategy report for .pdf
1 Write a detailed comprehensive brand strategy report for .pdf
 
1 Within this assignment you must detail specific material .pdf
1 Within this assignment you must detail specific material .pdf1 Within this assignment you must detail specific material .pdf
1 Within this assignment you must detail specific material .pdf
 
1 Why would you want to make your work reproducible 2 W.pdf
1 Why would you want to make your work reproducible 2 W.pdf1 Why would you want to make your work reproducible 2 W.pdf
1 Why would you want to make your work reproducible 2 W.pdf
 
1 Which of the following statements is not TRUE regarding S.pdf
1 Which of the following statements is not TRUE regarding S.pdf1 Which of the following statements is not TRUE regarding S.pdf
1 Which of the following statements is not TRUE regarding S.pdf
 
1 Winterville a city of population 125000 in the Rust Bel.pdf
1 Winterville a city of population 125000 in the Rust Bel.pdf1 Winterville a city of population 125000 in the Rust Bel.pdf
1 Winterville a city of population 125000 in the Rust Bel.pdf
 
1 Why is transportation considered so important to the US.pdf
1 Why is transportation considered so important to the US.pdf1 Why is transportation considered so important to the US.pdf
1 Why is transportation considered so important to the US.pdf
 
1 Why do cells need their DNA to be condensed before dividi.pdf
1 Why do cells need their DNA to be condensed before dividi.pdf1 Why do cells need their DNA to be condensed before dividi.pdf
1 Why do cells need their DNA to be condensed before dividi.pdf
 
1 Which wariable is the dependent wariable Choose a Amou.pdf
1 Which wariable is the dependent wariable Choose a Amou.pdf1 Which wariable is the dependent wariable Choose a Amou.pdf
1 Which wariable is the dependent wariable Choose a Amou.pdf
 

Recently uploaded

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 

1 We are going to create a recursive CTE to count from 1 to.pdf

  • 1. 1. We are going to create a recursive CTE to count from 1 to 99. with numbers (n) as ( <INSERT ANCHOR HERE> union all select <WHAT COMES NEXT> from numbers where <WHAT IS THE TERMINATOR?> ) select * from numbers What is the anchor? That is, what is the select that would return the first value? What goes in the middle? Think about what you would return next once the numbers table is defined. Finally, what ends your recursion so you dont have an infinite loop? Include a screenshot of your SQL statement and the results and submit as Week7_Q1.sql 2. What needs to be changed to display the even numbers from 2 to 180 ? Edit your query and submit it and the results as Week7_Q2.sql. 3. Change your query to loop from 2 to 400. If you get an error, google it and add the correct OPTION (big hint) to fix the query. Submit the query and result as Week7_Q3.sql 4. Write two T-SQL statements against the AdventureWorks database that use non-recursive CTEs.