ClassicModels SQL Exercises
26 Questions
100 Views

ClassicModels SQL Exercises

Created by
@EasygoingAgate6318

Questions and Answers

What does the SQL command SELECT * FROM Payments LIMIT 10; do?

List all the records in the Payments table and display only the first 10 rows of results.

What does the SQL command SELECT checkNumber FROM Payments LIMIT 10; do?

Display all the values for checkNumber in the Payments table.

What does the SQL command SELECT paymentDate FROM Payments LIMIT 10; do?

Display all the values for paymentDate in the Payments table.

What does the SQL command SELECT amount FROM Payments LIMIT 10; do?

<p>Display all the values for amount in the Payments table.</p> Signup and view all the answers

What does the SQL command SELECT customerNumber FROM Payments LIMIT 10; do?

<p>Display all the values for customerNumber in the Payments table.</p> Signup and view all the answers

What does the SQL command SELECT checkNumber FROM Payments ORDER BY checkNumber LIMIT 10; do?

<p>Display all the values for checkNumber in the Payments table and sort the results by checkNumber.</p> Signup and view all the answers

What does the SQL command SELECT checkNumber FROM Payments ORDER BY checkNumber DESC LIMIT 10; do?

<p>Display all the values for checkNumber in the Payments table and sort the results by checkNumber in descending order.</p> Signup and view all the answers

What does the SQL command SELECT paymentDate FROM Payments ORDER BY paymentDate LIMIT 10; do?

<p>Display all the values for paymentDate in the Payments table and sort the results by paymentDate.</p> Signup and view all the answers

What does the SQL command SELECT paymentDate FROM Payments ORDER BY paymentDate DESC LIMIT 10; do?

<p>Display all the values for paymentDate in the Payments table and sort the results by paymentDate in descending order.</p> Signup and view all the answers

What does the SQL command SELECT customerNumber FROM Payments ORDER BY customerNumber LIMIT 10; do?

<p>Display all the values for customerNumber in the Payments table and sort the results by customerNumber.</p> Signup and view all the answers

What does the SQL command SELECT customerNumber FROM Payments ORDER BY customerNumber DESC LIMIT 10; do?

<p>Display all the values for customerNumber in the Payments table and sort the results by customerNumber in descending order.</p> Signup and view all the answers

What does the SQL command SELECT checkNumber, paymentDate FROM Payments LIMIT 10; do?

<p>Display the values for checkNumber and paymentDate in the Payments table.</p> Signup and view all the answers

What does the SQL command SELECT checkNumber, amount FROM Payments LIMIT 10; do?

<p>Display the values for checkNumber and amount in the Payments table.</p> Signup and view all the answers

What does the SQL command SELECT checkNumber, customerNumber FROM Payments LIMIT 10; do?

<p>Display the values for checkNumber and customerNumber in the Payments table.</p> Signup and view all the answers

What does the SQL command SELECT DISTINCT(customerNumber) FROM Payments LIMIT 10; do?

<p>Display a list of unique customerNumber values in the Payments table.</p> Signup and view all the answers

What does the SQL command SELECT MIN(amount) AS 'Smallest Payment' FROM Payments; do?

<p>Display the smallest amount value in the Payments table labeled 'Smallest Payment'.</p> Signup and view all the answers

What does the SQL command SELECT MAX(amount) AS 'Largest Payment' FROM Payments; do?

<p>Display the largest amount value in the Payments table labeled 'Largest Payment'.</p> Signup and view all the answers

What does the SQL command SELECT AVG(amount) FROM Payments LIMIT 10; do?

<p>Display the average amount value in the Payments table.</p> Signup and view all the answers

What does the SQL command SELECT MIN(paymentDate) FROM Payments LIMIT 10; do?

<p>Display the earliest paymentDate value in the Payments table.</p> Signup and view all the answers

What does the SQL command SELECT MAX(paymentDate) FROM Payments LIMIT 10; do?

<p>Display the latest paymentDate value in the Payments table.</p> Signup and view all the answers

What does the SQL command SELECT customerNumber, SUM(amount) FROM Payments GROUP BY customerNumber LIMIT 10; do?

<p>Display the customerNumber and the total payment amount assigned to that customer number in the Payments table.</p> Signup and view all the answers

What does the SQL command SELECT customerNumber, AVG(amount) FROM Payments GROUP BY customerNumber LIMIT 10; do?

<p>Display the customerNumber and the average payment amount assigned to that customerNumber in the Payments table.</p> Signup and view all the answers

What does the SQL command SELECT COUNT(*) FROM Payments LIMIT 10; do?

<p>Calculate the number of rows in the Payments table.</p> Signup and view all the answers

What does the SQL command SELECT COUNT(DISTINCT(customerNumber)) LIMIT 10; do?

<p>Count the number of unique customerNumber values in the Payments table.</p> Signup and view all the answers

What does the SQL command SELECT customerNumber FROM Payments WHERE customerNumber < 200 LIMIT 10; do?

