SQL statement-case when then else end, SQL-case
Output the following results based on the preceding table information:
The following are the database and table structure data:
create table DeptSales(deptID int,SubjMonth int ,sales int ,deptname varchar(50))
insert into deptsales (deptid ,subjmonth,sales) values (1,1,55);insert into deptsales (deptid ,subjmon
Case statements and case expressions are an important part of PLSQL Process Control. Although they are easy to use, they are easy to confuse. This article describes the case statement and the case expression, and provides an example
This helps you better understand the simil
Tags: for statement while statement case statement Shell Yang ShufanThe shell, as a scripting language, also contains other program control structures such as loops, branches, and so on, making it easier to perform more complex and powerful functions.Using the FOR Loop statementAt work, you often encounter a task that
An SQL statement is used in the project, such:
Select sum (price * xiaoliang)/sum (xiaoliang) price from ......
When sum (xiaoliang) = 0, the error of division by 0 will occur. What should I do? At first, I wantProgramProcessing, that is, moving the computing process to the program is obviously troublesome. Later, I found the method of using the case statement
is declared and needs to be inserted before the BEGIN keyword: dynamic RESULT sets 1LANGUAGE sql*/create PROCEDURE a_test2 ( V_c VARCHAR (()) DYNAMIC RESULT sets 1LANGUAGE sqlbegin DECLARE t_sql VARCHAR2 (a); DECLARE t_a VARCHAR2 (); DECLARE t_b VARCHAR2 (); DECLARE t_c VARCHAR2 (); DECLARE t_d VARCHAR2 (); --The t_stmt behind the for is consistent with the following prepare variable, and its type is statement.
Select Case StatementExecutes one of several sets of statements based on the value of an expression.
Select Case testexpression[Case Expressionlist-n[Statements-n]] . . .[Case Else Expressionlist-n[Elsestatements-n]]End Select
ParametersTestexpression
An arbitrary numeric or string expression.
Expressionlist-n
An
Tags: DB2 merger Today in the development of a single table to do the merge statement, using the Spring jdbctemplate batch modification, so to pass the parameters in, using the above merge statement to complete, here to make a record. Some Java code is as follows: private void Uploadagentchannel (Workbook Workbook, String City, int month) {Sheet Sheet = workbook
Tags: using ar sp data div art on BS sizePaged query statements that are used in different databases:Current page: CurrentPagePage Size: pagesize1. Oracle DatabaseSELECT * FROM (select A.*,rownum rn from (query_sql) A) where Rn Note: query_sql is a query SQL statement.OrSELECT * FROM (select RowNum rn,id from TABLENAME where RowNum 2. Infomix DatabaseSelect Skip CurrentPage First pagesize * from TABLENAME3. DB2 DatabaseSELECT * FROM (select field 1, F
Label:The first form of a notationINSERT into PERSVALUES (+, ' Harris ', +, ' Sales ', 5, 18000, 1000, ' 1950-1-1 ')The second type of notationINSERT into PERS (NAME, JOB, ID)VALUES (' Swagerman ', ' PRGMR ', 500),(' Limoges ', ' PRGMR ', 510),(' Li ', ' PRGMR ', 520)The third kind of wordingINSERT into PERS (ID, NAME, DEPT, JOB, years, SALARY)SELECT ID, NAME, DEPT, JOB, years, SALARYFrom staffWHERE DEPT = 38The fourth kind of notationINSERT into PERS (ID, NAME, JOB, DEPT, SALARY)VALUES (410, '
you can successfully list, it is considered anonymous FTP is turned on, otherwise considered off.(2) Assign a value to the variable target by filtering out all IP addresses in the/etc/ethers file via the awk command.(3) Use the FOR Loop statement, read the IP address in the target variable, and repeatedly probe the FTP open situation.The script is as follows:[Email protected] ~]# VI scanhost.sh#!/bin/bashtarget=$ (awk ' {print '} '/etc/ethers)echo "T
didn't find it anyway.Case Use Scenario 3: Let's say you put Zhang San's birthday updated to 1949-10-1, John Doe's birthday updated to 1997-7-1, etc., like this update by a lot. What should we do? Very simple, most people would do that.Update USER set birthday= ' 1949-10-1 ' where Name= ' Zhang San ';Update USER set birthday= ' 1997-7-1 ' where name= ' John Doe ';Update USER set birthday= ' 1949-10-1 ' where Name= ' Zhang San ';Update USER set birthday= ' 1997-7-1 ' where name= ' John Doe ';Whe
Switch case is a qualified data in js, which is much simpler than if else. Next I will introduce my understanding of js switch case.
In the if Condition Statement, only one logical condition can exist. if multiple conditions exist, you can use nested if statements to solve the problem. However, this method increases the complexity of the program, reduce program r
5.1 Case Statement1. The case statement has the following structureCase SELECTORWhen EXPRESSION 1 then STATEMENT 1;When Expresssion 2 then STATEMENT 2;........When EXPRESSION n then STATEMENT N;ELSE
Switch syntax
The code is as follows
Copy Code
switch (expression){case constant Expression 1: statement 1;....Case constant Expression 2: statement 2;Default: statement;}
Default is to execute it if it is not matched, and default is no
SQL statement case when then else end returns a qualified value, sqlcase
Case has two formats
Simple Case functions and Case search functions:
-- Simple Case function CASE sex WHEN '1'
Tags: Linux shell1.case structural Conditional statement syntaxThe case statement is actually the canonical multi-branch if statementCase "string variable" inValue 1) Instruction 1 ...;;Value 2) Instruction 2 ...;;*) Instruction 3 ...EsacChinese programming Syntax:Case "Find a girlfriend condition" inHave a room) to ma
look at this. When this value is set to 0 o'clock, a table with a self-increasing field inserts the behavior of a row of data:
1) Apply for Auto_inc lock
2) Get the current AUTO_INCREMNT value N, give auto_increment plus 1
3) Perform the insert operation and fill n into the new row corresponding field
4) Release Auto_inc lock
We see this process, although innodb in order to reduce the size of the lock, the execution of the statement is released
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.