Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2007
    Location
    010101010110100
    Posts
    803

    Unanswered: How *not to* use SELECT DISTINCT

    Hello all,

    I have an issue that I can't solve. I was using SELECT DISTINCT but I think there may be a better way of doing this. Below is some of my sample data.
    Laundry Room - (East) Tuesday 00:00:00 06:00:00

    Laundry Room - (East) Wednesday 00:00:00 06:00:00

    Utility Room - (East) Thursday 00:00:00 06:00:00

    Utility Room - (East) Friday 00:00:00 06:00:00

    Gym - (East) Saturday 00:00:00 06:00:00
    This data comes from 4 different tables. After joining them all together, I would like to sort the data by the first field which indicates the room type then have all of the times and days under that. As you can see, I have "Laundry Room" 2x. Here is what I am trying to achive.

    Laundry Room East

    Tuesday 00:00:00 06:00:00

    Wednesday 00:00:00 06:00:00

    Thursday 00:00:00 06:00:00

    Friday 00:00:00 06:00:00

    Gym
    Saturday 00:00:00 06:00:00

    Sunday 00:00:00 06:00:00
    EDIT: I forgot to mention that that first field (Gym, Laundry room) is data within the field that can be added by the user dynamically. If that data was always the same and never changed, it would be easy. I could just specify exactly what I needed through a select. I hope I am making sense here.

    Can someone please point me in the direction I should go with this?

    Thanks,

    Frank
    Last edited by Frunkie; 08-15-07 at 03:45.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    do this with your application script

    it requires merely ORDER BY, not GROUP BY

    GROUP BY is for collapsing multiple rows of a group into one result row
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Mar 2007
    Location
    010101010110100
    Posts
    803
    Quote Originally Posted by r937
    do this with your application script

    it requires merely ORDER BY, not GROUP BY

    GROUP BY is for collapsing multiple rows of a group into one result row
    Ok Rudy, thanks. I figured that it may need to be done in my application but I was hoping for an sql fix. Thanks again.

Posting Permissions

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