Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2007
    Posts
    2

    Unanswered: groupby expression in sql

    hi there,

    Item (upc, title, type, category, company, year, sellPrice)
    Purchase (receiptId, date, cid, name, card#, expire, expectedDate, deliveredDate)
    PurchaseItem (receiptId, upc, quantity)
    Stored (name, upc, stock)

    I have the following tables can anyone please tell me what is wrong with my sql statement:

    [CODE]
    select title, company, sum(stock) as currentstock, sum(quantity) as quantitysold
    from item, purchase, purchaseitem, stored
    where purchaseitem.upc = item.upc AND purchaseitem.receiptID = purchase.receiptID AND
    purchaseitem.upc = stored.upc
    group by title;



    The user provides a date and a number, say n. The system prints a list of the n best selling items on that day, by all the stores. For each best seller, the system shows the title, the company, the current stock and the number of copies sold. The output should be ordered according to sales: the best selling item should be first, the second best will follow, etc.

    Thanks.

  2. #2
    Join Date
    Nov 2007
    Posts
    2

    Groupby Expression Error

    sorry i forgot to say that there is a groupby expression error.

  3. #3
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    http://www.dbforums.com/showthread.php?t=1031644
    Please read & follow posting guidelines as stated above.

    >there is a groupby expression error.
    Error? What error? I don't see any error.

    Do you honestly expect us to do your homework for you?
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  4. #4
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    'company' should be added into the GROUP BY clause.

Posting Permissions

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