Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Given the three tables, write out what you think the output would be if the SQL code were executed. Refer to this tutorial (https://mode.com/sql-tutorial/sql-case/) to
Given the three tables, write out what you think the output would be if the SQL code were executed.
Refer to this tutorial (https://mode.com/sql-tutorial/sql-case/) to understand how to interpret CASE statements.
User ID 1 2 3 email john@gmail.com tom@gmail.com sarah@gmail.com nicole@gmail.com tim@gmail.com name john tom sarah nicole time 4 5 Devices ID 1 2 3 4 5 User_id 3 3 1 desc mobile macbook mobile pc mobile active yes yes no 4 no 4 yes File ID 1 2 3 4 5 User_id 3 3 3 4 4 File_type photo doc Mp3 photo photo File_name Selfie.jpg Todo.docx Song 1.mp3 Vacation 1.jpg Vacation2.jpg 3. = SELECT ID, CASE When File_type = 'photo' Then 'Photo' When File_type = "MP3' Then 'Not Photo' Else 'Not photo nor MP3 End as File_type From File 4. SELECT User.ID, User Name, Device.desc, CASE WHEN Device.desc = 'mobile' Then 'It's a mobile WHEN Device.desc = 'macbook' Then 'It's a macbook' ELSE 'Not mobile nor macbook' END as Device Text FROM User Join Device On user.ID = Device.user_id User ID 1 2 3 email john@gmail.com tom@gmail.com sarah@gmail.com nicole@gmail.com tim@gmail.com name john tom sarah nicole time 4 5 Devices ID 1 2 3 4 5 User_id 3 3 1 desc mobile macbook mobile pc mobile active yes yes no 4 no 4 yes File ID 1 2 3 4 5 User_id 3 3 3 4 4 File_type photo doc Mp3 photo photo File_name Selfie.jpg Todo.docx Song 1.mp3 Vacation 1.jpg Vacation2.jpg 3. = SELECT ID, CASE When File_type = 'photo' Then 'Photo' When File_type = "MP3' Then 'Not Photo' Else 'Not photo nor MP3 End as File_type From File 4. SELECT User.ID, User Name, Device.desc, CASE WHEN Device.desc = 'mobile' Then 'It's a mobile WHEN Device.desc = 'macbook' Then 'It's a macbook' ELSE 'Not mobile nor macbook' END as Device Text FROM User Join Device On user.ID = Device.user_id
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started