Professional Documents
Culture Documents
Objectives
In this lesson, you will learn to: Use wildcards Use the IS NULL and IS NOT NULL keywords Use the ORDER BY clause Use the TOP keyword Use the DISTINCT keyword Use aggregate functions in queries
2 of 52
3 of 52
4 of 52
Since the newspaper name must have Texas Times, and it could be prefixed or suffixed by anything, the wild card to be used is %
5 of 52
FROM Newspaper
WHERE cNewspaperName LIKE '%Texas Times%'
6 of 52
7 of 52
8 of 52
9 of 52
10 of 52
11 of 52
12 of 52
14 of 52
15 of 52
16 of 52
17 of 52
18 of 52
19 of 52
20 of 52
21 of 52
22 of 52
23 of 52
24 of 52
25 of 52
26 of 52
WHERE search_conditions
[ORDER BY [column_name[,column_name]
27 of 52
29 of 52
30 of 52
31 of 52
32 of 52
33 of 52
34 of 52
35 of 52
Result:
The information is available in the Newspaper table The aggregate function to be used is COUNT
Therefore, the query using the SELECT statement should be: SELECT 'No.Of Newspapers = COUNT(cNewspaperCode) FROM Newspaper
36 of 52
37 of 52
38 of 52
39 of 52
40 of 52
41 of 52
42 of 52
43 of 52
44 of 52
45 of 52
46 of 52
47 of 52
Syntax
SELECT column_list FROM table_name ORDER BY column_name
49 of 52
The LIKE keyword is used to select those rows that match the specified portion of character string
In SQL Server terms, NULL is an unknown value or a value for which data is not available The NULL values can be retrieved from the table using the IS NULL keyword in the WHERE clause
50 of 52
The GROUP BY clause organizes the summarized result set into groups defined in a table with the help of the aggregate functions
The HAVING clause restricts the result set to produce the data based on a condition
51 of 52
52 of 52