Select (transact-sql)

SQL Инструкция CREATE VIEW

В SQL представление — это виртуальная таблица, основанная на результирующем наборе инструкции SQL.

Представление содержит строки и столбцы, как и настоящая таблица. Поля в представлении — это поля из одной или нескольких реальных таблиц в базе данных.

Вы можете добавить в представление инструкции SQL функций, WHERE и JOIN и представить данные так, как если бы они поступали из одной таблицы.

Синтаксис CREATE VIEW

CREATE VIEW view_name AS
SELECT column1, column2, …
FROM table_name
WHERE condition;

Примечание: В представлении всегда отображаются актуальные данные!
Компонент database engine воссоздает данные, используя инструкцию SQL представления, каждый раз, когда пользователь запрашивает представление.

SORT operator

The task of the sort operator is to put in order the received input data. The following query will retrieve data from the SalesOrderDetail table and the ORDER BY statement provides that the result set will return in ascending order according to the ModifiedDate column.

1
2
3

SELECTCarrierTrackingNumber

FROMSales.SalesOrderDetail

ORDERBYModifiedDateASC

When we check the query plan after the execution of the query, we will see that the storage engine reads the data by way of the clustered index scan operator. As a second step, the sort operator takes 121.317 rows as input and sorts them in ascending order.

Now, let’s take a new example query. This query will use an enlarging copy of the Adventureworks database and it will sort approximately 453.341 rows.

1
2
3
4
5

SELECTCreditCardApprovalCode,AccountNumber

FROMSales.SalesOrderHeaderEnlarged

WHERE

DueDate>’20150601′

ORDERBYDueDateASC

In the compilation phase of the query plan, the query optimizer calculates the memory requirement of the query based
on the estimated number of rows and row sizes, and this memory requirement is called a memory grant or query work
buffer. For some reasons (outdated statistics, wrong cardinality estimation, parameter sniffing, badly defined data
types) the memory grant might be calculated as wrong.

In the execution plan, we see a warning sign on the sort operator which means that the memory grant is not enough
for the sort operation and the query required more memory to perform the sort operation. In this circumstance,
during the execution of the query, the sort operator uses the tempdb database to meet the memory deficit. When we
analyze the sort operator properties, we can find out more detailed information about the tempdb spill issue.

The sort operator uses 45 MB memory but this memory amount is not enough to perform sorting all rows, for this
reason, sort operator used the tempdb database. During the execution of a query, the memory grant can not be changed
dynamically and insufficient memory grant estimations cause this type of issue.

Tip: Row Mode Memory Grant Feedback
feature in SQL Server 2019 helps to overcome this problem without any code changing. The main idea of this feature
is to adjust the memory grant requirement of a query to use the last execution memory grant information. With the
help of this feature, we can assume that several executions of the query the memory grant must be adjusted. The
below image illustrates memory grant changings after the four execution of the query. In the last execution of the
query, the optimizer has decided to find the proper memory grant amount for this query

At the same time, the following options can consider overcoming the tempdb spill issue:

  • Creating an index that tunes the ORDER BY statement performance
  • Using the MIN_GRANT_PERCENT query option
  • Update the outdated statistics

Syntax and Parameters of SQL ORDER BY

The syntax of the Oracle SQL ORDER BY clause is:

In this clause:

  • column_name is one of the columns in your SELECT clause or in your table that you want to order by.
  • column_position is a number that refers to the position of a column in your SELECT statement.
  • expression is a valid SQL expression that you want to order your results by
  • ASC or DESC can be used to specify the order of the data. ASC is ascending, and DESC is descending. This is optional, and if it is not provided, the default sort order is ASC.
  • NULLS FIRST or NULLS LAST can be used to specify how NULL values are sorted. NULLS FIRST means that NULL values are shown at the top of the list, and NULLS LAST means that NULL values are shown at the bottom of the list. The default treatment if this is not specified is NULLS FIRST if the sort is DESC, or NULLS LAST if the sort is ASC or not specified.

