simple_case.sql

来自「AbsDataBase5.16 最新版」· SQL 代码 · 共 13 行

SQL
13
字号
/* This SQL script uses Demos.abs database. 
   Please open ...\AbsoluteDatabase\Demos\Data\Demos.abs database file.
   This sample illustrates use of simple CASE function.
   For each row in the dataset being retrieved, field "VenueNo" is compared to 2, and, if it is true, the string "Memorial Stadium" appears to the right of event name. If it is not true, then "VenueNo" is compared to 4, and if it equals to 4, string "Coliseum" appears. If "EventNo" matches neither 2 nor 4, ELSE part of the statement is executed and "unknown venue: VenueNo="is shown followed by value of the field "VenueNo".*/

select e1."Event_Name", 
  case e1."VenueNo" 
    when 2 then "Memorial Stadium" 
    when 4 then "Coliseum" 
    else "unknown venue: VenueNo=" + e1."VenueNo" 
  end as "Venue"
  from "events" e1

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?