Tags: exists result technology BSP log Apple AAAAA number redAs a Java back-end developer, database knowledge is essential, to the database of the familiarity of the investigation is also on whether the person has a solid basic skills. Especially for junior developers, interviews may not ask the framework for knowledge, but they will never go into database knowledge, and here are some common types of SQL statements that can be helpful both for normal development and for preparing interviews. Bas
| 6000 Develop | Ten | 5200 Personnel | 5 | 3500 Personnel | 2 | 3900 Sales | 3 | 4800 Sales | 1 | Sales | 4 | 4800 (rows)We now want to compare the salary of each employee to the average salary of his department, how should SQL statements be written? Using window functions, the query can be easily implemented:postgres=# SELECT Depname, empno, salary, AVG (salary) over (PARTITION by depname) from Emp
One, group function nestingAs defined in Oracle, group functions can be nested only two layers. In fact, multi-layer nesting has no practical purpose, so Oracle does not provide multi-layered nesting of group functions. However, a single-line function can be nested multiple layers.Two1. Oracle contains the following group functions-avg ([distinct| All]n) return average, ignoring null values-count ({*|[ Distinct| ALL]}EXPR) returns the number of record
= Models. Positiveintegerfield ()View CodeBased on the given model, three examples are introduced first: # total Number of books. >>> Book.objects.count () 2452# Span style= "COLOR: #008000" > Total number of books with publisher=baloneypress >>> Book.objects.filter ( Publisher__name= " baloneypress " ). Count () ( >>> from Django.db.models import avg>>> bookobjects. All () . Aggregate (avg ( ' p
The mean and Mark difference is the most basic thing in statistics. cvavg () is an average data calculation and supports multi-channel usage. The method used is as follows:
Simple cvavg () Implementation# Include # Include # Include IntMain (){Iplimage * image1 = cvloadimage ("grotto.jpg", 1 );Cvscalar scalar1;Scalar1 = cvavg (image1 );
Printf ("blue channel AVG is: %. f/N", scalar1.val [0]);Printf ("Green Channel
annual salary of each person, and sort by column alias in ascending order)Select isnull (sal, 0) * 12 + isnull (comm, 0) annual salary from emp order by annual salary;
20. How to display the highest salary and minimum wage among employeesSelect max (sal) as "max (sal)", min (sal) from emp;
21. How to display the Minimum Wage employee informationSelect * from emp where sal = (select min (sal) from emp );Www.2cto.com22. display the average and total salaries of all employeesSelect
*) double avg (double *, int) Nogil ctypedef str UCT point: Double x double y double distance (point *, point *)For example, we give the sample.h file as follows:#ifndef __sample_h__#define __sample_h__#include Sample.pyx:Cython Package BodyThe program is as follows, the syntax in the Pyx text is consistent with Python, but you can specify the formal parameter type (or not) as in C, which is actually the most basic wrapper
grouped for statistical analysis, so often with aggregation (statistical) function to use The commonly used aggregation (statistics) functions are: COUNT (): Returns the number of non-null values in the row retrieved by the SELECT statement, and if no matching rows are found, COUNT () returns 0,count (*) with a nonzero value SUM (): Counts the total number of data per set, rows with null columns in the table do not participate in the calculation, or null if no matching rows are found
sort by column alias in ascending order)Select isnull (sal, 0) * 12 + isnull (comm, 0) annual salary from emp order by annual salary;20. How to display the highest salary and minimum wage among employeesSelect max (sal) as "max (sal)", min (sal) from emp;21. How to display the Minimum Wage employee informationSelect * from emp where sal = (select min (sal) from emp );Www.jb51.net22. display the average and total salaries of all employeesSelect avg (s
Group function and group statistics, group function statistics
Grouping Functions
Grouping functions commonly used in SQL
Count (): Count
Max (): calculates the maximum value.
Min (): Minimum value
Avg (): calculates the average value.
Sum (): Sum
-- Count the number of people in the emp table select count (*) from emp; -- count the number of people who receive the bonus select count (comm) from emp; -- calculate the minimum wage of all employees
--- Price statistics for all books
Select sum (price) total price, AVG (price) average price, max (price) highest price, min (price) lowest price
From titles
--- Count records of where conditions--- Business-type book price statisticsSelect sum (price) total price, AVG (price) average price, max (price) highest price, min (price) lowest priceFrom titles where type = 'business'
-- Count-- Returns the author
0m4.832sSYS 0m4.113sCopy time is about 28.6s2.2 Test BBCPTime/usr/local/bin/bbcp-4-k-a-r-f-v-p 2-w 9m-s 16-t ' ssh-p 1222-x-a-ofallbacktorsh=no%i-l%u%H/usr/local /BIN/BBCP ' test.tar.gz [email protected]:/tmp/[email protected] ' s password:bbcp:indexing files to be copied ...bbcp:copying 0 files and 0 links in 0 directories.bbcp:appending to/tmp/test.tar.gz at offset 0bbcp:171110 16:32:20 12% done; 135.9 MB/s, Avg 135.9 MB/sbbcp:171110 16:32:22 22% d
(sal,0) *12+isnull (comm,0) annual salary from the EMP order by annual salary;
20. How to show the employee's maximum wage and minimum wage
Select Max (sal) as "Max (sal)", Min (sal) from EMP;
21, how to display the minimum wage of employee information
SELECT * from emp where sal = (select min (sal) from EMP);
Www.jb51.net
22, showing the total wage and salary of all employees
Select AVG (SAL) as "avg (S
Integration of the last semester to learn the accumulation of hope can help beginners!It may be useful in the future!The use of a basic statementOperation based on EMP table1, according to the salary from high to low arrangementSql> Select RowNum as Order, ename,sal2 from (select Ename,sal3 from EMP4 ORDER BY Sal Desc)5 Where rownum6;2, do the embedded diagram from large to small after the first five to find the wrong wordingSql> Select Ename,sal2 from EMP3 where rownum4 ORDER BY Sal Desc;First
from EMP Group by Deptno) temp,emp cwhere e.job = (Selec T job from emp where ename = ' SCOTT ') and e.deptno=d.deptno and E.deptno=temp.deptnoand E.mgr=c.empno and e.ename!= ' SCOTT '; Iii. List of all employees whose salary is more than ' SMITH ' or ' ALLEN ', number, name, department name, leader name, department number, average wage, maximum wage, minimum wage Determine the data table to use: 1, EM P: Determine employee number, employee name, leader name to be displayed accordi
/*The grouping function can no longer have normal columns in the SELECT clause, unless the column gives all the null values in group by to be grouped into a group filter SELECT from WHERE GROUPBY having an by-clause*/--find out the average salary for each jobSELECTJOB,AVG(SAL),MAX(SAL),MIN(SAL) fromEmpGROUP byJOB; SELECT MAX(SAL) fromEMP;SELECTDEPTNO,AVG(SAL) fromEmpGROUP byDEPTNO;--find the average salar
Tags: Oracle having group functionsGrouping functions: Acts on a set of values and returns a value to a set of data;Use of grouping functions:Commonly used grouping functions:AVG (averaging), sum(sum), min(minimum), Max(max), Count(Total), Wm_concat ( Row to column )Example :Select COUNT (Distinct deptno) from EMP;row to column: select deptno Department number , Wm_concat (ename) Department of the employee's name from the EMP Group by DEPTNO;----------------------------------------------------g
D.deptno,d.dname,d.loc,e.empno,e.enameFrom Dept d,emp E where D.deptno=e.deptno (+)(28) To inquire all employees and their department information, including those who do not belong to any department of staff.Select D.deptno,d.dname,d.loc,e.empno,e.enameFrom Dept d,emp E where D.deptno (+) =e.deptno(29) To inquire the names of all employees who work for clerk and their departments.Select E.ename,d.dname from emp e,dept D where e.deptno=d.deptnoand e.job= ' clerk '(30) To inquire the minimum wage
* from emp where hiredate+2=last_day (HireDate); 2. Find employees hired 30 years ago select * from emp where HiredateSelect Ename,sal from emp order by substr (ename,1,1) desc,sal;8. Assuming one months is 30 days, find out the daily wages of all employees, regardless of decimalsSelect Ename,round (SAL/30) daily_sal from EMP;9. Find employees employed in FebruarySELECT * from emp where TO_CHAR (hiredate, ' fmmm ') = ' 2 ';10. List the number of days the employee joins the company (rounded)Sele
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.