A simple case expression that uses an expression to determine the return value.
Grammar:
The code is as follows
Copy Code
Case Search_expressionWhen Expression1 THEN RESULT1When Expression2 THEN result2...When Expressionn THEN ResultnELSE Default_result
Search the case expression, using criteria to determine the return valu
Introduction to the case command: This command is used for conditional judgment, select structure.1 . Command format:Case switch in-----switch variable valuevalue1)Statement-----Statement Statement...;;value2)Statement...;;*)Statement
Create a shell with a case statement (function is open, close, reset, display virtual machine)#!/bin/bashCase "$" inStart)/* When the keyword is start, execute the statement that opens the virtual machineecho Start ...Virsh Start $ >/dev/null;;Poweroff)/* Executes a statement that forces the virtual machine to be close
Label:First, briefThe process of manipulating the database often forgets the syntax of the case keyword, so record it here.Second, the contentSimple syntax for case SELECT testname, Testsex,
Case testsex
when ' 1 ' Then ' male '
when ' 0 ' Then ' female '
END Sex
from SELECT testname, Testdatetime,
Case
', 673,48,625,52, ' profession ');
Simple Statement
Copy Code code as follows:
SELECT case when 10*2=30 THEN ' correct '
When 10*2=40 THEN ' correct '
ELSE ' Should be 10*2=20 '
End as ' result ';
Multi-expression
Copy Code code as follows:
SELECT Case 10*2
When THEN ' correct '
When THEN ' correct '
When THEN ' cor
UpdateHr_user uSetU.is_approve=( Case whenu.curr_org_idinch (Selectt.org_id fromhr_organization t start witht.org_id= 10001263Connect byPrior org_id=T.org_id_parent) Then 'N' ELSE 'Y' END); UpdateHr_user uSetU.is_approve=( Case whenu.curr_org_idinch (Selectt.org_id fromhr_organization t start witht.org_id= 10001263Connect byPrior or
1.ifExpression: IF (Expr1, EXPR2, EXPR3)The EXPR1 condition is true, the value is Expr2, false, and the value is EXPR3Cases:SELECT o.id,u.account,catagory. ' Name ', Ordertime,detail.amount,periodtime, if (direction='0',' bullish ',' bearish ' = = = O.userid2.case whenCase Column NameWhen condition then resultelse other resultsEnd aliasesCases:SELECT case detail. "Status" when'0'Then'no position opened' whe
JS Some if statement to determine the condition is fasle casePrior to write an if judgment condition produced by the bug, when the Write logic processing data is in the background to the interface before, so I developed a field value of number type 0 or one to judge, the last interface comes out of the time is a string, whether 0 or 1 is true. Number of type 0, the Boolean value is false,string type of 0, and the Boolean value is true. So here's a
Label:Ora-00932:inconsistent datatypes:expected number got CHAR00932.00000-"Inconsistent datatypes:expected%s got%s"1 Case 2when '0'then NVL (tx_cnt,0 )3 ELSE4END act_tx_cnt,TX_CNT is number type, which is the count after group byTOT_TX_CNT is VARCHAR2 (XX) typeTherefore, the above error message appears.Solution: Transform data to convert Number data to VACHAR2 (XX) type1 Case 2when'0'
enters a value, the input value will be assigned to N,n on behalf of the user input contentN1= Input ('User name >>>') N2= Input ('Password >>>')ifN1 = ="Frank" andN2 = ="frank123": Print('Enter the correct')Else: Print('Erroe')Or is not tested, anyway is and is 2 satisfied to be true, or is a casual satisfaction is true6.if Judging if the number is even[[email protected] python]#Cat if3.py#!/usr/bin/env python#_*_ Coding:utf8 _*_#when there is input, wait
1. Structure 2. Case studies#!/bin/bashecho "Wayne:input 1" echo "echo : Input 2" echo "We : Input 3" read-t 30-p "Input your choice:" Choca Se "$cho" in "1") echo "Wayne Love echo" ;; " 2 ") echo" Echo love Wayne " ;; " 3 ") echo" We love EW " ;; *) echo "No no No" ;; esac~
Label:Use [EShop]GO/****** object:storedprocedure [dbo]. [Sp_findproc] Script DATE:2015/8/19 11:05:24 ******/SET ANSI_NULLS onGOSET QUOTED_IDENTIFIER ONGOALTER PROCEDURE [dbo]. [Sp_findproc] (@akey varchar (255)) As --Find keywords in all stored procedures, keywords are not case sensitiveDECLARE @aname as varchar (700)DECLARE @atext as varchar (8000)DECLARE @acolid as intDECLARE @pos as intDECLARE @start as intDECLARE @end as intDECLARE @shorttext as
Title: Seek 1+2+...+n, the request cannot use multiplication and division method, for, while, if, else, switch, case and so on keyword and conditional judgment statement (A? B:C)
This problem is indeed a bit biased, most people on the internet to give the solution are recursive. public int sum (int n) {if (n==1)
return 1;
Else
Return N+sum (n-1);
Obviously, the condition is used to judge, does not meet the
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.