Skip to content

SQL:OrderBy

사용시 주의점

AS 로 만든 컬럼은 문자열로 가능하지만, 이 문자열을 그대로 Order by 에 사용하면 안된다.

적어도 sqlite에서 안된다.

아래 구문은 작동안함.

select
       substr(ci.heat_text, 1, 2) as 'header.lane'
from charging_info as ci
order by 'header.lane'  -- 문자열을 적으면 안된다.

아래 처럼 수정해야 한다.

select
       substr(ci.heat_text, 1, 2) as header_lane
from charging_info as ci
order by header_lane

NULL 위치 지정

See also