SQL Queries for Worker Table
6 Questions
1 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

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;</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');</p> Signup and view all the answers

    Signup and view all the answers

    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

    Description

    Test your knowledge of SQL with this quiz focusing on various queries related to the Worker table. Cover essential SELECT statements, including unique selections, string manipulation, and sorting. Challenge yourself with practical examples and improve your database skills.

    More Like This

    Use Quizgecko on...
    Browser
    Browser