Docsity

SQL Exercises with Answers: Data Manipulation and Querying, Exams of Nursing

Toggle sidebar
bg1
1 | P a g e
DSCI 723 EXAM WITH WELL HIGHLIGHTED
AND VERIFIED ANSWERS 100% CORRECT
Which of the statements below best describes the result set returned by this
SELECT statement?
SELECT VendorState, COUNT(*) AS Column2
FROM Vendors
GROUP BY VendorState
HAVING COUNT(*) > 1;
A. the names of the vendors in each state
B. the duplicate vendors from each state
C. the number of vendors in each state
D. the number of vendors in each state having more than one vendor CORRECT
ANSWER>>>> D. the number of vendors in each state having more than one vendor
Which aggregate expression gets the number of unique values in the VendorID column?
A. AVG(VendorID)
B. COUNT(VendorID)
C. SUM(VendorID)
D. COUNT(DISTINCT VendorID) CORRECT ANSWER>>>> D. COUNT(DISTINCT VendorID)
SELECT VendorState, VendorCity, VendorName, COUNT(*) AS InvoiceQty,SUM(InvoiceTotal) AS
InvoiceAvg
FROM Invoices i
JOIN Vendors v
ON i.VendorID = v.VendorID
WHERE VendorState < 'e'
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download SQL Exercises with Answers: Data Manipulation and Querying and more Exams Nursing in PDF only on Docsity!

DSCI 723 EXAM WITH WELL HIGHLIGHTED

AND VERIFIED ANSWERS 100% CORRECT

Which of the statements below best describes the result set returned by this SELECT statement? SELECT VendorState, COUNT() AS Column FROM Vendors GROUP BY VendorState HAVING COUNT() > 1; A. the names of the vendors in each state B. the duplicate vendors from each state C. the number of vendors in each state

D. the number of vendors in each state having more than one vendor CORRECT

ANSWER>>>> D. the number of vendors in each state having more than one vendor

Which aggregate expression gets the number of unique values in the VendorID column? A. AVG(VendorID) B. COUNT(VendorID) C. SUM(VendorID)

D. COUNT(DISTINCT VendorID) CORRECT ANSWER>>>> D. COUNT(DISTINCT VendorID)

SELECT VendorState, VendorCity, VendorName, COUNT(*) AS InvoiceQty,SUM(InvoiceTotal) AS InvoiceAvg FROM Invoices i JOIN Vendors v ON i.VendorID = v.VendorID WHERE VendorState < 'e'

GROUP BY VendorState, VendorCity, VendorName HAVING SUM(InvoiceTotal) > 500 ORDER BY VendorState, VendorCity, VendorName; The GROUPING SETS operator works like the ROLLUP and CUBE operators, but it... A. excludes summary rows B. doesn't add summary rows for specified groups C. allows you to use additional sets of parentheses to create composite groups

D. only works with tables that have an even number of rows CORRECT ANSWER>>>> C.

allows you to use additional sets of parentheses to create composite groups Expressions coded in the WHERE clause... A. can use either aggregate search conditions or non-aggregate search conditions B. can use aggregate search conditions but can't use non-aggregate search conditions C. can use non-aggregate search conditions but can't use aggregate search conditions

D. must refer to columns in the SELECT clause CORRECT ANSWER>>>> C. can use non-

aggregate search conditions but can't use aggregate search conditions A SELECT statement that includes aggregate functions is often called a/an ________________ query. A. action B. compound C. summary

D. complex CORRECT ANSWER>>>> C. summary

Which aggregate expression finds the latest date in the InvoiceDate column? A. SUM(InvoiceDate) B. COUNT(InvoiceDate) C. MAX(InvoiceDate)

D. MIN(InvoiceDate) CORRECT ANSWER>>>> C. MAX(InvoiceDate)

JOIN Top5 ON i.VendorID = Top5.VendorID GROUP BY i.VendorID ORDER BY LargestInvoice DESC; When this query is executed, each row in the result table will show... A. the largest invoice amount related to that row B. the average invoice amount related to that row C. the largest invoice amount related to that row, but only if it's larger than the average for all invoices D. the average invoice amount related to that row, but only if it's larger than the average for all invoices

