Given the three tables, write out what you think the output would be if the...
70.2K
Verified Solution
Link Copied!
Question
Accounting
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 [email protected][email protected][email protected][email protected][email protected] 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 [email protected][email protected][email protected][email protected][email protected] 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
Answer & Explanation
Solved by verified expert
Get Answers to Unlimited Questions
Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!
Membership Benefits:
Unlimited Question Access with detailed Answers
Zin AI - 3 Million Words
10 Dall-E 3 Images
20 Plot Generations
Conversation with Dialogue Memory
No Ads, Ever!
Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!