SQL Conventions and Capabilities
48 Questions
0 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

Which salesperson has the highest sales amount?

  • Mary Jones
  • Bill Adams
  • Sam Clark
  • Sue Smith (correct)
  • What is the difference between Bob Smith's sales and quota?

  • No difference
  • $57,406.00 under quota (correct)
  • $42,594.00 over quota
  • $57,406.00 over quota
  • Which salesperson met their quota?

  • Bob Smith
  • Paul Cruz
  • Dan Roberts (correct)
  • Nancy Angelli
  • What is the total sales made by salespeople who are under quota?

    <p>$186,042.00</p> Signup and view all the answers

    Which of the following sales representatives has a null quota?

    <p>Tom Snyder</p> Signup and view all the answers

    Who has the greatest positive difference between sales and quota?

    <p>Sue Smith</p> Signup and view all the answers

    How much over quota is Larry Fitch?

    <p>$11,865.00</p> Signup and view all the answers

    Which salesperson has sales of $299,912.00?

    <p>Sam Clark</p> Signup and view all the answers

    What is the primary purpose of SQL: The Complete Reference?

    <p>To provide comprehensive coverage of SQL standards and functions</p> Signup and view all the answers

    How are SQL language elements represented in this book?

    <p>In uppercase monospace font</p> Signup and view all the answers

    Which SQL dialects are commonly discussed in SQL: The Complete Reference?

    <p>All dialects conforming to ANSI/ISO standards and popular DBMS products</p> Signup and view all the answers

    What kind of audience is SQL: The Complete Reference targeted towards?

    <p>A general audience including students and managers</p> Signup and view all the answers

    How should readers handle dialect differences in SQL statements?

    <p>Modify the SQL statements as needed for their specific DBMS</p> Signup and view all the answers

    What does a vertical ellipsis (...) indicate in SQL examples?

    <p>Truncation of long query results after a few rows</p> Signup and view all the answers

    How does SQL: The Complete Reference approach programming language conventions?

    <p>It follows normal case conventions consistent with each language</p> Signup and view all the answers

    What is a significant feature of the SQL statements provided in the book?

    <p>They come with query results mimicking an interactive session</p> Signup and view all the answers

    What SQL command is used to retrieve the average amount of all orders?

    <p>SELECT AVG(AMOUNT) FROM ORDERS</p> Signup and view all the answers

    What is the purpose of the string concatenation operator in DB2?

    <p>To combine multiple strings into one</p> Signup and view all the answers

    Which of the following SQL commands can be used to group orders by customer number?

    <p>SELECT CUST, SUM(AMOUNT) FROM ORDERS GROUP BY CUST</p> Signup and view all the answers

    Which SQL function would you use to get the month from a DATE value in DB2?

    <p>MONTH()</p> Signup and view all the answers

    What is the result of the query 'SELECT SALES - QUOTA FROM SALESREPS WHERE SALES < QUOTA' when executed?

    <p>It displays the difference between sales and quota for salespersons below their quotas.</p> Signup and view all the answers

    Which SQL query correctly retrieves the names of all salespeople hired in 1988?

    <p>SELECT NAME FROM SALESREPS WHERE YEAR(HIRE_DATE) = 1988</p> Signup and view all the answers

    In the context of SQL, what does the 'ORDER BY' clause do?

    <p>It changes the sequence in which records are displayed.</p> Signup and view all the answers

    How would you write a SQL command to find customers with orders greater than $25,000?

    <p>SELECT * FROM ORDERS WHERE AMOUNT &gt; 25000 ORDER BY CUST</p> Signup and view all the answers

    What type of operations does DB2 support for DATE, TIME, and TIMESTAMP data types?

    <p>Both addition and subtraction</p> Signup and view all the answers

    What is the result of using the TO_CHAR() function in Oracle with a DATE input?

    <p>It formats the date into a specified string format</p> Signup and view all the answers

    Which SQL command summarizes the total order amount for each customer?

    <p>SELECT CUST, SUM(AMOUNT) FROM ORDERS GROUP BY CUST</p> Signup and view all the answers

    How many built-in functions are incorporated by the SQL2 standard from various SQL implementations?

    <p>About two dozen</p> Signup and view all the answers

    What does the result $8,256.37 represent in the average order query?

    <p>The average size of an order across all customers.</p> Signup and view all the answers

    Which built-in function is NOT typically available in DB2 for data type conversion?

    <p>SUBSTR()</p> Signup and view all the answers

    In an SQL query, what does the term 'CUST' represent?

    <p>The customer identification number.</p> Signup and view all the answers

    In DB2, what SQL command would you use to extract the year portion from a TIMESTAMP?

    <p>YEAR(TIMESTAMP)</p> Signup and view all the answers

    What is the primary function of the SELECT statement in SQL?

    <p>To retrieve data from a database</p> Signup and view all the answers

    Which of the following best describes the complexity of SQL queries?

    <p>SQL queries vary in complexity, allowing for simple to complex expressions.</p> Signup and view all the answers

    How can NULL values be beneficial in SQL?

    <p>They provide a systematic way to handle missing or inapplicable data.</p> Signup and view all the answers

    In the provided SQL query, SELECT CITY, TARGET, SALES FROM OFFICES WHERE REGION = 'Eastern', what is being filtered?

    <p>Offices belonging to a specific region, 'Eastern'.</p> Signup and view all the answers

    What type of data can SQL-based databases typically store?

    <p>Text, integers, decimals, and other vendor-specific types</p> Signup and view all the answers

    Which of the following SQL queries would retrieve sales offices where sales exceed targets?

    <p>SELECT CITY, TARGET, SALES FROM OFFICES WHERE SALES &gt; TARGET</p> Signup and view all the answers

    What is the result of the query SELECT CITY, TARGET, SALES FROM OFFICES?

    <p>All sales offices with no filtering</p> Signup and view all the answers

    Why can variations in data types complicate SQL statement portability?

    <p>Different systems may have unique vendor-specific data types.</p> Signup and view all the answers

    What is the syntax to insert a new office into the database with the provided details?

    <p>INSERT INTO OFFICES (CITY, REGION, TARGET, SALES, OFFICE) VALUES ('Dallas', 'Western', 275000.00, 0.00, 23)</p> Signup and view all the answers

    Which SQL statement is correctly formatted to delete a customer from the database?

    <p>DELETE FROM CUSTOMERS WHERE COMPANY = 'Acme Industries'</p> Signup and view all the answers

    What does the DELETE statement for terminating salespeople with low sales compare?

    <p>SALES to QT= DATEADD(DAY, 15, '05/30/1989')</p> Signup and view all the answers

    In Oracle, what is the default time set to in a DATE data type if no time is specified?

    <p>Midnight</p> Signup and view all the answers

    How can date arithmetic be performed in Oracle, as per the standards discussed?

    <p>By adding a number to a date directly.</p> Signup and view all the answers

    What additional data type does the ANSI/ISO SQL2 standard specify besides DATE, TIME, and TIMESTAMP?

    <p>INTERVAL</p> Signup and view all the answers

    Which format is used in the sample Oracle SQL query for selecting records based on hire date?

    <p>SELECT NAME, HIRE_DATE FROM SALESREP WHERE HIRE_DATE &gt;= '14-JUN-89'</p> Signup and view all the answers

    When deleting customers, the condition for deletion can be based on which of the following criteria?

    <p>The company name</p> Signup and view all the answers

    Study Notes

    SQL Conventions

    • SQL: The Complete Reference describes SQL features in popular DBMS products and ANSI/ISO standards.
    • Syntax is generally consistent across SQL dialects, with differences noted.
    • Examples follow common practices, so slight modifications might be needed for specific DBMS.
    • Technical terms are italicized on first use.
    • SQL keywords, table/column names, and sample statements are in uppercase monospace font.
    • SQL API function names are in lowercase monospace font.
    • Program listings use normal case conventions for the programming language.
    • Uppercase for COBOL/FORTRAN, lowercase for C.
    • Uppercase or lowercase statements are usually accepted.
    • Query results follow SQL statements; long results are truncated with "...".

    SQL Capabilities

    • Retrieve data (e.g., sales representative names, offices, sales, quotas).
    • Calculate results (differences between sales and quotas).
    • Filter data based on conditions (e.g., sales less than quota).
    • Sort data (e.g., orders by amount).
    • Summarize data (e.g., average order amount by customer).
    • Add new data (e.g., sales office, customer).
    • Delete data (e.g., customer, salesperson).

    Simple Queries

    • The SELECT statement retrieves data from a database.
    • Can retrieve information from one table (e.g., sales offices).
    • Can filter results using WHERE clauses (e.g., Eastern region offices).
    • Display filtered data, sorted by columns (e.g., Eastern region offices exceeding targets, sorted alphabetically).

    Data Summarization

    • Calculate averages (e.g., average order amount).
    • Calculate averages based on conditions (e.g., average order amount by a specific customer).
    • Calculate sums grouped by a column (e.g., total orders by customer).

    Add Data

    • Data can be added to the database with INSERT statements (e.g. sales office).

    Data Delete

    • DELETE statements remove data from a database (e.g., customer, salespeople).

    Date and Time Functionality

    • Some SQL implementations (e.g., Oracle, DB2, SQL Server) have different date/time formats.
    • Different implementations support date arithmetic.
    • ANSI/ISO standard includes data types like DATE, TIME, TIMESTAMP, and INTERVAL.
    • String concatenation is specific to some deployments.

    Built-in Functions

    • Most SQL implementations offer built-in functions (e.g., arithmetic, data type conversion).
    • Function examples: MONTH(), YEAR(), TO_CHAR().
    • Flexibility for data reformatting, manipulation, and display.
    • Syntax varies among dialects.
    • Different functions with slightly different syntax may be included in different implementations.

    Studying That Suits You

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

    Quiz Team

    Related Documents

    SQL: The Complete Reference PDF

    Description

    This quiz explores the conventions and capabilities of SQL as described in 'SQL: The Complete Reference'. Learn about the consistent syntax across various SQL dialects, how to retrieve and manipulate data, and understand the technical terms used in SQL practice. Brush up on SQL queries and their results to enhance your database management skills.

    More Like This

    SQL Syntax
    32 questions

    SQL Syntax

    ArtisticPenguin avatar
    ArtisticPenguin
    SQL DELETE Statement and Syntax
    6 questions
    SQL Operators
    30 questions
    Use Quizgecko on...
    Browser
    Browser