「SQL」ORDER BYとCASE WHEN文のサンプル

書式
ORDER BY (CASE WHEN 条件式 THEN)
使用例

SELECT CustomerName,Country FROM Customers
ORDER BY (CASE
        WHEN City IS NOT NULL THEN Country
        ELSE City
END);

結果

CustomerName Country
Cactus Comidas para llevar Argentina
Océano Atlántico Ltda. Argentina
Rancho grande Argentina

SQL

Posted by arkgame