Oracle Table Complex Queryin practical applications often need to perform complex data statistics, often need to display more than one table of data, now we show you a more complex SELECT statementData Grouping -max,min,avg,sum,countHow to show the highest wage and minimum wage for all employeesSql>select Max (SAL) "Maximum wage", min (sal) "minimum wage" from EMP;Please inquire about the highest annual salarySql>select Max (SAL*13+NVL (comm,0) *13) "
Label: 1. Show jobs with average salary of >2000 Select Job,avg (SAL) from EMP Group BY job have avg (SAL) >2500; 2. Calculate the salary above 2000, the average salary of various positions is more than 3000 of the position and average salary Select Job,avg (SAL) from EMP where sal>2000 GROUP BY job has avg (SAL) >3000
Tags: strong SP on work BS Oracle ROM function RAC1. Show jobs with average salary of >2000Select Job,avg (SAL) from EMP Group BY job have avg (SAL) >2500;2. Calculate the salary above 2000, the average salary of various positions is more than 3000 of the position and average salarySelect Job,avg (SAL) from EMP where sal>2000 GROUP BY job has
Tags: information completion care about feature participation recommended color DIVStatistical function Statistical functions include: count (): Sum of Statistics (): Calculate sum min (): Compute Minimum AVG (): Averaging Max (): Calculating the total number of people in the EMP table, average wage, total wage, minimum wage With maximum wage select COUNT (*) Number of AVG (SAL) average salary, sum (SAL) to
Grouping Functions--What is a grouping function: You can perform a single calculation on a set of records in a result setSelect Sal from emp--Single-line grouping function--max, Min (max, min)--Query the highest wage and lowest wage wage in the EMP tableSelect Max (sal), Min (sal)From EMP--sum, AVG (SUM, average)--Query the employee table for the department number is the sum of 20 employees ' wages and the average salarySelect sum (SAL),
identical columns exist in the two tables (if there is only one column, you can connect them naturally)
[Note: Do not repeat natural join with NATURAL connections ,]
Select ename, deptno from emp join dept using (deptno); -- Do not forget to add parentheses and keyword join6. ON clause
Select ename, dname from emp join dept on emp. deptno = dept. deptno;7. left outer join: LEFT OUTER JOIN
Select ename, dname from emp left outer join dept on emp. deptno = dept. deptno;8. right outer join: RIGHT
?
/* Answer: distinct (placed after the select keyword )*/
-- 33. What are the keywords that show both detail records and summary values during grouping? -- Please write a sample code?
/* Answer: Keyword: Compute \ compute by */select s_group, s_age as 'average age' from student where s_group = 'two group' order by s_group compute AVG (s_age) by s_group
-- 34. What are the wildcards in SQL? What is the meaning of each type?
/* A: '_' indicate
Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=5933Test instructions: Length isnnArray of:A_1, a_2, \cdotsa ? 1 ?? ,a ? 2 ?? ,? , each operation can either merge two contiguous numbers for one, with a value of two numbers; It is possible to divide a number into two, two numbers and the original number. Transform the array into a length with minimal manipulationKKand all arrays of equal value, no solution output-1?1。Read the wrong question ah ... Test instructions is an a
# and B. C # ='01'LeftJoin SC C on a. s # = c. s # and C. C # ='02'Where B. score>Isnull (C. score,0)
-- 2. query the information and scores of students whose scores are lower than those of the "01" course.-- 2.1 check whether "01" course and "02" course exist at the same time.Select a. *, B. Score [score of course '01'], C. Score [score of course '02']From student A, SC B, SC CWhere a. s # = B. S # And a. s # = c. s # and B. C # ='01'And C. C # ='02'And B. score -- 2.2 check whether "01" cours
Grouping function: operate on a group of records in the Table. Only one result is returned each time. Common functions include MIN, MAX, SUM, AVG, COUNT, and other MIN and MAX return the minimum and maximum values of each group. Eg: selectmin (salary), max (salary) fromemployees; the SUM and AVG functions return the SUM mean respectively. Eg: selectsum (salary), avg
Blog purpose: To speak with a diagramAuxiliary text Description:1. Call form: Use Component.method () in the client;2. Scope of Use: aggregation, combination with the same structure.Example:Generate conditional statements: When AVG (CPU) > 60% or AVG (MEM) > 70% for 3 min then does scale up to AVG (CPU) > 60%, AVG (MEM
Grouping FunctionsCommonly used grouping functions in SQLCount (): countMax (): ask for maximum valueMin (): To find the minimum valueAVG (): averagingSUM (): sum--count the number of people in the EMP table select COUNT (*) from EMP; --statistics on the number of people who receive the bonus select COUNT (comm) from emp;--for all employees the minimum wage select min (sal) from emp;--to ask for the highest wage for all employees select MAX (SAL) from emp;--seeking department Average salary and
Design Mode: Combination Mode
Blog purpose: Use graphs to speak
Auxiliary text description:
1. Call method: Use component. method () in the Client ();
2. Scope of use: Aggregation and combination with the same structure.
Example:
Generate the Condition Statement: when avg (cpu)> 60% or avg (mem)> 70% for 3 min then do scale up. for avg (cpu)> 60%,
2, 4, 68 union all 27 select 3, 1, 91 union all 28 select 3, 2, 47 union all 29 select 3, 3, 88 union all 30 select 3, 4, 56 union all 31 select 4, 2, 88 union all 32 select 4, 3, 90 union all 33 select 4, 4, 93 union all 34 select 5, 1, 46 union all 35 select 5, 3, 78 union all 36 select 5, 4, 53 union all 37 select 6, 1, 35 union all 38 select 6, 2, 68 union all 39 select 6, 4, 71;View Code
03 problem and implementation code
(1) query the student IDs of all students whose scores are higher th
Title:There are N (n=3) root wood, the length of which is a,b,c (a=8.0,b=10.0,c=100.0), divided into the same length of X (x=100) a single copy. The maximum length of a single part.Analysis:N-Wood, etc. is divided into X-parts. The optimal solution is AVG = (a+b+c)/x. In fact, each wood may have a surplus, so that it will not be X-parts. If you don't get x, then push back. COUNT = a/avg + b/
, lastpubtime from Rtc.dbo.PublishedStaticInstance WHERE containernum = 2AND CategoryId = 4) as InstanceWHERECHARINDEX (' aggregatestate ', Data) > 0) as userandavailability on resource.resourceid = PublisherID/*where userathost = ' [email protected] ' collatesql_latin1_general_cp1_ci_as*/ORDER by Userathost, Lastpubtime DESCClick Load, you can preview the status of the user, most of which are offineCreate a doughnut chart and put the status state as the legend, userathost percent as the value,
with is NULL, was not nullselect*From the USERS WHERE user_birthday is null sorts the query result sort on a single column, that is, sort by column, sorted by , sorted by, sort by: query all the score information in the score table numbered 1, and sort by fractional ascending select * FROM SCORES WHERE gno=1 ORDER by score asc/desc Sort multiple columns: Sort by, sort by, prioritize, pay attention to the conditions, such as: Query the score table all information, and according to the game numbe
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.