Show 4 Records that occur more often...and how often they occur.

Discussion in 'ASP .Net' started by Miguel Dias Moura, May 6, 2004.

  1. Hello,

    i have a dataSet in an ASP.Net / VB page which connects to a database named
    "DB" with fields AuthorName, BookTitle, BookEditor.

    I want do display 4 records in my page as follows:
    Author Name # Number of books published by this Author (Number of records
    associated with this Author)

    I want to display the 4 Authors which published more books...

    In conclusion:
    I want to show the 4 AuthorName values which appear more often in the
    database and display the number of records having that AuthorName.

    Can you help me out?

    How should my SQL look? What do i need to add?

    Thank You,
    Miguel
    Miguel Dias Moura, May 6, 2004
    #1
    1. Advertising

  2. Miguel Dias Moura

    avnrao Guest

    This post should have been in SQL. neway, what required is getting the
    things done..

    Select Top 4 AuthorName, Sum(BookTitle) from Table Group By AuthorName Order
    By Sum(BookTitle) Desc
    check if it works.

    Av.

    "Miguel Dias Moura" <> wrote in message
    news:...
    > Hello,
    >
    > i have a dataSet in an ASP.Net / VB page which connects to a database
    > named
    > "DB" with fields AuthorName, BookTitle, BookEditor.
    >
    > I want do display 4 records in my page as follows:
    > Author Name # Number of books published by this Author (Number of
    > records
    > associated with this Author)
    >
    > I want to display the 4 Authors which published more books...
    >
    > In conclusion:
    > I want to show the 4 AuthorName values which appear more often in the
    > database and display the number of records having that AuthorName.
    >
    > Can you help me out?
    >
    > How should my SQL look? What do i need to add?
    >
    > Thank You,
    > Miguel
    >
    >
    avnrao, May 6, 2004
    #2
    1. Advertising

  3. Thanks,

    can you tell where can i find the SQL forum?


    "avnrao" <> wrote in message
    news:uh1$...
    > This post should have been in SQL. neway, what required is getting the
    > things done..
    >
    > Select Top 4 AuthorName, Sum(BookTitle) from Table Group By AuthorName

    Order
    > By Sum(BookTitle) Desc
    > check if it works.
    >
    > Av.
    >
    > "Miguel Dias Moura" <> wrote in message
    > news:...
    > > Hello,
    > >
    > > i have a dataSet in an ASP.Net / VB page which connects to a database
    > > named
    > > "DB" with fields AuthorName, BookTitle, BookEditor.
    > >
    > > I want do display 4 records in my page as follows:
    > > Author Name # Number of books published by this Author (Number of
    > > records
    > > associated with this Author)
    > >
    > > I want to display the 4 Authors which published more books...
    > >
    > > In conclusion:
    > > I want to show the 4 AuthorName values which appear more often in the
    > > database and display the number of records having that AuthorName.
    > >
    > > Can you help me out?
    > >
    > > How should my SQL look? What do i need to add?
    > >
    > > Thank You,
    > > Miguel
    > >
    > >

    >
    >
    Miguel Dias Moura, May 6, 2004
    #3
  4. Miguel Dias Moura

    avnrao Guest

    microsoft.public.sqlserver.programming

    Av.
    "Miguel Dias Moura" <> wrote in message
    news:%...
    > Thanks,
    >
    > can you tell where can i find the SQL forum?
    >
    >
    > "avnrao" <> wrote in message
    > news:uh1$...
    >> This post should have been in SQL. neway, what required is getting the
    >> things done..
    >>
    >> Select Top 4 AuthorName, Sum(BookTitle) from Table Group By AuthorName

    > Order
    >> By Sum(BookTitle) Desc
    >> check if it works.
    >>
    >> Av.
    >>
    >> "Miguel Dias Moura" <> wrote in message
    >> news:...
    >> > Hello,
    >> >
    >> > i have a dataSet in an ASP.Net / VB page which connects to a database
    >> > named
    >> > "DB" with fields AuthorName, BookTitle, BookEditor.
    >> >
    >> > I want do display 4 records in my page as follows:
    >> > Author Name # Number of books published by this Author (Number of
    >> > records
    >> > associated with this Author)
    >> >
    >> > I want to display the 4 Authors which published more books...
    >> >
    >> > In conclusion:
    >> > I want to show the 4 AuthorName values which appear more often in the
    >> > database and display the number of records having that AuthorName.
    >> >
    >> > Can you help me out?
    >> >
    >> > How should my SQL look? What do i need to add?
    >> >
    >> > Thank You,
    >> > Miguel
    >> >
    >> >

    >>
    >>

    >
    >
    avnrao, May 6, 2004
    #4
  5. Miguel Dias Moura

    Hans Kesting Guest

    "avnrao" <> wrote in message news:uh1$...
    > This post should have been in SQL. neway, what required is getting the
    > things done..
    >
    > Select Top 4 AuthorName, Sum(BookTitle) from Table Group By AuthorName Order
    > By Sum(BookTitle) Desc
    > check if it works.
    >
    > Av.
    >


    shouldn't that be "COUNT(booktitle)" ?? :)


    Hans Kesting
    Hans Kesting, May 6, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mick
    Replies:
    0
    Views:
    418
  2. Afanasiy
    Replies:
    3
    Views:
    284
    Peter Hansen
    Nov 4, 2003
  3. Bob Martin
    Replies:
    0
    Views:
    78
    Bob Martin
    Jan 10, 2014
  4. Gene Heskett
    Replies:
    0
    Views:
    63
    Gene Heskett
    Jan 10, 2014
  5. Bob Martin
    Replies:
    0
    Views:
    70
    Bob Martin
    Jan 11, 2014
Loading...

Share This Page