Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2005
    Posts
    4

    Exclamation Unanswered: query oracle 8i user

    For this table below I want to count the number of 0's put, that in one column and count the remaining numbers and put that in another column. I also want to group the title so that for example ice hockey only appears once... the data below has already been selected from a table using a query.

    TITLE THREAD
    -------------------------------------------------- ----------
    Ice Hockey 146
    Gaelic 0
    Ice Hockey 143
    Ice Hockey 154
    Soccer 0
    Soccer 0
    Ice Hockey 0
    Ice Hockey 155
    Ice Hockey 156
    Ice Hockey 143
    Ice Hockey 143

    TITLE THREAD
    -------------------------------------------------- ----------
    Ice Hockey 0
    Ice Hockey 0
    Ice Hockey 160
    Ice Hockey 161
    French Soccer 0
    Ice Hockey 0
    Skiing 0
    Ice Hockey 160

    19 rows selected.

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    You mean like this?
    Code:
    select title, count(decode(thread,0,1)) zeroes,
           count(decode(thread,0,null,1)) non_zeroes
    from   mytable
    group by title;

Posting Permissions

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