related to that row CORRECT ANSWER>>>> A. the largest invoice amount related to that

row If coded as follows, what can the subquery return? SELECT (subquery) A. a single value B. a column of one or more values C. a table

D. a subquery can't be coded in this way CORRECT ANSWER>>>> A. a single value

If coded as follows, what can the subquery return? WHERE (subquery) A. a single value B. a column of one or more rows C. a table

D. a subquery can't be coded in this way CORRECT ANSWER>>>> D. a subquery can't be

coded in this way WITH Top5 AS(SELECT TOP 5 VendorID, AVG(InvoiceTotal) AS AvgInvoice

FROM Invoices GROUP BY VendorID ORDER BY AvgInvoice DESC) SELECT i.VendorID, MAX(i.InvoiceTotal) AS LargestInvoice FROM Invoices i JOIN Top5 ON i.VendorID = Top5.VendorID GROUP BY i.VendorID ORDER BY LargestInvoice DESC; In this query, the table named Top5 is used as part of a... A. correlated subquery B. noncorrelated subquery C. correlated table expression

D. join CORRECT ANSWER>>>> D. join

Which operator can you use to test whether any rows are returned by a subquery? A. EXISTS B. NOT EXISTS C. MAX

D. MIN CORRECT ANSWER>>>> A. EXISTS

A subquery is a/an ______________ statement that's coded within another SQL statement. A. SELECT B. FROM C. ORDER BY

D. WHERE CORRECT ANSWER>>>> A. SELECT

If coded as follows, what can the subquery return? WHERE VendorID NOT IN (subquery) A. a single value B. a column of one or more values C. a table

D. a subquery can't be coded in this way CORRECT ANSWER>>>> B. a column of one or

more values All of the following values can be stored in a column that's defined as decimal(6,2), except... A. - 246. B. 0 C. 2479.

D. 32492.05 CORRECT ANSWER>>>> D. 32492.05 because it can only capture 6 total digits,

2 of which may be behind the decimal. If you assign a value with one data type to a column with another data type, SQL Server converts the value to the data type of the column using what? A. explicit conversion B. implicit conversion C. Unicode values

D. scientific notation CORRECT ANSWER>>>> B. implicit conversion

Which string uses the least amount of storage when stored in a column of type varchar(20)? A. 'example' B. 'exam' C. 'ex'

D. they all use the same amount of storage CORRECT ANSWER>>>> C. 'ex'

Which function is typically used to insert control characters into a character string?

A. ASCII

B. CHAR

C. UNICODE

D. STR CORRECT ANSWER>>>> B. CHAR

Which of the following statements is true? A. implicit data type conversion is performed when you mix values of different data types in an expression B. every data type can be implicitly converted to every other data type C. values are always implicitly converted from the data type with higher precedence to the data type with lower precedence D. you can convert a data type implicitly by using either the CAST or the CONVERT function

CORRECT ANSWER>>>> A. implicit data type conversion is performed when you mix values

of different data types in an expression Regarding the char and nchar data types, which of the statements below is false? A. data stored using these data types occupies the same number of bytes regardless of the actual length of the string B. they are typically used to define columns that have a fixed number of characters C. the char(2) data type will always contain two characters

D. char and nchar can automatically resize themselves to accommodate larger strings CORRECT

ANSWER>>>> D. char and nchar can automatically resize themselves to accommodate larger

strings Which data type is only used to store whole numbers? A. int B. decimal C. real

D. string CORRECT ANSWER>>>> A. int

A. ASCII

B. fixed-length string C. Unicode

D. variable-length string CORRECT ANSWER>>>> C. Unicode

Observe the ENROLLMENT AND COURSE database: ENROLLMENT EmpID | EmpName | CourseID 111 | Joe | AMG 222 | Bob | AMG 333 | Lisa | PMG 444 | Sue | AMG COURSE CourseID | CourseName AMG | Anger Management PMG | Project Management What will be the result of the following query? SELECT count(*) FROM enrollment GROUP BY courseid;

  1. number 1
  2. number 3
  3. numbers 3 and 1
  4. number 4

