Podcast
Questions and Answers
What SQL command would you use to combine the FIRST_NAME and LAST_NAME into a single column?
What SQL command would you use to combine the FIRST_NAME and LAST_NAME into a single column?
- SELECT FIRST_NAME + LAST_NAME AS COMPLETE_NAME FROM Worker;
- SELECT FIRST_NAME & LAST_NAME AS COMPLETE_NAME FROM Worker;
- SELECT CONCAT(FIRST_NAME, LAST_NAME) AS COMPLETE_NAME FROM Worker; (correct)
- SELECT FIRST_NAME || LAST_NAME AS COMPLETE_NAME FROM Worker;
Which SQL query correctly retrieves the count of employees in the 'Admin' department?
Which SQL query correctly retrieves the count of employees in the 'Admin' department?
- SELECT COUNT(*) AS EmployeeCount FROM Worker WHERE DEPARTMENT LIKE 'Admin';
- SELECT COUNT(*) FROM Worker WHERE DEPARTMENT = 'Admin'; (correct)
- SELECT COUNT(DEPARTMENT) FROM Worker WHERE DEPARTMENT = 'Admin';
- SELECT SUM(1) FROM Worker WHERE DEPARTMENT = 'Admin';
What will be the output of the query 'SELECT FIRST_NAME FROM Worker WHERE FIRST_NAME LIKE '%a%';'?
What will be the output of the query 'SELECT FIRST_NAME FROM Worker WHERE FIRST_NAME LIKE '%a%';'?
- It retrieves first names starting with 'a' or ending with 'a'.
- It retrieves all first names with 'a' at the beginning.
- It retrieves all first names containing the letter 'a' anywhere. (correct)
- It retrieves all first names that end with 'a'.
Which SQL statement correctly orders all workers by FIRST_NAME ascending and DEPARTMENT descending?
Which SQL statement correctly orders all workers by FIRST_NAME ascending and DEPARTMENT descending?
Which SQL query fetches details for workers excluding first names 'Vipul' and 'Satish'?
Which SQL query fetches details for workers excluding first names 'Vipul' and 'Satish'?
Flashcards
What is an Alias name in SQL?
What is an Alias name in SQL?
An alias name, also known as a nickname, lets you provide a shorter and more descriptive name for a column or table in your SQL query. This makes your code easier to read and understand.
How to Convert Names to Uppercase in SQL?
How to Convert Names to Uppercase in SQL?
The UPPER()
function in SQL converts all characters in a string to uppercase. It's useful for formatting data, ensuring consistent capitalization in reports, or performing case-insensitive comparisons.
How to Find Unique Values in SQL?
How to Find Unique Values in SQL?
The DISTINCT
keyword in SQL helps you filter out duplicate values from a column. It ensures that each unique value appears only once in your results.
How to Combine Strings (Names) in SQL?
How to Combine Strings (Names) in SQL?
Signup and view all the flashcards
How to Sort Data in SQL?
How to Sort Data in SQL?
Signup and view all the flashcards
Study Notes
SQL Queries for Worker Table
-
Query 1: Select the first name from the
Worker
table, aliased asWORKER_NAME
.SELECT FIRST_NAME AS WORKER_NAME FROM worker
-
Query 2: Select the first name from the
Worker
table in uppercase.SELECT UPPER(FIRST_NAME) FROM Worker
-
Query 3: Select unique department values from the
Worker
table.SELECT DISTINCT DEPARTMENT FROM Worker
-
Query 4: Concatenate first and last name into a single column
COMPLETE_NAME
, separated by a comma.SELECT CONCAT(FIRST_NAME, ', ', LAST_NAME) AS COMPLETE_NAME FROM Worker
-
Query 5: Select all worker details, ordered by first name ascending.
SELECT * FROM Worker ORDER BY FIRST_NAME ASC
-
Query 6: Select all worker details, ordered by first name ascending and department descending.
SELECT * FROM Worker ORDER BY FIRST_NAME ASC, DEPARTMENT DESC
-
Query 7: Select worker details where first name is "Vipul" or "Satish".
SELECT * FROM Worker WHERE FIRST_NAME = 'Vipul' OR FIRST_NAME = 'Satish'
-
Query 8: Select worker details excluding first names "Vipul" and "Satish".
SELECT * FROM Worker WHERE FIRST_NAME != 'Vipul' AND FIRST_NAME != 'Satish'
-
Query 9: Select worker details where first name contains "a".
SELECT * FROM Worker WHERE FIRST_NAME LIKE '%a%'
-
Query 10: Select worker details where salary is between 100000 and 500000.
SELECT * FROM Worker WHERE SALARY BETWEEN 100000 AND 500000
-
Query 11: Count employees in the "Admin" department.
SELECT COUNT(*) FROM Worker WHERE DEPARTMENT = 'Admin'
-
Query 12: Select the top 10 records from the
Worker
table.SELECT * FROM Worker LIMIT 10
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.