问题
The columns for Exposure, Focal, and Iso are not being sorted properly. It seems like they are all being interpreted as strings and sorted as such. For example, if I sort Exposure down, the values can look like this:
1/800, 1/800, 1/800, 1/80, 1/675, 1/640, 1/60, 1/500
If I sort the Focal, it can look like this:
1.4, 1.4, 1.4, 14.0, 14.0, 1.3, 13.0, 1.2, 1.2, 12.0, 1.0, 10.0
and if I sort by ISO, it can look like this:
800, 800, 800, 80, 80, 640, 640, 60, 500, 500, 50
EDIT: My other question (and answers) for doing all this in one single sql query.
回答1:
I tested this on Oracle
with
w_data AS(
select '1/800' exposure from dual union all
select '1/80' from dual union all
select '1/675' from dual union all
select '1/640' from dual union all
select '1/500' from dual
)
select *
from w_data
order by 1 / to_number(substr(exposure, 3, length(exposure)))
For focal you do ORDER BY to_number(focal)
and the same for ISO.
Note that exposure example will only work if first 2 characters are always '1/'. I can rewrite it for more general case, like '2.9/700', if you wish
来源:https://stackoverflow.com/questions/7605069/how-can-i-perform-sql-order-by-exposure-focal-and-iso-in-numeric-not-string