Also, the column that you order by does not need to exist in the SELECT clause. So you don’t need to see the column in your results to use it in the ORDER BY.

Example — Sorting Results in descending order

When sorting your result set in descending order, you use the DESC attribute in your ORDER BY clause. Let’s take a closer look.

In this example, we have a table called suppliers with the following data:

supplier_id supplier_name city state
100 Microsoft Redmond Washington
200 Mountain View California
300 Oracle Redwood City California
400 Kimberly-Clark Irving Texas
500 Tyson Foods Springdale Arkansas
600 SC Johnson Racine Wisconsin
700 Dole Food Company Westlake Village California
800 Flowers Foods Thomasville Georgia
900 Electronic Arts Redwood City California

Enter the following SQL statement:

Try It

SELECT *
FROM suppliers
WHERE supplier_id > 400
ORDER BY supplier_id DESC;

There will be 5 records selected. These are the results that you should see:

supplier_id supplier_name city state
900 Electronic Arts Redwood City California
800 Flowers Foods Thomasville Georgia
700 Dole Food Company Westlake Village California
600 SC Johnson Racine Wisconsin
500 Tyson Foods Springdale Arkansas

SQL Учебник

SQL ГлавнаяSQL ВведениеSQL СинтаксисSQL SELECTSQL SELECT DISTINCTSQL WHERESQL AND, OR, NOTSQL ORDER BYSQL INSERT INTOSQL Значение NullSQL Инструкция UPDATESQL Инструкция DELETESQL SELECT TOPSQL MIN() и MAX()SQL COUNT(), AVG() и …SQL Оператор LIKESQL ПодстановочныйSQL Оператор INSQL Оператор BETWEENSQL ПсевдонимыSQL JOINSQL JOIN ВнутриSQL JOIN СлеваSQL JOIN СправаSQL JOIN ПолноеSQL JOIN СамSQL Оператор UNIONSQL GROUP BYSQL HAVINGSQL Оператор ExistsSQL Операторы Any, AllSQL SELECT INTOSQL INSERT INTO SELECTSQL Инструкция CASESQL Функции NULLSQL ХранимаяSQL Комментарии

Demo Table: Employees

CREATE TABLE Employees (
EmployeeID INT,
EmployeeName VARCHAR(70),
FatherName VARCHAR(70),
City VARCHAR(70),
Country VARCHAR(70),
PostalCode INT,
Salary INT
)

1
2
3
4
5
6
7
8
9

CREATETABLEEmployees(

EmployeeIDINT,

EmployeeNameVARCHAR(70),

FatherNameVARCHAR(70),

CityVARCHAR(70),

CountryVARCHAR(70),

PostalCodeINT,

SalaryINT

)

EmployeeID EmployeeName FatherName City Country PostalCode Salary
101 Leo Jason Thomas sawyer Hong Kong Hong Kong 237645 350000
102 Nathan Miles Asher Kayden Bangkok Thailand 763423 450000
103 Ryan parker Caleb Everett Kuala Lumpur Malaysia 130978 550000
104 Andrew Bryson Theodore Axel New York City USA 116534 450000
105 Christopher Leonardo Joshua Jameson Shenzhen China 121345 760000
106 Jaxon Jose Lincoln Jace Paris France 987688 678000
107 Anthony Xavier Mateo Ezekiel Antalya Turkey 10342 532000
108 Gabriel Roman Julian Evan Istanbul Turkey 881122 883400
109 Grayson Jordan Dylan Santiago Dubai UAE 800907 9567404
110 Jack Adam Luke Austin Rome Italy 876590 7689490
111 John Greyson Owen Dominic Guangzhou China 793456 778690
112 Sebastian Colton Jackson Elias Mecca Saudi Arabia 698711 888534
113 Henry Easton Daniel Jeremiah Brussels Belgium 239067 7785690
114 Michael Nolan Jacob Jonathan Prague Czech Republic 654567 765900
115 Ethan Adrian Alexander Landon Amsterdam Netherlands 112389 9123670
116 Logan Aaron Mason Ezra Ho Chi Minh City Vietnam 390875 5567800
117 Elijah Connor Lucas Eli Orlando USA 412345 6753490
118 Benjamin Hunter Oliver Christian Buenos Aires Argentina 321245 7893451
119 William Josiah James Hudson Mexico City Mexico 213908 8099900
120 Noah Charles Liam Isaiah Johannesburg South Africa 264578 4569956

