Re: How to count rows in a sub-table

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Vishal Parkar (REMOVE_THIS_vgparkar_at_yahoo.co.in)
Date: 05/18/04


Date: Tue, 18 May 2004 06:47:11 +0530


  use left outer join

  Ex:

  select books.BookName, Count(orders.bookid) as TotalSold
  from Books left outer Join Orders on Orders.BookID = Books.BookID
  group by books.BookName
  order by books.BookName

  --
  Vishal Parkar
  vgparkar@yahoo.co.in | vgparkar@hotmail.com



Relevant Pages

  • Re: Combine results based on a value
    ... I have BOOK_RENTALS which contains customer names and books: ... JOHN SMITH, BOOKA ... You might try doing this with an outer join, ... Left outer join syntax: ...
    (comp.databases.oracle.server)
  • Re: Better way to sum 0 entries?
    ... I originally thought of this Tom, but the outer join should also include the ... > where b.LibraryID = l.LibraryID) as Books ... > LibraryID INTEGER, ...
    (microsoft.public.sqlserver.programming)
  • Re: How to count rows in a sub-table
    ... That did the trick. ... I had tried left outer join previously, ... was forcing all rows to be at least one. ... from orders instead of books did the trick. ...
    (microsoft.public.sqlserver.programming)