From the l_employees table, list all the different combinations of dept_code and credit_limit. Count the number of employees who are in each of these categories. Sort the rows by dept_code and then by credit_limit. Exclude the ‘SHP’ department in your results. Show only the dept_code, with a credit limit of over 12.50. Show your sql below.
Show me code step by step and or take screenshots of code and run test.
Hi,
Your are not sharing the structure of table l_employees which your
using. But based on your question I'm creating one table which can
reproducible all your question,
Take loop at table which I created:
create table if not exists l_employees(
employ_name varchar(30) not null,
dept_code varchar(10),
credit_limit decimal(8,2),
department varchar(10)
);
here i'm assuming dept_code is varchar of length 10, credit_limit of 8 length and 2 decimal points max(999999.99) and etc.
Insert some data into table using insert query:
insert into l_employees values("Shiva","ADMIN",
500000.00, "ADM");
insert into l_employees values("Venkat","HR", 600000.00,
"ADM");
insert into l_employees values("Venky","DEV", 700000.00,
"SHP");
insert into l_employees values("Swathi","QA", 800000.00,
"ADM");
insert into l_employees values("Pooji",null, 400000.00,
"ADM");
insert into l_employees values("Adi","BUSS", 300000.00,
"SHP");
insert into l_employees values("Amara","ADMIN", null, "ADM");
insert into l_employees values("Ammu","DEV", 550000.00,
"SHP");
insert into l_employees values("Kiran","DEV", 880000.00,
"ADM");
After inserting take a loop at what table contains: (you can use select * from l_employees;)

Now let's start your questions:
1. List all the
different combinations of dept_code and credit_limit
:
SQL command you required for this is:
select d.dept_code,c.credit_limit
from (select distinct credit_limit from l_employees) c cross
join
(select distinct dept_code from l_employees) d;
here d and c are variable which are pointing to dept_code and
credit_limit respectively.
distinct credit_limit from l_employees return all
unique values of credit_limit column values similarly
select distinct dept_code from
l_employees.
cross join : is SQL gives the all possible combination of two sets.
Output after executing above commad is :


2. Count the number of employees who are in each of these categories:
Here I took two categories are dept_code and credit_limit, employees belongs each of these categories means all employees which are having both these categories as not null.
To achieve that required command id :
SELECT COUNT(*) FROM l_employees where dept_code is not null and credit_limit is not null;
Here count(*) returns one column as count, and values from l_employees table where dept_code is not null and credit_limit is also not null.
Output after this command:
because table have total 9
rows and 2 rows having null values. So answer is 7
Note: You can count any combination using below syntax
select count(*) from table_name where
condition1,condition2.etc; example select count(*) where
credit_limit > 500000.00 and department = "ADM"
3.Sort the rows by
dept_code and then by credit_limit:
Command for this is:
select * from l_employees order by dept_code,credit_limit;
here order by returns sorted list with respective to column dept_code and column credit_limit.
Syntax is : select * from table_name order by column1,column2..etc;
Output:

4.Exclude the ‘SHP’ department in your results:
For this you only require where clause to avoid SHP department;
Examples :
1. avoid SHP department in problem1:
select d.dept_code,c.credit_limit
from (select distinct credit_limit from l_employees where
department != "SHP") c cross join
(select distinct dept_code from l_employees where department !=
"SHP") d;
result is:

2. avoid SHP department in problem2:
SELECT COUNT(*) FROM l_employees where dept_code is not
null and credit_limit is not null and department !=
"SHP";
Output:

3. avoid SHP department in problem3:
select * from l_employees where department != "SHP"
order by dept_code,credit_limit;
Output:

5. Show only the dept_code, with a
credit limit of over 12.50 :
For the best suit with current table I'm making credit_card limit
to 500000.00
command is:
select distinct dept_code from l_employees where
credit_limit > 500000.00;
Output:

All commands at once:

