The last time I took a note, I learned how to query multiple tables. This time I took a note to learn about grouping functions in Oracle.
First, let's take a look at what group functions are:
Group function: acts on a group of data and returns a value for a group of data.
Type of group functions in SQL:
COUNT (): calculates the number of all records.
MAX (): calculate the maximum value in a group of data.
MIN (): calculates the minimum value.
AVG
query.
The following conditions can be met:
A) each event object triggers a query and only processes the current object.
select * from OrderEvent
This EPL statement will give the event to the listener (mentioned later) after each orderevent object arrives for processing. However, this method is rare and of little significance.
B). Window processing mode:
EPL's biggest feature is this window processing mode, which has two kinds of Windows: Time Window and length window.
Time Window: If you want
Find out the sum of the monthly payroll expenses of the company-- find out the sum of the monthly payroll expenses of the company SELECT SUM from EMP;Check out the company's maximum wage, minimum wage and average wage-- Check out the company's maximum wage, minimum wage and average wage SELECT MAX (SAL),MIN(sal),ROUND(AVG(SAL),2 from EMP;Date of employment of the company's earliest employment and latest employment-- date of employment of the company'
practical application, it is often necessary to perform complex data statistics, often need to display multiple tables of data;group function Max,min,avg,sum,count. max (), Min () Max minhow 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) "Maximum annual wage", Min (SAL*13+NVL (comm,0
Tags: varchar sort brackets Order student ACL order by meaning execution planXi. Sub-query1. Sub-query OverviewReasons to learn the subqueryExample: Querying employee information with a higher salary than ScottIdea: 1, Scott's salarySelect Sal from emp where ename= ' SCOTT ';2, 3000 higher than the staff informationSELECT * FROM EMP where sal>3000;Sub-query mode:SELECT * from emp where sal> (select Sal from emp where ename= ' SCOTT '); 2, the use of sub-query10 Questions to note for sub-queries(
uppercase JSql>select * from EMP where (sal>500 or job= ' MANAGER ') and ename like ' j% ';14. Using the ORDER BY clauseExample: How to display employee information in the order of low to high wagesSql>select * from emp order by Sal;Example: Ascending by Part number and employee's salary descending orderSql>select * from emp ORDER BY deptno,sal Desc;15. Sorting using the alias of the columnSql>select ename,sal*12 "annual salary" from the EMP Order by "annual salary" DESC;Note: Aliases need to b
statement. We'll learn about distinct keywords, which can trigger some very useful optional features.
Some of the most commonly used clauses, keywords, and functions are summarized below. Then I will give an example of each part.
Order by– The clause that returns the result according to the specified column
distinct– only keywords that return only the only rows within the result set
COUNT--A function that returns the number of data rows in a matching query
where Classdesc is NULL
--3.60 class information for class description not empty
SELECT * from ClassInfo where classdesc are not NULL
--3.61 statistics of all scores average
Select AVG (studscore) from Studscoreinfo
--3.62 statistics number is "20050319001" Student achievement average score
Select AVG (studscore) from studscoreinfo where Studno = ' 20050319001 '
--3.63 statistics number is "20050319001" st
index instead of to the data page itself. To overcome the negative impact of data chunking, it is time-consuming to refactor the table's index, so it can only be done when needed. DBCC SHOWCONTIG can be used to determine whether the index of the table needs to be refactored. 2. DBCC showcontig usage The following are examples of how DBCC SHOWCONTIG and DBCC REDBINDEX are used. Take the Employee data table in the application as an example, in SQL Server Query Analyzer input command: Use datab
Tags: core ble aggregate function time left JOIN direct average reverse BSPA summary and grouped data Query statement---> Result set (multiple data)---> Aggregation function----> single row Records 1. Commonly used aggregation functions: SUM () Number sums all non-null values in the specified column AVG () number averages all non-null values in the specified column Min () number, character, DateTime returns the smallest number in the specified column,
cluster index instead of to the data page itself. To overcome the negative impact of data chunking, it is time-consuming to refactor the table's index, so it can only be done when needed. DBCC SHOWCONTIG can be used to determine whether the index of the table needs to be refactored. 2. DBCC showcontig usage The following are examples of how DBCC SHOWCONTIG and DBCC REDBINDEX are used. Take the Employee data table in the application as an example, in SQL Server Query Analyzer input command: U
Tags: post arrangement greater than TNO NES tin join MYS NULL--Seventh Chapter--1, check the earliest and latest date of entry dateSelect min (hiredate), Max (HireDate)From EMP--2. Check the average salary of all employees starting with sales, minimum wage, most-high wages, wages andSelect AVG (sal), Min (Sal), Max (SAL), sum (SAL)From EMPWhere job like ' sales% '--3, Query department 30 how many employeesSelect COUNT (*)From EMPwhere deptno = ' 30 '-
636.3 1183 6046Waiting: 342 1351 636.2 1183Total: 345 1354 636.8 1186
Percentage of the requests served within a certain time (MS)50% 118566% 133375% 146080% 156490% 183595% 235798% 324899% 5205100% 6049 (longest request)
[Jmeter]
Use jemeter with the same configuration (the number of threads is 10, the ramp time is 1 second, And the timeout threshold is 3000 ms)
The running result is as follows:Creating summariser Created the tree successfully using music_api_uid.jmxStarting the test @ Thu Nov
;Select * From t_ SC;SelectSc1.s _ id from t_ SC SC1, t_ SC SC2 where sc1.s _ id = sc2.s _ id and sc1.c _ id ='001' and sc2.c _ id = '002' and sc1.score> sc2.score;-- 2. query the student ID and average score of students whose average score is greater than 60;Select s_id, AVG (score) average score from t_ SC group by s_id having AVG (score)> 60;-- 3 query the student ID, name, number of course selections, a
performed:read:1401582write:500563other:200225total:2102370transactions:100112 (3446.37 per sec.)Deadlocks:1 (0.03 per sec.)Read/write requests:1902145 (65481.66 per sec.)Other operations:200225 (6892.78 per sec.)Test Execution Summary:Total time:29.0485sTotal number of events:100112Total time taken by event execution:2898.7554Per-request Statistics:Min:3.52msAvg:28.96msMax:187.11msApprox. Percentile:46.05msThreads Fairness:Events (Avg/stddev): 1001.
Heard that the project inside aggregation use more, then specifically for this a lot of practice.
The basic operations include:
• $project-You can extract fields from subdocuments, and you can rename fields
• $match-the ability to find
• $limit-accepts a number n, returning the first n documents in the result set.
• $skip-accepts a number n, discarding the first n documents in the result set. Low efficiency, still traversing the top n documents.
• $unwind-You can divide a document that con
treated as a comment. Similar to remark.
Set pause: Causes the screen to appear paused between pages.
Save: Saves the SQL query you are building to a selected file.
Host: Sends commands to the main operating system.
Start or @: tells Sqlplus to execute instructions that have been stored in the file.
Edit: Allows you to quickly leave Sqlplus and enter the editor you choose.
Define_editor: Tell Sqlplus the name of the editor you chose.
Exit or quit: terminates Sqlplus.
A simple example of a repor
Tags: _id log duplicate null BSP ORDER by ACL numeric colorAVG (average) and SUM (total) functions
You can use the AVG and SUM functions with numeric data .
AVG group function ignores null values
-- using the NVL function in group functions -- averaging sum (expr) / Count (NVL (expr,0))MIN (minimum) and Max (max) functions
You can use the MIN and MAX functions for data of any data
ename,sal*12" annual salary "from EMP order by "Annual Salary" (ASC); sql> Select Ename, (SAL+NVL (comm,0)) *12 as " annual salary "from emp order BY" annual salary "; Data grouping (max , Min , Avg , Sum , Count ) Sql>select Max (sal), Min (sal) from EMP; sql>select ename,sal from emp where sal= (select Max (SAL) from EMP); subquery, combined query sql> SELECT * from emp where sal> (select AVG (SAL) from
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.