Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: sql sum query

  1. #1
    New Coder thindrakhya's Avatar
    Join Date
    Jun 2007
    Posts
    90
    Thanks
    8
    Thanked 0 Times in 0 Posts

    sql sum query

    hi all

    I am using this query and php is giving me the error

    select productId , sum(quantity) from tblorderdetail where sum(quantity) > 10 group by productId


    Can anyone know where i am wrong

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    Quote Originally Posted by thindrakhya View Post
    select productId , sum(quantity) from tblorderdetail where sum(quantity) > 10 group by productId
    thats gotta be in the having clause

    Code:
    select productId , sum(quantity) from tblorderdetail  group by productId having sum(quantity) > 10
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow

  • Users who have thanked shyam for this post:

    thindrakhya (11-27-2007)


  •  

    Posting Permissions

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