Member of the
LearnItFirst.com Video Training Network
Related Video Training Sites:
·
SQL Server DBA Tutorials
·
Integration Services Training
Create a free account
·
Sign In
Transact SQL Video Tutorial
Home
Subscriber Videos
Transact-SQL Programming and Query Writing Tutorial: When to Use HAVING Instead of WHERE - Aggregates, GROUP BY, and the HAVING Clause
Chapter:
Aggregating Data Using DISTINCT, GROUP BY, HAVING, ROLLUP, CUBE and more
Skill Level:
300 (Intermediate)
Duration:
11:12
Size:
8.37MB
Versions/Editions Covered:
SQL Server 2005
,
SQL Server 2008
,
SQL Server 2000
Added/Updated:
Apr 18, 2006
The traditional areas of difficulty for SQL developers are aggregates, JOINs, and subqueries. Most people have no trouble understanding when to use COUNT instead of SUM but they get "stuck" when it comes to determining how to filter the data. Suppose you are asked to find all orders in 2006 in which customers ordered more than 5 items - how would you solve this query? Obviously you need two filters: for the date (2006) and for orders with more than 5 items. People have difficulty with this type of query however; most people would approach this query along these lines: "SELECT ... FROM Orders JOIN OrderDetails ... WHERE Year(DateOrdered)=2006 AND COUNT(*) > 5". Focus on the WHERE clause for a moment: is that right? If you aren't sure or if you think it is right, then you need to watch this video to understanding why this query must use the HAVING clause.
Tags for this video:
aggregates where clause
group by
having
<
Back
People Who Downloaded this Video Also Downloaded:
Title
Skill
Download
Subqueries, Nested Queries, and Derived Tables - An Introduction to Advanced SQL...
300
Download
Constraint Keys, Index Keys, Composite Keys, Natural keys, and Surrogate Keys
200
Download
Query Analyzer - Beyond the Basics (SQL Server 2000)
200
Download
JOINs - An Overview of the Five Types of JOINs (Cross, Outer, and Inner)
200
Download
JOINs and UNIONs - How Do I Know When to Use a JOIN or a UNION?
300
Download
About the Instructor:
Scott Whigham is the founder of LearnItFirst.com, one of the web's most extensive video training libraries focusing on technical training. Scott is also an experienced consultant, trainer, and author with more than a decade of hands-on experience working with SQL Server databases, writing and debugging applications using Visual Studio, and performance tuning. Scott designed the architecture (websites, class libraries, and database) for the LearnItFirst.com websites and, most re...
(Scott Whigham's full bio can be found on the
About the Author
page)
About Us
·
Corporate Philosophy
·
Become an Author
·
Contact Us
Video Playback
·
System Requirements
·
TSCC Codec
(to play videos)
·
Troubleshooting/Problems
Subscriptions
·
Pricing/Buy Now
·
Testimonials
·
Privacy
·
Terms of Service
More Video Training
·
SQL Server DBA Tutorials
·
Integration Services Training
·
All of Our Websites
More
·
FAQs
·
Search for videos
·
Site Map
© Copyright 2004-2008 LearnItFirst.com LLC. All rights reserved. All trademarks remain the property of their respective owners. This site is not affiliated in any way with the Microsoft Corporation.
1/6/2009 11:13:04 PM