Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

SQL

  • 05-12-2011 03:02AM
    #1
    Registered Users, Registered Users 2 Posts: 76 ✭✭


    could sombody help me with this,

    SELECT AVG(advance), AVG(price)
    FROM titles
    GROUP BY pub_id, category
    What do i need to add to remove the NULL values?
    many thanks
    Gareth


Comments

  • Registered Users, Registered Users 2 Posts: 76 ✭✭gardoyle27


    Cancel that, just twigged it, i'm a numpty at times!!


  • Closed Accounts Posts: 910 ✭✭✭Jagera


    Just out of interest, how are you using the results of that query?

    Normally, one would include the pub_id and category, so you know what average you are looking at, i.e.

    SELECT pub_id, category, AVG(advance), AVG(price)
    FROM titles
    GROUP BY pub_id, category


  • Registered Users, Registered Users 2 Posts: 76 ✭✭gardoyle27


    i'm not using it for anything, i had 100 sql questions to do for college and that was one of the questions,


  • Closed Accounts Posts: 910 ✭✭✭Jagera


    What did you put for your answer? I'm a bit stumped, as it could be mis-interpreted.

    1. remove nulls from result set?
    2. remove nulls from calculating the averages (I know how SQL handles these internally)


  • Registered Users, Registered Users 2 Posts: 76 ✭✭gardoyle27


    Jagera wrote: »
    What did you put for your answer? I'm a bit stumped, as it could be mis-interpreted.

    1. remove nulls from result set?
    2. remove nulls from calculating the averages (I know how SQL handles these internally)

    it was to remove the nulls from the result set
    can remeber exactly now but it was something like this

    SELECT AVG(advance), AVG(price)
    FROM titles

    WHERE advance IS NOT NULL
    OR price IS NOT NULL
    GROUP BY pub_id, category


  • Advertisement
Advertisement