One: Row to column
Mode: N row to a column of this experiment n take 3
1. Table Building
Sql> CREATE TABLE grade (ID int,name varchar2 (a), subject varchar2 (a), Grade number (3));
2. Insert experimental data
Insert into grade values (1, ' Andy '
Copyright Notice: CSDN is the blog hosting service provider. If the copyright issues involved in this article, csdn do not bear the relevant responsibility, please contact the copyright owner directly with the author of the article to
AVG (average) count (count) max (max) min (minimum) SUM (summation) The syntax for applying a function is: selecte "function name" ("Column name") from "table name1.AVG:Select AVG (Grade) from Table1, return result: Average of Grade column in Table12
--Note: rownum and ROWID only Oracle, other databases are not supportedSELECT * from Scott.dept;--the result of the query is called the ' result set '--rownum a sequence produced in a pseudo-column ' result set ', preceded by a result set, followed
1.WITH ROLLUP: Statistical data is performed on a group basis.Example: First grouping on the name field and then counting on a group basisMysql>SELECT Name,SUM(Singin) AsSingin_count from Employee_tbl GROUP by name with ROLLUP;+--------+-------------
MySQL only provides the union, does not provide the difference set, and the intersection, but we can use the Union to achieve the intersection and the difference, the following is the implementation method:First create two tables:ERROR 1064
Having
Having is used in a select expression to filter records that are already group by statistics. After the group by statistic record, the having will filter the records that match the conditions in the HAVING clause.
The syntax is as follows:
Https://www.2cto.com/database/201710/688377.html1, the role of triggers?A trigger is a special stored procedure that is executed primarily by triggering an event. It can enforce constraints to maintain the integrity and consistency of data, and can
a multiple-table query using the SELECT clause Select field name from Table 1, table 2 ... WHERE table 1. Fields=table 2. Fields and other query conditions select A.id,a.name,a.address,a.date,b.math,b.english,b.chinese from Tb_demo065_tel as B,tb_
1 , duplicate records in the lookup table are judged by a single field (Peopleid).SELECT * from peoplewhere Peopleid in (select Peopleid from People GROUP by Peopleid have count (Peopleid) > 1)Example Two: Select * from TestTable where numeber in
1, in the interview encountered a problem, is to write a table with ID and name two fields, query out the name duplicate all data, now listed below:SELECT * FROM Xi a WHERE (a.username) in (select Username from XI Group by username have count (*) >
In everyday SQL queries, we need to process the data that we want to query, and then query it in the pre-processed data. At this point we need to use the temporary table, pre-processing the data into the temporary table, and then in the temporary
/* 数据如下: name val memo a 2 a2(a的第二个值) a 1 a1--a的第一个值 a 3 a3:a的第三个值 b 1 b1--b的第一个值 b 3 b3:b的第三个值 b 2 b2b2b2b2 b 4 b4b4 b 5 b5b5b5b5b5 */--创建表并插入数据: create table tb(name varchar(10),val int,memo varchar(20))
DatabaseA database (DATABASE,DB) is a collection of organized, shareable data that is stored in a computer for a long period of time. The data in the database is organized, described and stored in a certain mathematical model, with small redundancy,
rowID is the data stored in the database, automatically the encoding for that data, each data has a different encoding, we can quickly determine a column based on rowID , and then manipulate it.This is the database to check the weight, and delete
The distinct (STR) function is used to remove duplicate records, but it is only possible to repeat for a certain field. For example: SELECT DISTINCT (name) from TableName; However, if you want to query the records of other field values, I started
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.