我在下面有一个查询,它是按'ProgramName'
使用排序的lp.name
排序。最高值'Science - IN'
之后是'Science - FL'
,但不'Science - FL'
应该高于另一个?我需要做一些特别的事情吗?
SELECT
lp.name AS 'program_name'
FROM customer_order co
JOIN customer c on co.customer_id = c.id
JOIN license_program lp ON co.license_program_id = lp.id
ORDER BY
CASE lower(sort_direction) WHEN 'asc' THEN
CASE lower(sort_order)
WHEN 'programname' THEN lower(lp.name)
ELSE (entry_date)
END
END ASC,
CASE lower(sort_direction) WHEN 'desc' THEN
CASE lower(sort_order)
WHEN 'programname' THEN lower(lp.name)
ELSE (entry_date)
END
END DESC
LIMIT start_page, page_size;