SQL References

SQL Keywords
ADD
ADD CONSTRAINT
ALTER
ALTER COLUMN
ALTER TABLE
ALL
AND
ANY
AS
ASC
BACKUP DATABASE
BETWEEN
CASE
CHECK
COLUMN
CONSTRAINT
CREATE
CREATE DATABASE
CREATE INDEX
CREATE OR REPLACE VIEW
CREATE TABLE
CREATE PROCEDURE
CREATE UNIQUE INDEX
CREATE VIEW
DATABASE
DEFAULT
DELETE
DESC
DISTINCT
DROP
DROP COLUMN
DROP CONSTRAINT
DROP DATABASE
DROP DEFAULT
DROP INDEX
DROP TABLE
DROP VIEW
EXEC
EXISTS
FOREIGN KEY
FROM
FULL OUTER JOIN
GROUP BY
HAVING
IN
INDEX
INNER JOIN
INSERT INTO
INSERT INTO SELECT
IS NULL
IS NOT NULL
JOIN
LEFT JOIN
LIKE
LIMIT
NOT
NOT NULL
OR
ORDER BY
OUTER JOIN
PRIMARY KEY
PROCEDURE
RIGHT JOIN
ROWNUM
SELECT
SELECT DISTINCT
SELECT INTO
SELECT TOP
SET
TABLE
TOP
TRUNCATE TABLE
UNION
UNION ALL
UNIQUE
UPDATE
VALUES
VIEW
WHERE

MySQL Functions
String Functions
ASCII
CHAR_LENGTH
CHARACTER_LENGTH
CONCAT
CONCAT_WS
FIELD
FIND_IN_SET
FORMAT
INSERT
INSTR
LCASE
LEFT
LENGTH
LOCATE
LOWER
LPAD
LTRIM
MID
POSITION
REPEAT
REPLACE
REVERSE
RIGHT
RPAD
RTRIM
SPACE
STRCMP
SUBSTR
SUBSTRING
SUBSTRING_INDEX
TRIM
UCASE
UPPER

Numeric Functions
ABS
ACOS
ASIN
ATAN
ATAN2
AVG
CEIL
CEILING
COS
COT
COUNT
DEGREES
DIV
EXP
FLOOR
GREATEST
LEAST
LN
LOG
LOG10
LOG2
MAX
MIN
MOD
PI
POW
POWER
RADIANS
RAND
ROUND
SIGN
SIN
SQRT
SUM
TAN
TRUNCATE

Date Functions
ADDDATE
ADDTIME
CURDATE
CURRENT_DATE
CURRENT_TIME
CURRENT_TIMESTAMP
CURTIME
DATE
DATEDIFF
DATE_ADD
DATE_FORMAT
DATE_SUB
DAY
DAYNAME
DAYOFMONTH
DAYOFWEEK
DAYOFYEAR
EXTRACT
FROM_DAYS
HOUR
LAST_DAY
LOCALTIME
LOCALTIMESTAMP
MAKEDATE
MAKETIME
MICROSECOND
MINUTE
MONTH
MONTHNAME
NOW
PERIOD_ADD
PERIOD_DIFF
QUARTER
SECOND
SEC_TO_TIME
STR_TO_DATE
SUBDATE
SUBTIME
SYSDATE
TIME
TIME_FORMAT
TIME_TO_SEC
TIMEDIFF
TIMESTAMP
TO_DAYS
WEEK
WEEKDAY
WEEKOFYEAR
YEAR
YEARWEEK

