1-10 câu SQL
10 Questions
16 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

  1. (0.150 Point) What will be returned when the following SQL statement is executed? Select driver_no, count(*) as num_deliveries From deliveries Where state= 'MA' Group by driver_no;

  • A. A listing of all drivers who made deliveries to state 'MA', sorted by driver number
  • B. A listing of each driver who made deliveries to state = 'MA' as well as the number of deliveries that each driver has made to that state (correct)
  • C. A count of all of the deliveries made to state MA' by all drivers
  • D. An error message will be generated
    1. (0.150 Point) What will be returned when the following SQL query is executed? Select driver_no, count() as num_deliveries From deliveries Group by driver_no Having count() > 2;

  • A. A listing of all drivers who made more than 2 deliveries as well as a count of the number of deliveries (correct)
  • B. A listing of all drivers
  • C. A listing of the number of deliveries greater than 2
  • D. A listing of all drivers who made more than 2 deliveries
    1. (0.150 Point) The following code is an example of a: SELECT CustomerName, CustomerAddress, CustomerCity, CustomerState, Customer PostalCode FROM Customer_T WHERE Customer_T.CustomerID = (SELECT Order_T.CustomerID FROM Order_T WHERE OrderID = 1008);

  • A. Correlated subquery
  • B. JOIN.
  • C. Subquery. (correct)
  • D. FULL OUTER JOIN.
    1. (0.150 Point) Consider the following schema: SUPPLIERS(SupplierID, SupplierName, Address) Which SQL statement is used to grant ALL privileges on the SUPPLIERS in the schema to the user 'Manager'?

    <p>B. GRANT ALL ON SUPPLIERS TO Manager</p> Signup and view all the answers

    1. (0.150 Point) What does the following SQL statement do? Delete from Customer_T where state = 'HI';

    <p>A. Deletes all records from customer_t where the state is equal to HI</p> Signup and view all the answers

    1. (0.150 Point) An ACID transaction is one that is:

    <p>D. Durable.E. All of the above</p> Signup and view all the answers

    1. (0.150 Point) Write a SELECT query to list the employees whose salary is greater than 1000.

    <p>B. SELECT ename, sal FROm emp WHERE sal &gt; 1000</p> Signup and view all the answers

    1. (0.150 Point) A.............. interpreted as a special kind of stored procedure that is executed whenever an action, such as data modification, takes place

    <p>A Trigger</p> Signup and view all the answers

    1. (0.150 Point) Which of the below SELECT statement is used to select all columns of EMP table?

    <p>C. SELECT FROM emp</p> Signup and view all the answers

    1. (0.150 Point) What is a clustered index?

    <p>B. in a clustered index, the data is physically sorted and only one clustered index can be created per table</p> Signup and view all the answers

    Study Notes

    SQL Queries and Data Manipulation

    • The SQL statement Select driver_no, count(*) as num_deliveries From deliveries Where state= 'MA' Group by driver_no; returns the driver number and the total number of deliveries made in the state of MA.

    • The SQL statement Select driver_no, count(*) as num_deliveries From deliveries Group by driver_no Having count(*) > 2; returns the driver number and the total number of deliveries made by each driver, only for drivers who have made more than 2 deliveries.

    • The code snippet provided is a nested query, specifically a correlated subquery. It retrieves information from the Customer_T table based on a matching CustomerID in the Order_T table, where the OrderID is equal to 1008.

    • The SQL statement GRANT ALL PRIVILEGES ON SUPPLIERS TO Manager; is used to grant all privileges on the SUPPLIERS table to the user Manager.

    • The SQL statement Delete from Customer_T where state = 'HI'; deletes all rows from the Customer_T table where the state value is 'HI'.

    • An ACID Transaction is one that is:

      • Atomic: the entire Transaction completes or fails as a whole.
      • Consistent: The transaction always moves the database from one valid state to another valid state.
      • Isolated: Concurrent transactions do not interfere with each other and are not affected by each other.
      • Durable: Once completed, the changes made by a Transaction are permanent and survive system crashes.
    • The SQL statement SELECT * FROM Employees WHERE Salary > 1000; lists the employees whose salary is greater than 1000.

    • A Trigger is a special kind of stored procedure that is executed automatically whenever an action, such as data modification, takes place.

    • The SQL statement SELECT * FROM EMP; is used to select all columns of the EMP table.

    • A clustered index is a special type of index that determines the physical order of the data in a table. It can be used for faster data retrieval, but only one clustered index can be created per table, as the data itself is stored in the index.

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Description

    This quiz tests your understanding of SQL group functions and aggregate queries. Analyze the provided SQL statement to determine what output will be generated when executed. It's a great way to strengthen your SQL skills, especially in querying delivery data.

    More Like This

    Use Quizgecko on...
    Browser
    Browser