You are on page 1of 3

2. Explain the DATEADD and DATEDIFF commands.

DateAdd:

Returns a new datetime value based on adding an interval to the specified date

DateDiff:

Returns the number of date and time boundaries crossed between two specified dates

3. Explain the aggregate operators COUNT, SUM, and AVG.

COUNT: Returns the number of rows containing non-null values

SUM: Returns the sum of the values in a specified column

AVG: Returns the average of the values in a specified column

4.

Select *

From EMP_1

Where JOB_code=502

5.

Select *

From EMP_1

Where EMP_lname=Smith

6.

Select *

From EMP_1

Order by EMP_lname DESC

7.

SELECT DISTINCT JOB_CODE

FROM EMP_1

8.

SELECT *

FROM EMP_1

ORDER BY CUS_BALANCE DESC

9.
SELECT AVG(CUS_BALANCE) AS Average Balance

MIN(CUS_BALANCE) AS Minimum Balance

MAX(CUS_BALANCE) AS Maximum Balance

SUM(CUS_BALANCE) AS Total Unpaid Bills

From EMP_1

10.

SELECT COUNT(CUS_CODE)

FROM EMP_1

WHERE CUS_BALANCE>500

11.

SELECT CHAR_DATE

CHAR_NUM

CHAR_DESTINATION

CHAR_DISTANCE

CHAR_HOURS_FLOWN

FROM CHARATER

WHERE AC_NUMBER=2778V

12. List the two mandatory clauses in a SELECT command

Table and Column

13. Explain the logical operator AND, OR, and NOT.

AND

Combine two search conditions where both must be true

OR

Combine two search conditions when one or the other must be true

NOT

Select rows where a search condition is false


14. List the four data manipulation commands, and explain their purpose.

INSERT: The INSERT command in SQL is used to add records to an existing table.

DELETE: The DELETE command with a WHERE clause can be used to remove his record.

UPDATE: The UPDATE command can be used to modify the information contained within a table.

SELECT: The SELECT command is the most commonly used command in SQL.

15. In SQL Server, what are literals?


A literal is a notation for representing a fixed value in source code. Literals can be strings, integers,
decimals and datetime.

You might also like