Search Header Logo
Databases

Databases

Assessment

Presentation

Computers

10th Grade

Practice Problem

Medium

Created by

Robert B.A

Used 1+ times

FREE Resource

7 Slides • 22 Questions

1

SQL

2

Introduction

  • Structured Query Language (SQL) is the standard query language for writing scripts to obtain useful information from a database.

  • SQL performs actions such as defining tables, changing tables, add data to tables, search data from the table, perform calculations.

3

SQL scripts

An SQL script is a list of SQL commands that perform a given task, often stored in a file so the script can be reused.

4

SELECT .... FROM

  • SELECT: Fetches specified fields (columns) from a table; queries

    always begin with SELECT.

  • FROM: Identifies the table to use.

  • SELECT * – this specifies that all fields (columns) are to be shown.


SELECT ColumnName
FROM TableName

5

SQL Examples

  • Display the first name of all students

  • Display the first name and last name of all students

  • Display all columns in the table

6

SELECT .. FROM ... WHERE

  • This retreives only specific data.

  • logical operators for single condition.

    • = (Equal to)

    • < (Less than)

    • > (Greater than)

    • <= (Less or equal to)

    • >= (Greater or equal to)

    • <> (Not equal to)

7

Multiple Conditions

  • Operators used for multiple conditions

    • AND. (Returns data that meets both conditions)

    • OR. (Returns data that meets one condition or both)

8

Fill in the Blanks

9

Multiple Choice

What does the SELECT statement in SQL do?

1
Creates a new database
2
Retrieves data from a database
3
Updates data in a database
4
Deletes data from a database

10

Multiple Choice

Which SQL keyword is used to select all columns from a table?

1
SELECT *
2
SELECT ALL FIELDS
3
SELECT ALL COLUMNS
4
SELECT ALL

11

Multiple Choice

How would you retrieve the "FirstName" and "LastName" columns from the "Employees" table?

1
SELECT LastName, FirstName FROM Employees;
2
SELECT * FROM Employees;
3
SELECT FirstName, LastName FROM Employees;
4
SELECT FirstName, LastName FROM Staff;

12

Multiple Choice

Which clause is used to filter the results of a SELECT statement?

1
GROUP BY
2
SELECT
3
FILTER
4
WHERE

13

Multiple Choice

What does the following SQL query do?

SELECT ProductName, Price FROM Products WHERE Price > 100;

1
It retrieves the names and prices of products with a price higher than 100.
2
It retrieves all products regardless of price.
3
It deletes products with a price below 100.
4
It updates the prices of products above 100.

14

Multiple Choice

Which SQL statement correctly retrieves all columns from the "Students" table where the "Grade" is greater than 85?

1
SELECT * FROM Students WHERE Grade > 85;
2
SELECT * FROM Students WHERE Grade > 85.0;
3
SELECT * FROM Students WHERE Grade > '85';
4
SELECT * FROM Students WHERE Grade >= 85;

15

Multiple Choice

How would you write a query to retrieve the "FirstName" and "LastName" of employees from the "Employees" table who are in the "Sales" department?

1
SELECT * FROM Employees WHERE Department = 'Sales';
2
SELECT FirstName, LastName FROM Employees WHERE Department = 'Marketing';
3
SELECT FirstName, LastName FROM Employees WHERE Department = 'HR';
4
SELECT FirstName, LastName FROM Employees WHERE Department = 'Sales';

16

Multiple Choice

How would you retrieve all products from the "Products" table that have a price less than $50?

1
SELECT * FROM Products WHERE price > 50;
2
SELECT * FROM Products WHERE price = 50;
3
SELECT * FROM Products WHERE price <= 50;
4
SELECT * FROM Products WHERE price < 50;

17

Multiple Choice

Which of the following queries retrieves employees from the "Employees" table who are not in the "IT" department?

1
SELECT * FROM Employees WHERE department = 'HR'
2
SELECT * FROM Employees WHERE department != 'IT'
3
SELECT * FROM Employees WHERE department = 'IT'
4
SELECT * FROM Employees WHERE department <> 'IT'

18

Multiple Choice

How would you write a query to select the "CustomerName" and "City" from the "Customers" table for customers who live in "New York"?

1
SELECT CustomerName, City FROM Customers WHERE City = 'Miami';
2
SELECT CustomerName, City FROM Customers WHERE City = 'New York';
3
SELECT CustomerName, City FROM Customers WHERE City = 'Chicago';
4
SELECT CustomerName, City FROM Customers WHERE City = 'Los Angeles';

19

Multiple Choice

Which SQL statement is used to retrieve all columns from the "Transactions" table where the "TransactionType" is 'Credit'?

1
SELECT * FROM Transactions WHERE TransactionType = 'Credit';
2
SELECT * FROM Transactions WHERE TransactionType = 'Transfer';
3
SELECT * FROM Transactions WHERE TransactionType = 'Cash';
4
SELECT * FROM Transactions WHERE TransactionType = 'Debit';

20

Multiple Choice

What will the following SQL query return?

SELECT FirstName, LastName FROM Employees WHERE Salary > 50000;

1
A list of full names of employees with a salary greater than 50000
2
A list of employee IDs with a salary greater than 50000
3
A list of last names of employees with a salary greater than 50000
4
A list of first names and last names of employees with a salary greater than 50000.

21

Multiple Choice

Which data type would be most appropriate for storing a student’s date of birth in a school database?

1

Date

2

Text

22

Multiple Choice

A database stores the percentage of students who passed an exam. Which data type should be used for this percentage?

1

Integer

2

Float/Real

3

Text

4

Boolean

23

Multiple Choice

The Is_Enrolled field in a student database, which indicates whether a student is currently enrolled, should use which data type?

1
Date
2
String
3
Boolean
4
Integer

24

Multiple Choice

Which data type would be best for storing a student’s grade level (e.g., 7, 8, 9) in a school database?

1
float
2
boolean
3
string
4
integer

25

Multiple Choice

In a school database, the Email field should be stored as which data type?

1
integer
2
boolean
3
date
4
string

26

Multiple Choice

The GPA (Grade Point Average) field in a student database, which may have decimal places, should be stored as which data type?

1
integer
2
string
3
boolean
4
float or double

27

Multiple Choice

If you were to store a list of extracurricular activities a student is involved in, which data type would be most suitable?

1
integer
2

text

3
float
4
boolean

28

Multiple Choice

Which data type would you use to store a student's contact number in a school database?

1
boolean
2
string
3
array
4
integer

29

Match

Match the following

Account_Number

Account_Holder_Name

Account_Balance

Date_Of_Opening

Is_Active

INTEGER

String/Text

Real

Date

Boolean

SQL

Show answer

Auto Play

Slide 1 / 29

SLIDE