Advanced Functions
BIN
BINARY
CASE
CAST
COALESCE
CONNECTION_ID
CONV
CONVERT
CURRENT_USER
DATABASE
IF
IFNULL
ISNULL
LAST_INSERT_ID
NULLIF
SESSION_USER
SYSTEM_USER
USER
VERSION

SQL Server Functions
String Functions
ASCII
CHAR
CHARINDEX
CONCAT
Concat with +
CONCAT_WS
DATALENGTH
DIFFERENCE
FORMAT
LEFT
LEN
LOWER
LTRIM
NCHAR
PATINDEX
QUOTENAME
REPLACE
REPLICATE
REVERSE
RIGHT
RTRIM
SOUNDEX
SPACE
STR
STUFF
SUBSTRING
TRANSLATE
TRIM
UNICODE
UPPER

Numeric Functions
ABS
ACOS
ASIN
ATAN
ATN2
AVG
CEILING
COUNT
COS
COT
DEGREES
EXP
FLOOR
LOG
LOG10
MAX
MIN
PI
POWER
RADIANS
RAND
ROUND
SIGN
SIN
SQRT
SQUARE
SUM
TAN

Date Functions
CURRENT_TIMESTAMP
DATEADD
DATEDIFF
DATEFROMPARTS
DATENAME
DATEPART
DAY
GETDATE
GETUTCDATE
ISDATE
MONTH
SYSDATETIME
YEAR

Advanced Functions
CAST
COALESCE
CONVERT
CURRENT_USER
IIF
ISNULL
ISNUMERIC
NULLIF
SESSION_USER
SESSIONPROPERTY
SYSTEM_USER
USER_NAME

MS Access Functions
String Functions
Asc
Chr
Concat with &
CurDir
Format
InStr
InstrRev
LCase
Left
Len
LTrim
Mid
Replace
Right
RTrim
Space
Split
Str
StrComp
StrConv
StrReverse
Trim
UCase

Numeric Functions
Abs
Atn
Avg
Cos
Count
Exp
Fix
Format
Int
Max
Min
Randomize
Rnd
Round
Sgn
Sqr
Sum
Val

Date Functions
Date
DateAdd
DateDiff
DatePart
DateSerial
DateValue
Day
Format
Hour
Minute
Month
MonthName
Now
Second
Time
TimeSerial
TimeValue
Weekday
WeekdayName
Year

Other Functions
CurrentUser
Environ
IsDate
IsNull
IsNumeric

SQL Quick Ref

Introduction to SQL ORDER BY clause

To sort a result set returned by a SELECT statement, you use the  clause. The following query illustrates how to use the  clause in a statement:

The  clause allows you to sort the result set by a column or an expression with a condition that the value in the column or the returned value of the expression must be sortable i.e., the data type of the result must be the character, numeric or date-time.

To sort a result set in ascending order, you use keyword, and in descending order, you use the keyword. If you don’t specify any keyword explicitly, the  clause sorts the result set in ascending order by default.

To sort multiple columns, you just need to specify additional columns in the  clause. You can sort by one column in ascending order and another column in descending order.

Таблица базы данных

База данных чаще всего содержит одну или несколько таблиц.
Каждая таблица идентифицируется по имени (например, «клиенты» или «заказы»).
Таблицы содержат записи (строки) с данными.

В этом уроке мы будем использовать хорошо известный образец базы данных Northwind (входит в MS Access и MS SQL Server).

Ниже приведен выбор из таблицы «клиенты»:

CustomerID CustomerName ContactName Address City PostalCode Country
1 Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin 12209 Germany
2 Ana Trujillo Emparedados y helados Ana Trujillo Avda. de la Constitución 2222 México D.F. 05021 Mexico
3 Antonio Moreno Taquería Antonio Moreno Mataderos 2312 México D.F. 05023 Mexico
4 Around the Horn Thomas Hardy 120 Hanover Sq. London WA1 1DP UK
5 Berglunds snabbköp Christina Berglund Berguvsvägen 8 Luleå S-958 22 Sweden

