OEACLE judgment sentence case

Before using mysql, oracle's judgment statement will not be used (normal SQL is not to add, delete, modify, and check, it will not be a bit more), so I checked it on the Internet.
It took two hours to figure it out.

Create a simple table:

create table t1 ( a int);
insert into t1 values (1),(1),(0)

Then, I want the value of 1 to be displayed as true, and the value of 0 to be false.

To write:

select 
case
when t1.a=1 then "true"
when t1.a=0 then "false"
end b
from t1;

Insert picture description here

The format is basically the standard VB language 2333333333.
Logic: CASE when then ELSE END
gives everyone a standard VB comparison:

select case a
  case 1
   msgbox "a"
  case 2 to 5
   msgbox "b"
  case else
   msgbox "c"
end select

It is recommended to study VB 233333333
Do you say SQL is VB language with SQL language? ? ?

TIP: VB was popular in the past, and VF was used for finance. Now look at it: matlab, java, python, php, C, basically there is no place for VB...

Also, sysdate is the correct function to get the time, and the return value is datetime.
sysdate() reports an error.
It's all small details, just pay attention.

Guess you like

Origin blog.csdn.net/weixin_45642669/article/details/113844056