#### Archive

*Category Archives for "Intermediate"*

There are several ways to calculate a running total in SQL. In this article, we will cover two methods: Joins, and Window Functions. We’ll first look at how to calculate the running total using an INNER JOIN. By doing so, you’ll not only learn more about join conditions, but see how to take the result […]

Continue readingIn this puzzle, we’re going to learn how to do some basic data modeling. Many of you have expressed an interest in learning more about data modeling and database design. I figure we could start with a simple case study and let it evolve from there. Solving puzzles is a great way to learn SQL. […]

Continue readingRecursive CTE’s In this article we explore recursive CTE’s (Common Table Expressions). Recursive CTEs are special in the sense they are allowed to reference themselves! Because of this special ability, you can use recursive CTEs to solve problems other queries cannot. Recursive CTEs are really good at working with hierarchical data such as org charts […]

Continue readingIntroduction to Non Recursive CTEs In this article we explore non recursive CTEs (Common Table Expressions). This is a broad class, and basically covers every form of CTEs except those that call themselves. This other class is called the recursive CTEs; they are covered in the next article. If you’re unfamiliar with CTEs I would […]

Continue readingCommon Table Expressions or CTE’s for short are used within SQL Server to simplify complex joins and subqueries, and to provide a means to query hierarchical data such as an organizational chart. In this set of articles, we’ll introduce you to CTE’s, the two types, and their uses. In this article we’ll introduce CTE’s. Once […]

Continue reading