Приведенная выше таблица содержит пять записей (по одной для каждого клиента)
и семь столбцов (CustomerID, CustomerName, ContactName, Address, City, PostalCode и Country).

Using ASC and DESC Attributes

When sorting a result set using ORDER BY SQL sentence you can use ASC and DESC attributes in one SELECT statement.In this example, let’s use the same table of products as in the previous example.

prod_id prod_name cat_id
1 Pear 50
2 Banana 50
3 Orange 50
4 Apple 50
5 Bread 75
6 Sliced Ham 25
7 Kleenex NULL

Now enter the following SQL statement:

Six records will be selected. Here are the results that you should get.

prod_id prod_name cat_id
5 Bread 75
4 Apple 50
2 Banana 50
3 Orange 50
1 Pear 50
6 Sliced Ham 25

In this example, the records are returned sorted by the cat_id field in descending order and the secondary sorting by the prod_name field in ascending order.

Examples:

All examples will be on this table unless otherwise stated:

id name age salary
1 Justin 23 400
2 Selena 25 500
3 Mila 23 500
4 Tom 30 1000
5 Johnny 27 500
6 Russell 28 1000

Example №1
Let’s get all the records from the table and sort them by age:

The SQL query will select the strings in the following order:

f_id f_name f_age f_salary
1 Justin 23 400
3 Mila 23 500
2 Selena 25 500
5 Johnny 27 500
6 Russell 28 1000
4 Tom 30 1000

Since all records are selected, the WHERE block may not be specified:

You can also specify the sort type explicitly – ASC – the result will not change:

Example №2
Let’s now sort the records by decreasing age:

The SQL query will select the strings in the following order:

f_id f_name f_age f_sal
4 Tom 30 1000
6 Russell 28 1000
5 Johnny 27 500
2 Selena 25 500
1 Justin 23 400
3 Mila 23 500

Example №3
Let’s now sort the records by age and wage at the same time.

The records will be sorted by age first, and those records, where the age is the same (in our case – 23), will be located in the descending wages:

The SQL query will select the strings in the following order:

f_id f_name f_age f_sal
3 Mila 23 500
1 Justin 23 400
2 Selena 25 500
5 Johnny 27 500
6 Russell 28 1000
4 Tom 30 1000

Example №4
Under the same conditions (i.e. first sorting by f_age), let us sort by salary increase.

Now the first and second entries will be swapped so that first the f_sal is lower and then the f_sal is higher:

The SQL query will select the strings in the following order:

f_id f_name f_age f_sal
1 Justin 23 400
3 Mila 23 500
2 Selena 25 500
5 Johnny 27 500
6 Russell 28 1000
4 Tom 30 1000

MySQL ORDER BY examples

We’ll use the table from the sample database for the demonstration.

A) Using MySQL ORDER BY clause to sort the result set by one column example

The following query uses the clause to sort the customers by their last names in ascending order.

Output:

If you want to sort customers by the last name in descending order, you use the  after the column in the clause as shown in the following query:

Ouptut:

B) Using MySQL ORDER BY clause to sort the result set by multiple columns example

If you want to sort the customers by the last name in descending order and then by the first name in ascending order, you specify both   and in these respective columns as follows:

Output:

In this example, the  clause sorts the result set by the last name in descending order first and then sorts the sorted result set by the first name in ascending order to make the final result set.

C) Using MySQL ORDER BY clause to sort a result set by an expression example

See the following table from the sample database.

The following query selects the order line items from the table. It calculates the subtotal for each line item and sorts the result set based on the subtotal.

To make the query more readable, you can assign the expression in the clause a column alias and use that column alias in the clause as shown in the following query:

In this example, we use as the column alias for the expression  and sort the result set by the alias.

Since MySQL evaluates the clause before the clause, you can use the column alias specified in the clause in the clause.

Introduction to Oracle ORDER BY clause

In Oracle, a table stores its rows in unspecified order regardless of the order which rows were inserted into the database. To query rows in either ascending or descending order by a column, you must explicitly instruct Oracle Database that you want to do so.

