SQL Query
SQL Query
13. SQL CREATE DATABASE: The CREATE DATABASE statement is used to create a
database.
CREATE DATABASE DB_Namr
14. SQL CREATE TABLE: The CREATE TABLE statement is used to create a table in a
database.
EX:
CREATE TABLE Persons
(
PersonID int,
LastName varchar(255),
FirstName varchar(255),
Address varchar(255),
City varchar(255)
)
.
15. SQL Constraints: SQL constraints are used to specify rules for the data in a table
16. Functions:
AVG() - Returns the average value
COUNT() - Returns the number of rows
FIRST() - Returns the first value
LAST() - Returns the last value
MAX() - Returns the largest value
MIN() - Returns the smallest value
SUM() - Returns the sum
17. Group BY: The GROUP BY statement is used in conjunction with the aggregate
functions to group the result-set by one or more columns.
19. SUBSTRING Function: This function is used to extract characters from a text field.
SELECT SUBSTRING(SURNAME,1,4) AS CLIENT FROM CLNT
Or
SELECT SUBSTR(SURNAME,1,4) AS CLIENT FROM CLNT
20. LENGTH Function: This function returns the length of the value in a text field.
SELECT LENGTH(CHDRNUM) FROM CHDR
21. ROUND Function: The ROUND() function is used to round a numeric field to the
number of decimals specified.
SELECT ROUND(TOTPRE,0) AS PREMIUM, CHDRNO, RSKTYP, TRANNO FROM RISK
22. NOW Function: The NOW() function returns the current system date and time.
SELECT NOW() FROM CHDR