brittneybrinsfield / sequel-pro

Automatically exported from code.google.com/p/sequel-pro
Other
0 stars 0 forks source link

Couldn't sort column. #1832

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
ISSUE:

Cannot sort a column in a grouped nested query:

SELECT qsid, GroupColumn, IF(Days <= 0, -1, 1) AS SignDays                  
                      FROM (
                      SELECT DISTINCT 'ray' AS GroupColumn, 'holland' AS qsid, SS.SurgicalAppointmentDate AS Days
                    FROM DatabaseB.StoredSummary SS
                      ) Temp
                       GROUP BY qsid, SignDays, GroupColumn WITH ROLLUP 

What steps will reproduce the problem?
1. run a query like the above
2. try to sort on Days

What is the expected output?

Sorted result

What do you see instead?

Last Error Message
Couldn't sort column.

What version of Sequel Pro are you using? 1.0.2 Build 4096
What version of OS X are you using? 10.8.5 Build 12F45
What version of MySQL are you connecting to on the server? 5.6.13

Please provide any additional information below.

Original issue reported on code.google.com by raymonda...@gmail.com on 21 Oct 2013 at 8:14

Attachments:

GoogleCodeExporter commented 8 years ago
The issue appears to be that Sequel Pro adds an ORDER BY 3 to a query with WITH 
ROLLUP

Original comment by raymonda...@gmail.com on 21 Oct 2013 at 8:20

GoogleCodeExporter commented 8 years ago
Possible solution: on the ordering, if a query with a WITH ROLLUP is detected, 
wrap it in another query and use that. 
http://stackoverflow.com/a/12408367/744228

Original comment by raymonda...@gmail.com on 21 Oct 2013 at 8:22