Let’s look at using some complex SQL queries to find data from a…
Question Answered step-by-step Let’s look at using some complex SQL queries to find data from a… Let’s look at using some complex SQL queries to find data from a database containing 2 tables : employees and departments. The employees table will have the following columns and data types:employee_id – INTEGERname – TEXTemail – TEXTphone_number – TEXTdepartment_id – INTEGER The department table will have the following columns and data types:department_id – INTEGERdepartment_name – TEXTlocation – TEXTbudget – REAL You are supposed to set the following keys and constraints for both the tables:employeesemployee_id – PRIMARY KEY. departmentsdepartment_id – PRIMARY KEY. Next, enter the following data for the employees table :employee_id : 1, name : Viraj, email : <..a@edu, phone_number : 3104567890, department_id : 510.employee_id : 2, name : Vishal, email : <..m@edu, phone_number : 9876543210, department_id : 510.employee_id : 3, name : Sanjana, email : <..d@edu, phone_number : 3107623421, department_id : 553.employee_id : 4, name : Swarnita, email : <..a@edu, phone_number : 2526441314, department_id : 553.employee_id : 4, name : Joe, email : <..e@edu, phone_number : 3106441777, department_id : 444. For the department table, insert these 2 rows:department_id: 510, department_name: Sales, location: San Francisco, budget: 2000000department_id: 553, department_name: Marketing, location: Los Angeles, budget: 1000000department_id: 444, department_name: Engineering, location: Los Angeles, budget: 3000000-------------------------Write SQL queries to answer the following:Find the name, email and phone of employees that have a phone with prefix '310' but don't work in the Sales department.Find the name and email of employees, and the number of employees working in their department. You'll need to use an subquery with agregation and join with it to answer this.Find the total budget for Los AngelesFind the employees of the deparment with the largest budget. Hint: you need to use a subquery -----------import sqlite3def sample_data(): pass (write code here) sample_data() Computer Science Engineering & Technology Python Programming 95 737 Share QuestionEmailCopy link Comments (0)