For example, you may want to list all customers the by their names alphabetically or display all customers in order of lowest to highest credit limits.

To sort data, you add the clause to the statement as follows:

To sort the result set by a column, you list that column after the clause.

Following the column name is a sort order that can be:

  • for sorting in ascending order
  • for sorting in descending order

By default, the clause sorts rows in ascending order whether you specify or not. If you want to sort rows in descending order, you use explicitly.

places NULL values before non-NULL values and puts the NULL values after non-NULL values.

The clause allows you to sort data by multiple columns where each column may have different sort orders.

Note that the clause is always the last clause in a statement.

Example: Sort by ordinal positions of columns

The SQL Server allows you to sort the result set based on the ordinal positions of columns that appear in the select list.

There is the following statement sorts the Employee by EmployeeName and FatherName. But instead of specifying the column names explicitly, furthermore, it will use the ordinal positions of the columns:

SELECT
EmployeeName,
FatherName
FROM
Employees
ORDER BY
1,
2;

1
2
3
4
5
6
7
8

SELECT

EmployeeName,

FatherName
FROM

Employees

ORDERBY

1,

2;

Output:
In this above example, 1 (First) means the column and 2 (Second) means the .
Therefore, Using the ordinal positions of columns in the clause, which is considered a bad programming practice or exercise for a couple of reasons. First, the columns in a table don’t have ordinal positions and need to be referenced by the name. Second, when you modify the select list, you may forget to make the corresponding changes in the SQL ORDER BY clause.

Example

Question 1: Arrange in alphabetical order

SELECT CompanyName, ContactName, City, Country
FROM Supplier
ORDER BY CompanyName

1
2
3

SELECTCompanyName,ContactName,City,Country

FROMSupplier

ORDERBYCompanyName

Supplier
CompanyName
ContactName
City
Country

Demo table

Id CompanyName ContactName City Country
121 Amdocs Pvt. Ltd Cheryl Saylor Delhi India
131 Ascon Group Dolly Ben New Delhi India
101 Lalit Pvt.Ltd Nitin Shukla Lucknow India
231 Singsymsis Pvt.Ltd Aditya Shukla Kanpur India

Question 2: SQL Case statement For Order By clause with Desc/Asc sort

SELECT
*
FROM
TableName
WHERE
ORDER BY
CASE @OrderByColumn WHEN 1 THEN Forename END DESC, Date,
CASE @OrderByColumn WHEN 2 THEN Surname END ASC

1
2
3
4
5
6
7
8

SELECT
    *
FROM

TableName

WHERE

ORDER BY

CASE@OrderByColumn WHEN1THENForename ENDDESC,Date,

CASE@OrderByColumn WHEN2THENSurname ENDASC

Resource

Conclusion

In this article, you have learned how to use the SQL ORDER BY clause to sort a result set by columns in descending or ascending order and with the different types of ORDER BY Clause example. I hope you will enjoy it!

MySQL ORDER BY Descending

To sort data in Descending order, use Order By statement followed by the DESC keyword. The following are the list of ways we can sort data in Descending order.

For example, If you are searching for shoes on Amazon. If you type shoe in the search bar, it displays shoes by Rating. It means, Shoes are sorted as per the Rating. Technically,

MySQL Sort in Descending Order Example

In this MySQL Order By Desc example, we are going to sort customer’s data in Descending Order using the Sales column.

From the above screenshot, you can see data sorted by Sales in Descending order.

MySQL Order By Multiple Columns in Descending Order

In this order by DESC example, we are sorting the Data using multiple columns. First, data sorted by Education in Descending Order and then sorted by Yearly Income in Descending Order.

Sort in Descending Order using Alias Column

In this MySQL Order By Desc example, We are going to sort the table Data in Descending Order using the Alias Column Name.

We added 12500 to each yearly income column and used Alias to assign a New Income name. Next, we used the Alias name in the Order By clause. It means, Data sort by New Income in Descending Order.