5) numbers 4, 3, and 1 CORRECT ANSWER>>>> 3) numbers 3 and 1

Which of the following statements would be used to populate a table with data?

  1. ALTER TABLE
  2. CREATE TABLE
  3. DROP TABLE
  4. INSERT INTO

5) UPDATE CORRECT ANSWER>>>> 4) INSERT INTO

Which of the following is an invalid SQL keyword?

  1. Select
  2. SE_LECT
  3. selectT
  4. SeLeCt

5) select CORRECT ANSWER>>>> 2) SE_LECT

T/F - UPDATE is an example of a DDL command CORRECT ANSWER>>>> FALSE

DDL commands are CREATE, ALTER, DROP, and TRUNCATE What is the result of the following SQL statement? UPDATE employee SET salary = 50000 WHERE salary < 50000;

  1. The statement sets the salary for each employee to below 50,
  2. The statement sets the salary of each employee to 50,000 and ensures that the salary cannot drop below 50,
  3. The statement increases salary to 50,000 for each employee whose salary is below 50,
  4. The statement sets the salary of each employee to 50,

3) UPDATE SET-TO-NULL

4) UPDATE SET-TO-DEFAULT

5) None of the above CORRECT ANSWER>>>> 3) UPDATE SET-TO-NULL

Which of the following describes the uniqueness data quality characteristic?

  1. The extent to which data correctly reflects the real-world instances it is supposed to depict
  2. The degree to which all the required data is present in the data collection
  3. The characteristic that requires each real-world instance to be represented only once in the data collection
  4. The extent to which the data properly conforms to and matches up with the other data

5) The extent to which the data conforms to its specified format CORRECT ANSWER>>>> 3)

The characteristic that requires each real-world instance to be represented only once in the data collection T/F - Mandating instantaneous entry of all new data is an example of a preventive data quality action.

CORRECT ANSWER>>>> TRUE

Missing date of hire information of an employee indicates which data quality problem?

  1. Accuracy
  2. Uniqueness
  3. Completeness
  4. Consistency

5) Timeliness CORRECT ANSWER>>>> 3) Completeness

Which of the following describes the conformity data quality characteristic?

  1. The extent to which data correctly reflects the real-world instances it is supposed to depict
  2. The degree to which all the required data is present in the data collection
  3. The extent to which the data properly conforms to and matches up with the other data
  4. The extent to which the data conforms to its specified format
  1. The degree to which the data is aligned with the proper time window in its representation of the real-

world CORRECT ANSWER>>>> 4) The extent to which the data conforms to its specified

format Assume that Table B has a foreign key referring to a primary key in Table A. Which of the following options may result in the following: deleting a row in Table A will cause a deletion of a rowin Table B?

  1. DELETE RESTRICT
  2. DELETE CASCADE
  3. DELETE SET-TO-NULL
  4. DELETE SET-TO-DEFAULT

5) None of the above CORRECT ANSWER>>>> 2) DELETE CASCADE

T/F - Misspelled state name in the state field for the address of a customer always indicates the accuracy

data quality problem. CORRECT ANSWER>>>> TRUE

Which of the following statements given to you by a consultant should arouse suspicion?

  1. All the content on the web-site we made for you is stored in the database.
  2. The forms we made for you allow you to enter the data about your customers.
  3. The reports we made for you allow you to enter the data about your customers.
  4. The forms we made for you allow you to view the data about your customers.

5) The reports we made for you allow you to view the data about your customers. CORRECT

ANSWER>>>> 3) The reports we made for you allow you to enter the data about your customers.

T/F - A form can be used to enter data into a database table. CORRECT ANSWER>>>> TRUE

T/F - Every relation without transitive functional dependencies is in 3NF. CORRECT

ANSWER>>>> FALSE

If A --> B is an existing functional dependency, which of the following is an augmented functional dependency?