(BIS) SQL Question Bank

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/49

encourage image

There's no tags or description

Looks like no tags are added yet.

50 Terms

1
New cards

 How many customers are in the Customers table?

8

2
New cards

Use the Orders table. In the Orders table, what does each row represent?

One order

3
New cards

Use both tables. Which column appears in both tables and connects them?

customer_id

4
New cards

Use both tables. Order O00902 has customer_id C0367. Who placed this order?

Barbara Alvarez

5
New cards

In a query, which word tells SQL which table to look in?

FROM

6
New cards

Which word keeps only the rows that match a condition (for example, only Texas customers)?

WHERE

7
New cards

In the query below, what does the mean? (select * from customers)

Show all columns

8
New cards

What does COUNT(*) do?

Counts how many rows there are

9
New cards

What does the following do? ORDER BY order_total DESC;

Sorts orders from biggest total to smallest

10
New cards

What does the following do? GROUP BY ship_mode;

Puts orders into groups by ship mode so each group can be counted or added up

11
New cards

Use the Customers table. How many names does this query return? SELECT first_name FROM Customers WHERE state = 'TX';

4

12
New cards

Use the Orders table. What does this query return? SELECT order_status FROM Orders WHERE order_id = 'O00902'

Cancelled

13
New cards

Use the Orders table. What does this query return? SELECT payment_method FROM Orders WHERE order_id = 'O00587';

Gift Card

14
New cards

Use the Orders table. What number does this query return? SELECT COUNT(*) FROM Orders WHERE payment_method = 'Credit Card';

5

15
New cards

Use the Customers table. Which names does this query return? SELECT first_name FROM Customers WHERE segment = 'Home Office';

Heather and Carol

16
New cards

Use the Orders table. What number does this query return? SELECT COUNT(*) FROM Orders;

12

17
New cards

Use the Customers table. What does this query return? SELECT city FROM Customers WHERE first_name = 'Anthony';

Fort Worth

18
New cards

“Show everything in the Customers table.” Which query answers this?

SELECT * FROM Customers

19
New cards

“How many orders are there?” Which query answers this?

SELECT COUNT(*) FROM Orders

20
New cards

“Show the customers who live in Texas.” Which query answers this?

SELECT * FROM Customers WHERE state = 'TX'

21
New cards

“What is the total dollar amount of all orders?” Which query answers this?

SELECT SUM(order_total) FROM Orders

22
New cards

“Show orders from the biggest total to the smallest.” Which query answers this?

SELECT * FROM Orders ORDER BY order_total DESC

23
New cards

Use the Customers table. A manager asks, “How many customers do we have?” The AI writes the query below, which returns 8. Is the AI right? SELECT COUNT(*) FROM Customers;

Yes. The table has 8 customers

24
New cards

Use the Customers table. A manager asks, “Show our Texas customers.” The AI’s query returns all 8 customers, including people in Atlanta and Chicago. Is the AI right?

No. It also shows customers from other states, so it is missing WHERE state = 'TX'

25
New cards

The AI gives you a query. What should you do first?

Run it in SQLite and check the result against the table

26
New cards

Why should you check an AI’s SQL answer?

AI can make mistakes

27
New cards

Use the Orders table. Which ship mode has the most orders? SELECT ship_mode, COUNT(*) FROM Orders GROUP BY ship_mode;

Standard (7 orders)

28
New cards

Use the Customers table. What number appears next to Central? SELECT region, COUNT(*) FROM Customers GROUP BY region;

5

29
New cards

Use the Orders table. What number does this query return? SELECT SUM(order_total) FROM Orders;

2441.93

30
New cards

What does SUM do?

Adds numbers together

31
New cards

Use the Customers table. In the Customers table, what does each row represent?

One customer

32
New cards

Use the Customers table. Which column tells you the city a customer lives in?

city

33
New cards

Use the Orders table. Which column shows how much money an order was for?

order_total

34
New cards

Which word starts a query and lists the columns you want to see?

SELECT

35
New cards

What does LIMIT 3 do?

Shows only the first 3 rows

36
New cards

In WHERE state = 'TX', why is TX inside single quotes?

Because it is text

37
New cards

What does the semicolon ( ; ) at the end of a query mean?

The query ends here

38
New cards

Use the Customers table. What does this query return? SELECT last_name FROM Customers WHERE first_name = 'Heather';

Castillo

39
New cards

Use the Customers table. What does this query return? SELECT state FROM Customers WHERE city = 'Orlando';

FL

40
New cards

Use the Orders table. What does this query return? SELECT ship_mode FROM Orders WHERE order_id = 'O01036';

Two-Day

41
New cards

Use the Customers table. What number does this query return? SELECT COUNT(*) FROM Customers WHERE segment = 'Corporate';

2

42
New cards

“Show each customer’s first name and city.” Which query answers this?

SELECT first_name, city FROM Customers

43
New cards

“How many customers do we have?” Which query answers this?

SELECT COUNT(*) FROM Customers

44
New cards

“Show only the cancelled orders.” Which query answers this?

SELECT * FROM Orders WHERE order_status = 'Cancelled'

45
New cards

“Show the first 5 orders.” Which query answers this?

SELECT * FROM Orders LIMIT 5

46
New cards

Use the Orders table. A manager asks, “How many orders do we have?” The AI’s query returns 12. Is the AI right?

Yes. The table has 12 orders

47
New cards

Use the Customers table. A manager asks, “Which customers live in California?” The AI’s result shows one row: Charles Bennett, Los Angeles, CA. Is the AI right?

Yes, Charles is the only California customer

48
New cards

You run an AI-written query and SQLite shows an error message. What should you do?

Read the error, ask the AI to fix the query, and run it again

49
New cards

Use the Orders table. Which payment method has the most orders? SELECT payment_method, COUNT(*) FROM Orders GROUP BY payment_method;

Credit Card (5 orders)

50
New cards

Use the Customers table. What number appears next to Consumer? SELECT segment, COUNT(*) FROM Customers GROUP BY segment;

4