<p>Display the customerNumber values for those customerNumbers in the Payments table that have values less than 200.</p> Signup and view all the answers

What does the SQL command SELECT customerNumber FROM Payments WHERE customerNumber BETWEEN 200 AND 400 LIMIT 10; do?

<p>Display the customerNumber values for those customerNumbers in the Payments table that fall between 200 and 400.</p> Signup and view all the answers

Study Notes

SQL Queries for Payments Table

  • SELECT * FROM Payments LIMIT 10; retrieves all records, displaying the first 10 rows of the Payments table.
  • SELECT checkNumber FROM Payments LIMIT 10; fetches the first 10 entries of checkNumber, offering insight into payment identifiers.
  • SELECT paymentDate FROM Payments LIMIT 10; returns the initial 10 values for paymentDate, showing transaction timestamps.
  • SELECT amount FROM Payments LIMIT 10; lists the first 10 recorded payment amounts, indicating financial transactions.
  • SELECT customerNumber FROM Payments LIMIT 10; reveals the first 10 customerNumber values, identifying clients associated with payments.

Sorting and Ordering Results

  • SELECT checkNumber FROM Payments ORDER BY checkNumber LIMIT 10; organizes checkNumber values in ascending order, displaying the top 10.
  • SELECT checkNumber FROM Payments ORDER BY checkNumber DESC LIMIT 10; retrieves the first 10 checkNumber entries, sorted in descending order.
  • SELECT paymentDate FROM Payments ORDER BY paymentDate LIMIT 10; sorts the paymentDate values in ascending order for the initial 10 records.
  • SELECT paymentDate FROM Payments ORDER BY paymentDate DESC LIMIT 10; provides the 10 latest paymentDate values in descending order.
  • SELECT customerNumber FROM Payments ORDER BY customerNumber LIMIT 10; organizes customerNumber in ascending order for the top 10 entries.
  • SELECT customerNumber FROM Payments ORDER BY customerNumber DESC LIMIT 10; fetches the first 10 customerNumber entries sorted in descending order.

Multi-Column Selections

  • SELECT checkNumber, paymentDate FROM Payments LIMIT 10; presents both checkNumber and paymentDate for the initial 10 entries.
  • SELECT checkNumber, amount FROM Payments LIMIT 10; displays checkNumber alongside amount for the first 10 transactions.
  • SELECT checkNumber, customerNumber FROM Payments LIMIT 10; provides both checkNumber and customerNumber for the top 10 records.

Unique and Aggregate Functions

  • SELECT DISTINCT(customerNumber) FROM Payments LIMIT 10; generates a list of unique customerNumber values, helping to identify distinct clients.
  • SELECT MIN(amount) AS 'Smallest Payment' FROM Payments; calculates and labels the minimum payment amount as 'Smallest Payment'.
  • SELECT MAX(amount) AS "Largest Payment" FROM Payments; identifies the maximum payment amount, labeled as "Largest Payment".
  • SELECT AVG(amount) FROM Payments LIMIT 10; computes the average payment amount for analysis.
  • SELECT MIN(paymentDate) FROM Payments LIMIT 10; finds the earliest paymentDate, indicating the onset of transactions.
  • SELECT MAX(paymentDate) FROM Payments LIMIT 10; identifies the most recent paymentDate for current payment trends.

Grouping and Counting Data

  • SELECT customerNumber, SUM(amount) FROM Payments GROUP BY customerNumber LIMIT 10; aggregates total payment amounts for each customer, showing the first 10 groups.
  • SELECT customerNumber, AVG(amount) FROM Payments GROUP BY customerNumber LIMIT 10; computes average payment amounts grouped by each customer.
  • SELECT COUNT(*) FROM Payments LIMIT 10; counts total rows in the Payments table, serving as a record of transactions.
  • SELECT COUNT(DISTINCT(customerNumber)) LIMIT 10; counts unique customerNumber values, providing an overview of distinct clients.

Conditional Selections

  • SELECT customerNumber FROM Payments WHERE customerNumber < 200 LIMIT 10; filters customerNumber values under 200, displaying the first 10 results.
  • SELECT customerNumber FROM Payments WHERE customerNumber BETWEEN 200 AND 400 LIMIT 10; retrieves customerNumber values within the specified range, highlighting a specific client segment.

Studying That Suits You

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

Quiz Team

Description

Test your knowledge of SQL commands using ClassicModels database through flashcards. Each card includes a command and its definition, providing a quick overview of key SQL functionalities. Perfect for beginners and those looking to refresh their SQL skills.

More Quizzes Like This

SQL Commands Quiz
3 questions

SQL Commands Quiz

PlayfulMalachite avatar
PlayfulMalachite
SQL Commands Quiz
6 questions

SQL Commands Quiz

EnthralledDaisy avatar
EnthralledDaisy
SQL Fundamentals and Data Definition Commands
29 questions
Use Quizgecko on...
Browser
Browser