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

select number of rows from query

Options
  • 13-06-2007 12:31pm
    #1
    Registered Users Posts: 1,552 ✭✭✭


    In sql plus
    How do I get the number of distinct rows of a certain value?

    for example

    select group_number from records group by group_number

    How would I query for the total number of group_numbers in this query?


Comments

  • Registered Users Posts: 23,212 ✭✭✭✭Tom Dunne


    quinnd6 wrote:
    In sql plus
    How do I get the number of distinct rows of a certain value?


    select group_number from records group by group_number

    I'm not sure I am following you.

    Are you looking to count the number of rows returned?

    If so, use the COUNT() function:

    select COUNT(group_number) from records

    or, if you wanted distinct values for group_number:

    select COUNT(DISTINCT(group_number) from records


  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    select count(id), group_number from records group by group_number


  • Closed Accounts Posts: 97 ✭✭koloughlin


    If you want distinct ids then you could try

    select group_number, count(distinct id) from records group by group_number


  • Registered Users Posts: 1,552 ✭✭✭quinnd6


    select count(distinct(group_number) from records
    is what I was looking for.
    Thanks


Advertisement