Wrox Programmer Forums
|
BOOK: SQL Functions Programmer's Reference
This is the forum to discuss the Wrox book SQL Functions Programmer's Reference by Arie Jones, Ryan K. Stephens, Ronald R. Plew, Robert F. Garrett, Alex Kriegel; ISBN: 9780764569012
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: SQL Functions Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 10th, 2011, 07:48 PM
Registered User
 
Join Date: Jun 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up Logic for correlated subquery

hi i want to know the logic of this query..i mean how data flows.....
i want to know what do the
where subtotal <=
please help me to understand this with the help of dfd if necessary


USE AdventureWorks
SELECT TerritoryID, SubTotal, SalesPersonID, SalesOrderID
FROM Sales.SalesOrderHeader AS SO1
WHERE SubTotal <= (SELECT MAX(SO2.SUBTOTAL) FROM Sales.SalesOrderHeader AS SO2
WHERE SO1.TerritoryID = SO2.TerritoryID
AND SO1.SubTotal < = SO2.SubTotal
HAVING COUNT(SubTotal) <= 5)
ORDER BY TerritoryID,SubTotal DESC;





Similar Threads
Thread Thread Starter Forum Replies Last Post
Do i have to use a subquery, if yes then how? code_lover SQL Language 2 January 2nd, 2007 02:22 PM
Difference between Correlated Subquery and Subquer ramk_1978 SQL Language 2 June 12th, 2006 05:35 AM
Correlated Subquery Rewrite Needed gstanden SQL Language 5 November 24th, 2004 02:39 PM
Correlated Subquery part of Select List gstanden SQL Language 1 November 24th, 2004 07:25 AM
Mixing Data access logic and business logic polrtex BOOK: Professional Jakarta Struts 0 December 15th, 2003 07:19 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.