Advertisement
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.

select number of rows from query

  • 13-06-2007 12:31PM
    #1
    Registered Users, Registered Users 2 Posts: 1,559 ✭✭✭


    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, Registered Users 2 Posts: 23,202 ✭✭✭✭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, Registered Users 2 Posts: 68,173 ✭✭✭✭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, Registered Users 2 Posts: 1,559 ✭✭✭quinnd6


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


Advertisement