Results 1 to 2 of 2

Thread: Help with Query

  1. #1
    Join Date
    Feb 2004
    El Salvador

    Unanswered: Help with Query

    I have two tables, one with all the items (iv00101) and one with history of sales per month (iv30102). I need to make a query where it displays the item number, the item description, and the sum of the sales of the months I select.

    for example:

    select a.itemnmbr as Number, a.itemdesc as Description, sum(b.smrysales) as Sales
    from iv00101 as a left join iv30102 as b on a.itemnmbr = b.itemnmbr
    where (b.month = 12 and b.year=2003)

    that gives me no problem when the item has a sales history on december/2003. But if an item was created january/2004 and I make the same query, that item doesn't appear beacuse it has no sales history on december/2003. I need it to appear with the sum(b.smrysales) as Sales = 0

    any ideas?

  2. #2
    Join Date
    Apr 2002
    Toronto, Canada
    change WHERE to AND so that the conditions involving b.month and b.year are part of the ON clause | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts