1. Describe the Basic Form of the SQL SELECT Command
Total Page:16
File Type:pdf, Size:1020Kb
COP2700 – Data Structures (SQL) Pop Quiz – Chapter 4 – Single Table Selects
Names: ______1. Describe the basic form of the SQL SELECT command. SELECT (columns, expressions, constants or *) FROM (Tables or Views) JOIN (Join clauses) WHERE (Conditional Statements) GROUP BY (columns, expressions, constants) HAVING (Conditional Statements) ORDER BY (columns, expressions, constants)
2. How do you form a compound condition? Give an example. By connecting two or more conditional statements with a conjunction… WHERE Author_Num = 123 AND City = ‘Miami’
3. In SQL, what operator do you use to determine whether a value is between two other values without using an AND condition? BETWEEN
4. How do you use a computed column in SQL? How do you name the computed column? A computed column is like any other column and can be used in the same way. To name a computer column, you would use the AS directive. SELECT On_Hand * Price AS On_Hand_Total FROM Part Just as an aside, the AS is really not needed, but makes things more readable
5. How do you determine whether a column contains one of a particular set of values without using an OR condition? With the “IN” directive
6. How do you sort data in descending order? ORDER BY column_name DESC
7. What are the SQL aggregate functions? Count(), SUM(), AVG(), MIN() and MAX()
8. How do you avoid including duplicate values in a query’s results? Use the Distinct Adjective
9. What is a subquery? A subquery is a query within a query that is done first. If it is a Scalar Select (which returns one row and one column), you can use it in a normal conditional statement. If it returns a table with a single column, it can be used with the IN expression.
More Questions 1 On Other Side COP2700 – Data Structures (SQL) Pop Quiz – Chapter 4 – Single Table Selects
Names: ______
10. How do you group data in an SQL query? By using the GROUP BY directive
11. How do you find rows in which a particular column contains a null value? By using the conditional IS NULL SELECT * FROM Transcript WHERE Grade IS NULL
12. The Result Set from a Select Clause is a what? The Result Set from a Select Clause returns a Table
More Questions 2 On Other Side