Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language 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
  #11 (permalink)  
Old August 8th, 2005, 07:06 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to ~Bean~
Default

Code:
SELECT * FROM (SELECT CustomerID, Count(*), max(date) FROM tblOrders GROUP BY CustomerID) AS a, tblCustomers AS b WHERE b.CustomerID = a.CustomerID
How do I modify this statement to include Customers without any Orders...?


-------------------------
Beware of programmers with screwdrivers...
  #12 (permalink)  
Old August 9th, 2005, 11:22 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Use a left outer join instead of an inner join

SELECT * FROM (SELECT CustomerID, Count(*), max(date) FROM tblOrders GROUP BY CustomerID) AS a, tblCustomers AS b WHERE b.CustomerID *= a.CustomerID





Similar Threads
Thread Thread Starter Forum Replies Last Post
XSL: Count = Count + 1 elayaraja.s XSLT 3 July 18th, 2008 03:21 AM
how to count? wkm1925 SQL Server 2000 2 February 26th, 2007 11:57 AM
is there any in built function to count page count g.tamilselvan MySQL 1 February 15th, 2006 07:43 AM
Count, sum, count a value, return records CongoGrey Access 1 April 18th, 2005 02:25 PM
count() crmpicco MySQL 1 January 28th, 2005 01:44 PM





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