Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

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
Advertisement