SQL Учебник

SQL ГлавнаяSQL ВведениеSQL СинтаксисSQL SELECTSQL SELECT DISTINCTSQL WHERESQL AND, OR, NOTSQL ORDER BYSQL INSERT INTOSQL Значение NullSQL Инструкция UPDATESQL Инструкция DELETESQL SELECT TOPSQL MIN() и MAX()SQL COUNT(), AVG() и …SQL Оператор LIKESQL ПодстановочныйSQL Оператор INSQL Оператор BETWEENSQL ПсевдонимыSQL JOINSQL JOIN ВнутриSQL JOIN СлеваSQL JOIN СправаSQL JOIN ПолноеSQL JOIN СамSQL Оператор UNIONSQL GROUP BYSQL HAVINGSQL Оператор ExistsSQL Операторы Any, AllSQL SELECT INTOSQL INSERT INTO SELECTSQL Инструкция CASESQL Функции NULLSQL ХранимаяSQL Комментарии

SQL Учебник

SQL ГлавнаяSQL ВведениеSQL СинтаксисSQL SELECTSQL SELECT DISTINCTSQL WHERESQL AND, OR, NOTSQL ORDER BYSQL INSERT INTOSQL Значение NullSQL Инструкция UPDATESQL Инструкция DELETESQL SELECT TOPSQL MIN() и MAX()SQL COUNT(), AVG() и …SQL Оператор LIKESQL ПодстановочныйSQL Оператор INSQL Оператор BETWEENSQL ПсевдонимыSQL JOINSQL JOIN ВнутриSQL JOIN СлеваSQL JOIN СправаSQL JOIN ПолноеSQL JOIN СамSQL Оператор UNIONSQL GROUP BYSQL HAVINGSQL Оператор ExistsSQL Операторы Any, AllSQL SELECT INTOSQL INSERT INTO SELECTSQL Инструкция CASESQL Функции NULLSQL ХранимаяSQL Комментарии

SQL Справочник

SQL Ключевые слова
ADD
ADD CONSTRAINT
ALTER
ALTER COLUMN
ALTER TABLE
ALL
AND
ANY
AS
ASC
BACKUP DATABASE
BETWEEN
CASE
CHECK
COLUMN
CONSTRAINT
CREATE
CREATE DATABASE
CREATE INDEX
CREATE OR REPLACE VIEW
CREATE TABLE
CREATE PROCEDURE
CREATE UNIQUE INDEX
CREATE VIEW
DATABASE
DEFAULT
DELETE
DESC
DISTINCT
DROP
DROP COLUMN
DROP CONSTRAINT
DROP DATABASE
DROP DEFAULT
DROP INDEX
DROP TABLE
DROP VIEW
EXEC
EXISTS
FOREIGN KEY
FROM
FULL OUTER JOIN
GROUP BY
HAVING
IN
INDEX
INNER JOIN
INSERT INTO
INSERT INTO SELECT
IS NULL
IS NOT NULL
JOIN
LEFT JOIN
LIKE
LIMIT
NOT
NOT NULL
OR
ORDER BY
OUTER JOIN
PRIMARY KEY
PROCEDURE
RIGHT JOIN
ROWNUM
SELECT
SELECT DISTINCT
SELECT INTO
SELECT TOP
SET
TABLE
TOP
TRUNCATE TABLE
UNION
UNION ALL
UNIQUE
UPDATE
VALUES
VIEW
WHERE

