SELECT T.Y,T.AMT AS Q1,Q2.AMT AS Q2,Q3.AMT AS Q3,Q4.AMT AS Q4 FROM T_Y_Q_AMT T ,(SELECT Y,AMT FROM T_Y_Q_AMT WHERE Q =2) Q2 ,(SELECT Y,AMT FROM T_Y_Q_AMT WHERE Q =3) Q3 ,(SELECT Y,AMT FROM T_Y_Q_AMT WHERE Q =4) Q4 WHERE T.Y = Q2.Y AND T.Y = ...
SELECT DEPTNO INTO V_DEPTNO FROM EMP WHERE EMPNO = V_EMPNO; CASE WHEN V_DEPTNO = 10 THEN UPDATE EMP SET SAL = SAL+1000 WHERE EMPNO = V_EMPNO; DBMS_OUTPUT.PUT_LINE(V_EMPNO||'工资1000'); WHEN V_DEPTNO = 20 THEN UPDATE EMP SET SAL = SAL+2000 WHERE EMPNO = V_EMPNO; DBMS_OUTPU...
CASEWHEN条件1THEN值1WHEN条件2THEN值2 ...ELSE值nEND 值后面没有分号(;) 可以作条件的语句: 凡是可以再where子句里做条件的都可以 作为“条件”
10.获取comments select * from all_tab_comments where table_name = 'DWI_TR_EC_RISK_CTRL_BUSINESS' select * from all_col_comments where table_name = 'DWI_TR_EC_RISK_CTRL_BUSINESS' select * from all_tab_columns t where t.TABLE_NAME IN ('EPT_INVOICE_LINES_T_V','EPT_INVOICE_HEADER_T...
case when ... then .. when .. then ... end 这种表达式,是sql的不同条件分支结果。 举例如下, 1、创建数据表,create table test_student(stu_id number, class_id number); 2、插入测试数据, insert into test_student values(1,1001); insert into test_student values(2,1001); insert into test...
└限定查询┌语法 select 列1,列2 from 表 where 条件 └操作符┌比较符 > < >= <= = != <> ├逻辑符 and or not ├between 小值 and 大值 ├in (值1,值2,...) ├算数符 +-*/ ├空 is null is not null ├连接符 || └like '匹配的内容'函数┌系统函数┌单行函数┌数值函数┌abs(数...
round((sl1+sl2+sl3+sl4-hmax)/21,2) sqdms,round((wsl1+wsl2+wsl3+wsl4-wmax)/12,2) wqdms, round((sqpml/decode(pmmds,0,1,pmmds))*qhmds,2) qhl,(mdkcsl-sqpml) KCPMC FROM YRYP_PSBH t,luckman@house w where rq=trunc(sysdate) and t.dm=w.dm ) a1 ) a2) a3) a4...
在PL/SQL中,CASE语句用于根据条件选择不同的操作或返回不同的值。当CASE结果中有多个值时,可以使用以下两种方式处理: 使用CASE表达式:在CASE表达式中,可以为每个条件提供一个返回值。例如: 代码语言:sql 复制 SELECT CASE WHEN condition1 THEN result1 WHEN condition2 THEN result2 ... ELSE result END FROM ...
into v_man_sex from student where sex = 1; -- 多个字段赋值 select student_name,sex into v_name,v_sex from student where student_id = 'S003'; -- 获取一行数据 ( 此处需要查询出所有的字段,否则可能报错 ) select student_id,student_name,sex,CREATE_TIME into v_row from student where stude...
sum(casewhenB.RISK5_FLAG=5thenB.FUNDING_BALend)/10000asFUNDING_BAL_5 查询scott拥有的角色select*fromdba_role_privswhereGRANTEE=upper('scott'); 查询角色select*fromdba_roles; 用plsql工具编程可以节约时间,安全性高,提高性能数据库不用对sql进行编译了因为他已经打包好了一个过程 plsql缺点移植性不好...