SQL (Single table queries)

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/19

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

20 Terms

1
New cards

What is the basic form of the SQL SELECT command

SELECT-FROM-WHERE. Specify the columns to be listed after the word SELECT (or asterisk (*) to select all columns). Then specify the table name after the work FROM. Optionally, you can include one or more conditions after the word WHERE.

2
New cards

How are simple conditions written?

Column name, comparison operator, column name or value.

3
New cards

What comparison operators can be used with simple conditions?

=,>,>=,<,<=,<>, or !=

4
New cards

How are compound conditions formed?

By combining simple conditions using the AND, OR, and NOT operators

5
New cards

BETWEEN operator

Indicates a range of values in a condition. Also used to determine whether a value is between two other values without using an AND condition.

6
New cards

How do you use computed columns in SQL commands?

By using arithmetic operators an writing the computation in place of a column name

7
New cards

How do you assign a name to a computed column?

Follow the computation with the word AS and then the name

8
New cards

LIKE operator

Used to check for a value in a character column that is similar to a particular string of characters

9
New cards

Use of (%), ( _ ) wildcards

The percent (%) wildcard represents any collection of characters. The underscore ( _ ) wildcard represents any single character.

10
New cards

IN operator

Used to determine whether a column contains a value in a set of values

11
New cards

Aggregate functions COUNT, SUM, AVG, MAX, and MIN

SQL processes these aggregate functions to calculate values for groups of rows

12
New cards

What command do you use to sort data?

Use an ORDER BY clause

13
New cards

What is a Major Sort Key (or the Primary Sort Key)

The more important column when sorting data on two columns

14
New cards

What is a Minor Sort Key (or the Secondary Sort Key)

The less important column when sorting data on two columns

15
New cards

How do you sort data in descending order?

Follow the sort key with the DESC operator

16
New cards

How do you avoid including duplicate values in a query's result?

To avoid duplicates, precede the column name with the DISTINCT operator

17
New cards

What is a subquery?

When one SQL query is placed inside another, it is called a subquery.

18
New cards

How do you find rows in which a particular column contains a null value?

Use the IS NULL operator in the WHERE clause

19
New cards

How do you group data in a SQL query?

Use a GROUP BY clause

20
New cards

When grouping data in a query, how do you restrict the output to only those groups satisfying some condition?

Use a HAVING clause to restrict the output to certain groups.