xenopsy Posted April 30, 2013 Share Posted April 30, 2013 (edited) Hello all I have this order by issue that i would like to solve. I have 3 tables, Date, Time and Reader. This is my current result when i order it by Date, Reader, Time: Date Time Reader13-02-25 23:59:38 013-02-25 23:59:39 013-02-25 23:59:40 013-02-25 23:58:06 1613-02-25 23:58:37 1613-02-25 23:59:47 1613-02-26 00:10:20 013-02-26 00:10:22 013-02-26 00:14:00 013-02-26 00:00:30 1613-02-26 00:01:15 1613-02-26 00:11:01 16 But I want it to look like this: 13-02-25 23:59:38 013-02-25 23:59:39 013-02-25 23:59:40 013-02-26 00:10:20 013-02-26 00:10:22 013-02-26 00:14:00 013-02-25 23:58:06 1613-02-25 23:58:37 1613-02-25 23:59:47 1613-02-26 00:00:30 1613-02-26 00:01:15 1613-02-26 00:11:01 1613-02-26 00:11:02 1613-02-25 23:59:38 013-02-25 23:59:39 013-02-25 23:59:40 013-02-26 00:10:20 013-02-26 00:10:22 013-02-26 00:14:00 013-02-25 23:58:06 1613-02-25 23:58:37 1613-02-25 23:59:47 1613-02-26 00:00:30 1613-02-26 00:01:15 1613-02-26 00:11:01 16 Is there a way to do this? Didnt realy know what to search for in this matter. Regards Edited April 30, 2013 by xenopsy Link to comment Share on other sites More sharing options...
justsomeguy Posted April 30, 2013 Share Posted April 30, 2013 It sounds like you want to order by reader first. Link to comment Share on other sites More sharing options...
xenopsy Posted April 30, 2013 Author Share Posted April 30, 2013 The problem with ORDER BY 'Reader' first is that there are several thousands of rows for each reader. Also, there are 10 readers. Thus my request. Sure, I could do query's for each reader. But I would realy like another solution then that. Regards Link to comment Share on other sites More sharing options...
justsomeguy Posted April 30, 2013 Share Posted April 30, 2013 I don't know what you're asking for, what you showed you want is a result set that is ordered by reader, then date, then time (duplicated, I assumed you pasted it twice). If that's not what you want, then what do you want? This: The problem with ORDER BY 'Reader' first is that there are several thousands of rows for each reader. Also, there are 10 readers. Thus my request.doesn't explain why ordering by readers is not going to work for you. So what if there are several thousand rows or multiple readers? Link to comment Share on other sites More sharing options...
xenopsy Posted May 4, 2013 Author Share Posted May 4, 2013 If I order it by Readers, there will be thousends of rows to scroll to the next reader. So for easy viewing, it displays for example one complete night for each reader at a time; Night1 - Reader1Night1 - Reader2Night1 - Reader3Night2 - Reader1Night2 - Reader2Night2 - Reader3 This is almost done by date, reader and time order. But it cind of cuts each shift into half with this order. Theres no dissaster if I cant make it work. It would just be nice and more simple for the people who are using it. Link to comment Share on other sites More sharing options...
justsomeguy Posted May 6, 2013 Share Posted May 6, 2013 I don't think there's a way to do something like that in SQL, you would need to send one query per time frame and order each by the reader. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now