Write Queries for the questions below using SQL
Question 1: Count the number of employees per
company ID
Question 2: Provide all active company names
and their admin’s corresponding state
Question 3: What is the average monthly revenue
of all contracts?
Question 4: Per company ID, provide the name of
their first employee based on their name’s alphabetical
order
Question 5: Provide a list of employees and
admins, and their corresponding company name
+Table Name: Companies Column Name Column Type company (PK) BIGINT company Name VARCHAR(256) isActive BOOLEAN contractAmount DECIMAL (16,2) contractLength VARCHAR(16) Table Name*: Company_Admin Column Name Column Type adminID (PK) BIGINT company BIGINT admin Name VARCHAR(256) adminState VARCHAR(2) adminEmail VARCHAR(256) Table notes*: Admins are not considered employees Each company has one admin Table Name: Employee_Registree Column Name Column Type employeelD (PK) BIGINT companyID BIGINT employee Name VARCHAR(256) employee State VARCHAR(2) Appendix A Nullable? N N Y N N Nullable? N N N Y N Nullable? N N N Y Value Definitions Unique Identifier 0 = Not active, 1 = Active, NULL = unknown Amount of a company contract, based on contract length Contract length, either 'monthly', 'quarterly', or 'yearly' Value Definitions Unique Identifier Join key First and last name 2-letter state abbreviation Value Definitions Unique Identifier Join key First and last name 2-letter state abbreviation
Write Queries for the questions below using SQL Question 1: Count the number of employees per company ID Question 2: Pro
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am