SQL Queries for Worker Table

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

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?

  • 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%';'?

  • 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?

<p>SELECT * FROM Worker ORDER BY FIRST_NAME ASC, DEPARTMENT DESC; (A)</p> Signup and view all the answers

Which SQL query fetches details for workers excluding first names 'Vipul' and 'Satish'?

<p>SELECT * FROM Worker WHERE FIRST_NAME NOT IN ('Vipul', 'Satish'); (B)</p> Signup and view all the answers

Signup and view all the answers

Flashcards

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?

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?

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?

The CONCAT() function combines two or more strings into a single string. You can add spaces or other characters to separate the strings as needed.

Signup and view all the flashcards

How to Sort Data in SQL?

The ORDER BY clause allows you to sort the results of your SQL query in ascending or descending order based on one or more columns. This helps you organize your data for better readability and analysis.

Signup and view all the flashcards

Study Notes

SQL Queries for Worker Table

  • Query 1: Select the first name from the Worker table, aliased as WORKER_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.

Quiz Team

Related Documents

More Like This

Database Quiz: Company Contacts
5 questions
[05/Sanggan/06]
15 questions

[05/Sanggan/06]

InestimableRhodolite avatar
InestimableRhodolite
SQL Queries for Data Analytics
18 questions

SQL Queries for Data Analytics

WorldFamousSeaborgium avatar
WorldFamousSeaborgium
Use Quizgecko on...
Browser
Browser