SQL Tutorial: Introduction to recursion
Key Takeaways
Introduces recursion using SQL
Full Transcript
in the second video you will learn what you cash means and how you could use it for many problems the first question we want to answer is what recursion is in general as you can see in the picture it is something that is always repeated accordingly recursion is the use of a procedure subroutine function or eggwin that calls itself one or more times until a specific condition is met therefore a recursion could simplify a complex problem by sharing the problem in smaller poems performed repeatedly one really important fact about recursion is that you need the termination condition if you have no termination condition the call of the small problem repeats all the time as you can see in the shown picture and we world example everyone knows it's the family tree everyone has a father and your father as a father for example to find all father's for the last five generations you can use your question you have to reduce the problem to smaller problems of the same type whole problem is to find all generations and the small problem is to find your father in the first step find your father and in the second step find the father of the father until the termination condition of fife is reached knowing how we crashed works in Genoa we are now somewhere some facts about recursion advantages soft bottoms recursively if the bottom can be reduced to smaller partners of the same type and recursively solve problem is easy to eat and to follow and the termination condition could be used to limit the number of iterations thinking of disadvantages the Oshin time could be slower because the recursion function is called many times knowing what is recursion let's try out a simple macaron problem the problem we want to solve is to calculate the sum of consecutive numbers it can be defined as shown on the slide it is 1 for the first situation and for each following iteration number of the current iteration and the sum of the previous situation is added as an example the result of 5 is 15 is this the sum of 1 plus 2 Plus 3 plus 4 plus 5 now we are going to solve this problem with seeker in general we could solve recursive problems with city's common table expressions therefore you could see the initial query which initializes the field for iteration and the sum of number with one in the recursive part the current iteration number is added with the sum of the previous situation you can see that the termination condition is set to 6 this means this query calculates the sum of numbers until 6 finally the city is elected to get the wanted result you hear a lot about who curses afar
Original Description
Want to learn more? Take the full course at https://learn.datacamp.com/courses/hierarchical-and-recursive-queries-in-sql-server at your own pace. More than a video, you'll learn hands-on coding & quickly apply skills to your daily work.
---
In this second video, you will learn what recursion means and how you could use it for many problems.
The first question we want to answer is what recursion is in general. As you can see in the picture, it is something that is always repeated. Accordingly: Recursion is the use of a procedure, subroutine, function or algorithm that calls itself one or more times until a specific condition is met. Therefore, a recursion could simplify a complex problem by sharing the problem in smaller problems performed repeatedly. One really important fact about recursion is that you need a termination condition. If you have no termination condition, the call of the small problems repeats all the time. As you can see in the shown picture.
An real world example everyone knows is the family tree. Everyone has a father and your father has a father. For example, to find all fathers for the last 5 generations, you can use recursion. You have to reduce the problem to smaller problems of the same type. The whole problem is to find all generations and the small problem is to find your father. In the first step, find your father and in the second step, find the father of the father until the termination condition of 5 is reached.
Knowing how recursion works in general, we are now summarizing facts about recursion. There are several advantages: you can solve problems recursively, if the problem can be reduced to the smaller problems of the same type. A recursively solved problem is easy to read and to follow and a termination condition could be used to limited the number of iterations. Thinking of disadvantages, the execution time could slower because the recursive function is called many times.
Knowing what is recursion, let's try out a simple recur
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from DataCamp · DataCamp · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
SQL Server Tutorial: Date manipulation
DataCamp
R Tutorial: Intermediate Interactive Data Visualization with plotly in R
DataCamp
R Tutorial: Adding aesthetics to represent a variable
DataCamp
R Tutorial: Moving Beyond Simple Interactivity
DataCamp
Python Tutorial: Why use ML for marketing? Strategies and use cases
DataCamp
Python Tutorial: Preparation for modeling
DataCamp
Python Tutorial: Machine Learning modeling steps
DataCamp
R Tutorial: The prior model
DataCamp
R Tutorial: Data & the likelihood
DataCamp
R Tutorial: The posterior model
DataCamp
R Tutorial: An Introduction to plotly
DataCamp
R Tutorial: Plotting a single variable
DataCamp
R Tutorial: Bivariate graphics
DataCamp
Python Tutorial: Customer Segmentation in Python
DataCamp
Python Tutorial: Time cohorts
DataCamp
Python Tutorial: Calculate cohort metrics
DataCamp
Python Tutorial: Cohort analysis visualization
DataCamp
R Tutorial: Building Dashboards with flexdashboard
DataCamp
R Tutorial: Anatomy of a flexdashboard
DataCamp
R Tutorial: Layout basics
DataCamp
R Tutorial: Advanced layouts
DataCamp
Python Tutorial: Time Series Analysis in Python
DataCamp
Python Tutorial: Correlation of Two Time Series
DataCamp
Python Tutorial: Simple Linear Regressions
DataCamp
Python Tutorial: Autocorrelation
DataCamp
R Tutorial: The gapminder dataset
DataCamp
R Tutorial: The filter verb
DataCamp
R Tutorial: The arrange verb
DataCamp
R Tutorial: The mutate verb
DataCamp
R Tutorial: What is cluster analysis?
DataCamp
R Tutorial: Distance between two observations
DataCamp
R Tutorial: The importance of scale
DataCamp
R Tutorial: Measuring distance for categorical data
DataCamp
Python Tutorial: Plotting multiple graphs
DataCamp
Python Tutorial: Customizing axes
DataCamp
Python Tutorial: Legends, annotations, & styles
DataCamp
Python Tutorial: Introduction to iterators
DataCamp
Python Tutorial: Playing with iterators
DataCamp
Python Tutorial: Using iterators to load large files into memory
DataCamp
SQL Tutorial: Introduction to Relational Databases in SQL
DataCamp
SQL Tutorial: Tables: At the core of every database
DataCamp
SQL Tutorial: Update your database as the structure changes
DataCamp
Python Tutorial: Classification-Tree Learning
DataCamp
Python Tutorial: Decision-Tree for Classification
DataCamp
Python Tutorial: Decision-Tree for Regression
DataCamp
Python Tutorial: Census Subject Tables
DataCamp
Python Tutorial: Census Geography
DataCamp
Python Tutorial: Using the Census API
DataCamp
R Tutorial: A/B Testing in R
DataCamp
R Tutorial: Baseline Conversion Rates
DataCamp
R Tutorial: Designing an Experiment - Power Analysis
DataCamp
R Tutorial: Introduction to qualitative data
DataCamp
R Tutorial: Understanding your qualitative variables
DataCamp
R Tutorial: Making Better Plots
DataCamp
SQL Tutorial: OLTP and OLAP
DataCamp
SQL Tutorial: Storing data
DataCamp
SQL Tutorial: Database design
DataCamp
Python Tutorial: Introduction to spaCy
DataCamp
Python Tutorial: Statistical Models
DataCamp
Python Tutorial: Rule-based Matching
DataCamp
Related AI Lessons
⚡
⚡
⚡
⚡
Bloom Filters, Explained Properly
Dev.to · Daksh Gargas
Prefix Sums: The Preprocessing Trick That Makes Range Queries Instant
Medium · Programming
I Thought I Was Ready for the Interview — Then One Simple Math Question Destroyed Me
Medium · Programming
Week 2(Day 10): LeetCode Two Pointers(slow & fast): Remove Duplicates from Sorted Array (Brute…
Medium · Python
🎓
Tutor Explanation
DeepCamp AI