Question Description
Help me study for my Computer Science class. I’m stuck and don’t understand.
answer the following questions in the world documentations feel free to ask when it is not clear.
thanks
Unformatted Attachment Preview
Purchase answer to see full attachment

Final Answer

Done thanks and welcome
Chapter 7 An Introduction to Structured Query Language (SQL)
Chapter 7
Lab Assignment
Introduction to Structured Query Language (SQL)
1. In a SQL query, what is the difference between a WHERE clause and a SELECT clause?
In SQL, the WHERE clause is used in eliminating rows before any aggregate function is applied.
WHERE clause cannot contain the Aggregate function for example
SELECT COUNT(SalesOrderID)
FROM Sales.SalesOrderDetail
WHERE UnitPrice < 200
HAVING clause on the other hand helps in filtering records on the basis of the Aggregate functions.
For example the HAVING clause cannot be used without GROUP BY
2. Rewrite the following WHERE clause without the use of the IN special operator.
WHERE V_STATE IN (‘TN’, ‘FL’, ‘GA’)
Now rewrite the given query without use of the IN operator then follows:
where
V_STATE = 'TN' AND V_STATE = 'FL' AND V_STATE='GA'
where
V_STATE LIKE 'TN' AND V_STATE LIKE 'FL' AND V_STATE LIKE 'GA'
3. Explain the difference between an ORDER BY clause and a GROUP BY clause.
An ORDER BY clause has no impact on which rows are returned by the query; it simply sorts those
rows into the specified order. A GROUP BY clause does impact the rows that are returned by the
query. A GROUP BY clause gathers rows into collections that can be acted on by aggregate
functions.
4. Explain why the two following commands produce different results.
SELECT DISTINCT COUNT (V_CODE) FROM PRODUCT;
SELECT COUNT (DISTINCT V_CODE) FROM PRODUCT;
Chapter 7 An Introduction to Structured Query Language (SQL)
This query will first execute COUNT(V_CODE) which will return a single value. Then the DISTINCT
will be applied to that single value. Which means it will display the same value again.
SELECT COUNT (DISTINCT V_CODE)...
