Results 1 to 5 of 5

Thread: Groupby Unions

  1. #1
    Join Date
    May 2004
    Posts
    144

    Unanswered: Groupby Unions

    hi
    I have MSSQL query that performs multiple UNION ,but I would like to perform a GROUPBY on the whole result set.
    How Can i do this?
    plz help...
    bono

  2. #2
    Join Date
    Apr 2004
    Location
    Germany
    Posts
    23
    What about creating a view with the union statement?
    On the view you can perform the group by on the whole result set.

    Sneaky Pie

  3. #3
    Join Date
    Nov 2003
    Posts
    94
    use pubs

    select U.city, count(U.city)
    from
    (
    select city from authors
    union all
    select city from publishers
    ) U
    group by u.city

  4. #4
    Join Date
    Apr 2004
    Location
    Germany
    Posts
    23
    Hi HanafiH,

    your solution is much better than mine, I didn't know that this could work. So I've learned something new.

    Thanks for that

    Sneaky Pie

  5. #5
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by KeHoeff
    Hey I'm not quite sure if there is or not, but is there a section to advertise my website?

    Thanks!
    If your website is related to technology, particularly databases or webby stuff, then you can use the Marketplace.
    Post anywhere else and you will find they all get deleted and you get banned.
    Advertise anything else, or anything we just don't like, they all get deleted and you get banned.

    The forum is for database professionals to help each other, so we have pretty narrow definitions of what else we will accept.
    Testimonial:
    pootle flump
    ur codings are working excelent.

Posting Permissions

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