MySQL Функции
Функции строк
ASCII
CHAR_LENGTH
CHARACTER_LENGTH
CONCAT
CONCAT_WS
FIELD
FIND_IN_SET
FORMAT
INSERT
INSTR
LCASE
LEFT
LENGTH
LOCATE
LOWER
LPAD
LTRIM
MID
POSITION
REPEAT
REPLACE
REVERSE
RIGHT
RPAD
RTRIM
SPACE
STRCMP
SUBSTR
SUBSTRING
SUBSTRING_INDEX
TRIM
UCASE
UPPER
Функции чисел
ABS
ACOS
ASIN
ATAN
ATAN2
AVG
CEIL
CEILING
COS
COT
COUNT
DEGREES
DIV
EXP
FLOOR
GREATEST
LEAST
LN
LOG
LOG10
LOG2
MAX
MIN
MOD
PI
POW
POWER
RADIANS
RAND
ROUND
SIGN
SIN
SQRT
SUM
TAN
TRUNCATE
Функции дат
ADDDATE
ADDTIME
CURDATE
CURRENT_DATE
CURRENT_TIME
CURRENT_TIMESTAMP
CURTIME
DATE
DATEDIFF
DATE_ADD
DATE_FORMAT
DATE_SUB
DAY
DAYNAME
DAYOFMONTH
DAYOFWEEK
DAYOFYEAR
EXTRACT
FROM_DAYS
HOUR
LAST_DAY
LOCALTIME
LOCALTIMESTAMP
MAKEDATE
MAKETIME
MICROSECOND
MINUTE
MONTH
MONTHNAME
NOW
PERIOD_ADD
PERIOD_DIFF
QUARTER
SECOND
SEC_TO_TIME
STR_TO_DATE
SUBDATE
SUBTIME
SYSDATE
TIME
TIME_FORMAT
TIME_TO_SEC
TIMEDIFF
TIMESTAMP
TO_DAYS
WEEK
WEEKDAY
WEEKOFYEAR
YEAR
YEARWEEK
Функции расширений
BIN
BINARY
CASE
CAST
COALESCE
CONNECTION_ID
CONV
CONVERT
CURRENT_USER
DATABASE
IF
IFNULL
ISNULL
LAST_INSERT_ID
NULLIF
SESSION_USER
SYSTEM_USER
USER
VERSION

SQL Server функции
Функции строк
ASCII
CHAR
CHARINDEX
CONCAT
Concat with +
CONCAT_WS
DATALENGTH
DIFFERENCE
FORMAT
LEFT
LEN
LOWER
LTRIM
NCHAR
PATINDEX
QUOTENAME
REPLACE
REPLICATE
REVERSE
RIGHT
RTRIM
SOUNDEX
SPACE
STR
STUFF
SUBSTRING
TRANSLATE
TRIM
UNICODE
UPPER
Функции чисел
ABS
ACOS
ASIN
ATAN
ATN2
AVG
CEILING
COUNT
COS
COT
DEGREES
EXP
FLOOR
LOG
LOG10
MAX
MIN
PI
POWER
RADIANS
RAND
ROUND
SIGN
SIN
SQRT
SQUARE
SUM
TAN
Функции дат
CURRENT_TIMESTAMP
DATEADD
DATEDIFF
DATEFROMPARTS
DATENAME
DATEPART
DAY
GETDATE
GETUTCDATE
ISDATE
MONTH
SYSDATETIME
YEAR
Функции расширений
CAST
COALESCE
CONVERT
CURRENT_USER
IIF
ISNULL
ISNUMERIC
NULLIF
SESSION_USER
SESSIONPROPERTY
SYSTEM_USER
USER_NAME

MS Access функции
Функции строк
Asc
Chr
Concat with &
CurDir
Format
InStr
InstrRev
LCase
Left
Len
LTrim
Mid
Replace
Right
RTrim
Space
Split
Str
StrComp
StrConv
StrReverse
Trim
UCase
Функции чисел
Abs
Atn
Avg
Cos
Count
Exp
Fix
Format
Int
Max
Min
Randomize
Rnd
Round
Sgn
Sqr
Sum
Val
Функции дат
Date
DateAdd
DateDiff
DatePart
DateSerial
DateValue
Day
Format
Hour
Minute
Month
MonthName
Now
Second
Time
TimeSerial
TimeValue
Weekday
WeekdayName
Year
Другие функции
CurrentUser
Environ
IsDate
IsNull
IsNumeric

SQL ОператорыSQL Типы данныхSQL Краткий справочник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

Adblock
detector