Tag Archive

Tag Archives for " GROUP BY "

Joins versus Subqueries SQL Puzzle

Joins versus Subqueries

In this puzzle, we’re going to learn about joins versus subqueries.  In many queries you can substitute joins and subqueries.  Yet, since each has their strengths, it isn’t wise to do so.  Once you have worked through this puzzle you see some of the benefits and disadvantages of joins versus subqueries. Solving puzzles is a […]

Continue reading

Learn How to Combine Data with a CROSS JOIN

Cross Join Meme

A cross join is used when you wish to create combination of every row from two tables.  All row combinations are included in the result; this is commonly called cross product join.  A common use for a cross join is to create obtain all combinations of items, such as colors and sizes. Note:  The series […]

Continue reading

Using Conditional Logic in SQL with CASE Expression

Kings Chapel College

The main purpose of a CASE expression is to return a value based on one or more conditional tests.  CASE expressions can be used anywhere in a SQL statement an expression is allowed. Though a truly an expression, some people refer to them as “CASE statements.”  This most likely stems from that use of the […]

Continue reading

Get Ready to Learn SQL Server 23: Using Subqueries in the HAVING Clause

HAVING Clause Subquery

This is the fifth in a series of articles about subqueries.  In this article we discuss subqueries in the HAVING clause.  Other articles discuss their uses in other clauses. All the examples for this lesson are based on Microsoft SQL Server Management Studio and the AdventureWorks2012 database.  You can get started using these free tools using […]

Continue reading

What is the difference between WHERE and HAVING clauses?

In this article learn when to use WHERE and HAVING.  Both perform similar functions, but for different purposes! All the examples for this article are based on Microsoft SQL Server Management Studio and the AdventureWorks2012 database.  You can get started using these free tools using my Guide Getting Started Using SQL Server. How do Where and Having Differ? […]

Continue reading
2

What is the Difference between ORDER and GROUP BY?

Differences in Order By versus Group By

The GROUP and ORDER BY clauses are both used to organize data.  Learn which is used to sort the data, and which is used for counting and summing. All the examples for this lesson are based on Microsoft SQL Server Management Studio and the AdventureWorks2012 database.  You can get started using these free tools using […]

Continue reading
2

How to Use GROUP BY to Summarize Query Results

Group and Summarize Data

In today’s lesson you’re going to learn about grouping results returned from your queries using the GROUP BY clause. The objectives of today’s lesson are to: Learn how to group results using GROUP BY Use aggregate functions to perform calculations Understand how to filter groups using the HAVING clause Important! Please follow along and do the […]

Continue reading