Hope you got what you want . Cheers..?????!
From the l_employees table, list all the different combinations of dept_code and credit_limit. Count the number...
Which SQL statement retrieves the EmployeeName and City columns from the Employees table? O LIST EmployeeName, City ON Employees; O FIND EmployeeName, City ON Employees; SELECT EmployeeName, City FROM Employees; O RETRIEVE EmployeeName, City FROM Employees; Which SQL statement finds the different cities in which national parks reside with no duplicate rows listed? SELECT DISTINCT city FROM natlpark ORDER BY city; O ORDER BY natlpark DISTINCT city; O ORDER BY city FROM natlpark; O SELECT city FROM natlpark ORDER BY...
Using SQL*Plus on OMEGA, access the tables you created in Project 2 and complete the following SQL transactions. Log your statements and results by spooling your file (with echo on). Directions for creating and running SQL files are available in the Assignments and Exams page in Blackboard (in the Project 2 group of files). All column headings must show in their entirety. Be sure to include a cover sheet with your full name, section, and date submitted. 19. 4 points...
Assume that Flags are 0 and 1. Please note all other assumptions
with inline code comments.
a. Write a SQL query that will show them one
value which represents the number of employees with more than 150
hours accrued vacation.
b. Write SQL ONE query that returns two rows:
The first is a count of salaried employees with over 125 hours
accrued vacation and the second result row is the count of
non-salaried employees with over 125 hours accrued vacation....
I need help with certain questions. Please.
18. 4 points
For each Rental, list the Rental ID,
Rental date, customer ID, customer first name, customer last name,
and count of disks rented; sort by Rental ID. Show the Rental date
formatted as ‘mm-dd-yyyy.’ Hint: use a GROUP BY clause.
19. 4 points
List the disk ID, title name, rating,
format description, and fee amount for all copies rented in Rental
3; sort by disk ID. Show the fee amount formatted...
please help me out with these SQL problems: 1. Create a treewalking list of every employee's last name, his manager's last name, and his position in the company. – The top level manager has position 1, this manager's subordinates position 2, their subordinates position 3, and so on. – Start the listing with employee number 100. 2. create the list of department names and the departmental costs (salaries added up). – Include only departments whose salary costs are between 15000...
The Ch07_ConstructCo database stores data for a consulting company that tracks all charges to projects. The charges are based on the hours each employee works on each project. The structure and contents of the Ch07_ConstructCo database are shown in Figure P7.1.Note that the ASSIGNMENT table in Figure P7.1 stores the JOB_CHG_HOUR values as an attribute (ASSIGN_CHG_HR) to maintain historical accuracy of the data. The JOB_CHG_HOUR values are likely to change over time. In fact, a JOB_CHG_ HOUR change will be...
This code must be in SQL - Run the script provided with the assignment. This will create the tables used for this assignment. Write the necessary SQL commands to perform the required actions. Run the queries to obtain results from the database. (Make sure all columns returned have proper headings.) 3 2 In a single row show the following values: how many unique manufacturers are in the products table. What is the most expensive price per unit in the products...
Hello! I'm posting this program that is partially completed if someone can help me out, I will give you a good rating! Thanks, // You are given a partially completed program that creates a list of employees, like employees' record. // Each record has this information: employee's name, supervisors's name, department of the employee, room number. // The struct 'employeeRecord' holds information of one employee. Department is enum type. // An array of structs called 'list' is made to hold...
Given (Oracle) SQL Script " CREATE TABLE Members( MemberID NUMBER(4) NOT NULL PRIMARY KEY, MFirst VARCHAR(25) NOT NULL, MLast VARCHAR(25) NOT NULL, Street VARCHAR(64) NOT NULL, City VARCHAR(25) NOT NULL, State VARCHAR(2) NOT NULL, ZipCode NUMBER(5) NOT NULL, CreditLimit NUMBER(7,2) NOT NULL, Gender VARCHAR(1) NOT NULL CHECK (Gender IN('F','M')) ); CREATE TABLE Employees( EmployeeID NUMBER(3) NOT NULL PRIMARY KEY, EFirst VARCHAR(25) NOT NULL, ELast VARCHAR(25) NOT NULL, ...
SQL Queries – in this assignment you will be asked to create several SQL queries relating to the Sakila database that we installed in class. You may freely use DBeaver to create these queries, but I will expect your solution to show me the SQL code to answer or complete the tasks below. Write a query that produces the last name, first name, address, district, and phone number for every customer in the customer table. (You don’t need to include...