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,
JobTitle VARCHAR(25) NOT NULL,
Department VARCHAR(25) NOT NULL,
Salary NUMBER(7,2) NOT NULL,
EType VARCHAR(25) NOT NULL
);
CREATE TABLE Transactions(
TransactionID NUMBER(4) NOT NULL PRIMARY KEY,
TransactionDate DATE NOT NULL,
Location VARCHAR(25) NOT NULL,
EmployeeID NUMBER(4) NOT NULL,
MemberID NUMBER(4) NOT NULL,
CONSTRAINT Transactions_FK1 FOREIGN KEY (EmployeeID)
REFERENCES Employees(EmployeeID),
CONSTRAINT Transactions_FK2 FOREIGN KEY (MemberID)
REFERENCES Members(MemberID)
);
INSERT INTO Members VALUES(1001, 'Eugene', 'Harris', '5103
McMillan', 'Shady Cove', 'OR', 97539, 300.00, 'M');
INSERT INTO Members VALUES(1002, 'Jill', 'Milburn', '1668
Randolph', 'Bloomington', 'IN', 47404, 800.00, 'F');
INSERT INTO Members VALUES(1003, 'Rodney', 'Wolter', '6089
Oaskshire', 'Lansing', 'IL', 60438, 500.00, 'M');
INSERT INTO Members VALUES(1004, 'Ramona', 'Neill', '3008
Lafayette', 'Downers Grove', 'IL', 60516, 1200.00, 'F');
INSERT INTO Members VALUES(1005, 'Patty', 'Webb', '2565 Ashburn',
'Palatine', 'IL', 60055, 1000.00, 'F');
INSERT INTO Members VALUES(1006, 'Sabrina', 'Melvin', '4976
Dexter', 'Haubstadt', 'IN', 47406, 600.00, 'F');
INSERT INTO Employees VALUES(101, 'Dennis', 'Ulmer', 'Sales
Rep', 'Sales', 56000, 'FullTime');
INSERT INTO Employees VALUES(102, 'Robert', 'Smith', 'Clerk',
'Operations', 32000, 'FullTime');
INSERT INTO Employees VALUES(103, 'Steve', 'Comstock', 'Sales Rep',
'Sales', 44000, 'FullTime');
INSERT INTO Employees VALUES(104, 'Richard', 'Rivero', 'Stocker',
'Operations', 12000, 'Intern');
INSERT INTO Transactions VALUES(1,
TO_DATE('12/30/2014','mm/dd/yyyy'), 'Online', 103, 1001);
INSERT INTO Transactions VALUES(2,
TO_DATE('12/30/2014','mm/dd/yyyy'), 'IL Store', 101, 1003);
INSERT INTO Transactions VALUES(3,
TO_DATE('1/1/2015','mm/dd/yyyy'), 'Online', 101, 1001);
INSERT INTO Transactions VALUES(4,
TO_DATE('6/17/2015','mm/dd/yyyy'), 'IN Store', 104, 1002);
INSERT INTO Transactions VALUES(5,
TO_DATE('7/8/2015','mm/dd/yyyy'), 'IL Store', 103, 1003);
INSERT INTO Transactions VALUES(6,
TO_DATE('11/23/2015','mm/dd/yyyy'), 'Online', 103, 1005);
INSERT INTO Transactions VALUES(7,
TO_DATE('12/3/2016','mm/dd/yyyy'), 'IN Store', 103, 1005);
INSERT INTO Transactions VALUES(8,
TO_DATE('1/10/2016','mm/dd/yyyy'), 'IL Store', 104, 1004);
INSERT INTO Transactions VALUES(9,
TO_DATE('12/22/2016','mm/dd/yyyy'), 'IN Store', 104, 1001);
"
Please answer
1. List the full name of members who are not from the state of IN nor IL.
2. List the full name of each member and the full names of the employees’ who ever assisted that member on a transaction.
3. List the full name and full address of the member who has the highest credit limit.
4. List the full name, title, and department of the employee who handled online transactions.
5. List the member ID, full name, and credit limit of each customer whose credit limit is greater than the average credit limit of all members.
6. List the member ID and the total number of transactions made by the members whose name (including first name and/or last name) contains letter “R”.
7. List the member ID, full name and address of the members who have made a transaction.
8. List the total number of transactions handled by each employee at each location (IN store, IL store, or Online).
9. List the Employee ID and full name of the employees whose salary is above the average.
10. List the full name and the total number of transactions handled by the full-time employee. Rank your results in descending order on the total number of transactions.
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')));
INSERT INTO Members VALUES(1001, 'Eugene', 'Harris', '5103
McMillan', 'Shady Cove', 'OR', 97539, 300.00, 'M');
INSERT INTO Members VALUES(1002, 'Jill', 'Milburn', '1668
Randolph', 'Bloomington', 'IN', 47404, 800.00, 'F');
INSERT INTO Members VALUES(1003, 'Rodney', 'Wolter', '6089
Oaskshire', 'Lansing', 'IL', 60438, 500.00, 'M');
INSERT INTO Members VALUES(1004, 'Ramona', 'Neill', '3008
Lafayette', 'Downers Grove', 'IL', 60516, 1200.00, 'F');
INSERT INTO Members VALUES(1005, 'Patty', 'Webb', '2565 Ashburn',
'Palatine', 'IL', 60055, 1000.00, 'F');
INSERT INTO Members VALUES(1006, 'Sabrina', 'Melvin', '4976
Dexter', 'Haubstadt', 'IN', 47406, 600.00, 'F');
CREATE TABLE Employees(
EmployeeID NUMBER(3) NOT NULL PRIMARY KEY,
EFirst VARCHAR(25) NOT NULL,
ELast VARCHAR(25) NOT NULL,
JobTitle VARCHAR(25) NOT NULL,
Department VARCHAR(25) NOT NULL,
Salary NUMBER(7,2) NOT NULL,
EType VARCHAR(25) NOT NULL);
INSERT INTO Employees VALUES(101, 'Dennis', 'Ulmer', 'Sales
Rep', 'Sales', 56000, 'FullTime');
INSERT INTO Employees VALUES(102, 'Robert', 'Smith', 'Clerk',
'Operations', 32000, 'FullTime');
INSERT INTO Employees VALUES(103, 'Steve', 'Comstock', 'Sales Rep',
'Sales', 44000, 'FullTime');
INSERT INTO Employees VALUES(104, 'Richard', 'Rivero', 'Stocker',
'Operations', 12000, 'Intern');
CREATE TABLE Transactions(
TransactionID NUMBER(4) NOT NULL PRIMARY KEY,
TransactionDate DATE NOT NULL,
Location VARCHAR(25) NOT NULL,
EmployeeID NUMBER(4) NOT NULL,
MemberID NUMBER(4) NOT NULL,
CONSTRAINT Transactions_FK1 FOREIGN KEY (EmployeeID) REFERENCES
Employees(EmployeeID),
CONSTRAINT Transactions_FK2 FOREIGN KEY (MemberID) REFERENCES
Members(MemberID));
INSERT INTO Transactions VALUES(1,
TO_DATE('12/30/2014','mm/dd/yyyy'), 'Online', 103, 1001);
INSERT INTO Transactions VALUES(2,
TO_DATE('12/30/2014','mm/dd/yyyy'), 'IL Store', 101, 1003);
INSERT INTO Transactions VALUES(3,
TO_DATE('1/1/2015','mm/dd/yyyy'), 'Online', 101, 1001);
INSERT INTO Transactions VALUES(4,
TO_DATE('6/17/2015','mm/dd/yyyy'), 'IN Store', 104, 1002);
INSERT INTO Transactions VALUES(5,
TO_DATE('7/8/2015','mm/dd/yyyy'), 'IL Store', 103, 1003);
INSERT INTO Transactions VALUES(6,
TO_DATE('11/23/2015','mm/dd/yyyy'), 'Online', 103, 1005);
INSERT INTO Transactions VALUES(7,
TO_DATE('12/3/2016','mm/dd/yyyy'), 'IN Store', 103, 1005);
INSERT INTO Transactions VALUES(8,
TO_DATE('1/10/2016','mm/dd/yyyy'), 'IL Store', 104, 1004);
INSERT INTO Transactions VALUES(9,
TO_DATE('12/22/2016','mm/dd/yyyy'), 'IN Store', 104, 1001);

1)
select MFirst || ' ' || MLast "Full Name"
from Members
where State!='IN' or State!='IL';
2)
SELECT MFIRST|| ' ' || MLAST "MEMBER FULL NAME", EFIRST|| ' ' ||
ELAST "EMPLOYEE FULL NAME"
FROM EMPLOYEES E,MEMBERS M,TRANSACTIONS T
WHERE E.EMPLOYEEID=T.EMPLOYEEID AND M.MEMBERID=T.MEMBERID;
3)
SELECT MEMBERID,MFIRST||' ' || MLAST "FULL NAME" ,STREET||'
'||CITY||' ' ||STATE||' '||ZIPCODE "ADSRESS"
FROM MEMBERS
WHERE CREDITLIMIT IN (SELECT MAX(CREDITLIMIT)
FROM MEMBERS);
4)
SELECT EFIRST|| ' '|| ELAST "FULL NAME", JOBTITLE,DEPARTMENT
FROM EMPLOYEES E, TRANSACTIONS T
WHERE E.EMPLOYEEID=T.EMPLOYEEID AND LOCATION='Online';
5)
SELECT MEMBERID,MFIRST||' ' || MLAST "FULL NAME" ,CREDITLIMIT
FROM MEMBERS
WHERE CREDITLIMIT > (SELECT AVG(CREDITLIMIT)
FROM
MEMBERS);
6)
SELECT T.MEMBERID,COUNT(*)
FROM Transactions T
WHERE MEMBERID IN(SELECT MEMBERID
FROM MEMBERS
WHERE MFIRST LIKE '%R%' OR MLAST LIKE '%R%')
GROUP BY T.MEMBERID;
7)
SELECT DISTINCT(M.MEMBERID),MFIRST||' ' || MLAST "FULL
NAME",STREET||' '||CITY||' ' ||STATE||' '||ZIPCODE "ADSRESS"
FROM MEMBERS M,Transactions T
WHERE M.MEMBERID=T.MEMBERID;
8)
SELECT EMPLOYEEID,COUNT(*)
FROM Transactions
WHERE Location='Online' or Location='IL Store' or Location='IN
Store'
group by employeeid;
9)
SELECT EFIRST||' ' || ELAST "FULL NAME" ,SALARY
FROM EMPLOYEES
WHERE SALARY > (SELECT AVG(SALARY)
FROM
EMPLOYEES);
10)
SELECT EMPLOYEEID,COUNT(*)
FROM Transactions
WHERE EMPLOYEEID IN(SELECT EMPLOYEEID
FROM EMPLOYEES
WHERE ETYPE='FullTime')
GROUP BY EmployeeID
ORDER BY COUNT(*) DESC;



Given (Oracle) SQL Script " CREATE TABLE Members( MemberID NUMBER(4) NOT NULL PRIMARY KEY, ...
SQL - create statement for query For each patient, display his or her last name, first name, and the name of his or her doctor. For each pediatrics patient, display his or her ID and his or her doctor's ID and name. For each doctor, display the name and the name of the doctor's supervisor in alphabetic order of supervisor's name. Include column aliases for clarity. Note: Check for accuracy. For each doctor in one of the two areas entered...
SQL: CREATE STATEMENT For patients whose last name matches the name entered by the user, display their first name, phone number, and doctor's name. Note: Try Davis. (TEXT FOR DATABASE BELOW) DROP TABLE PATIENT; DROP TABLE BILLING; DROP TABLE DOCTOR; CREATE TABLE DOCTOR( DOC_ID VARCHAR2(10) NOT NULL, DOC_NAME VARCHAR2(20), DATEHIRED DATE, SALPERMON NUMBER(8), AREA VARCHAR2(20), SUPERVISOR_ID NUMBER(8), CHGPERAPPT NUMBER(8), ANNUAL_BONUS NUMBER(8), PRIMARY KEY (DOC_ID) ); INSERT INTO DOCTOR VALUES('432', 'Harrison', to_date('05-DEC-1994','dd-mon-yyyy'), 12000, 'Pediatrics', 100, 75, 4500); INSERT INTO DOCTOR VALUES('509',...
Q2. Retrieve the names of all employees from the employee table to produce output on CSV format or delimited format with a common delimeter, rather than separete columns. Hint:Put the whole row into a string with a semicolon as the seperator(delimeter) between thecolumns: FORMAT:(fname;minit;lname) Example: EMPLOYEES -------------- James;E;Borg Frank;T;Wong Q3. Write a query to show the employees name from the employee table in this format: first letter of the first name, followed by a dot, a blank, and the full...
Provide the syntax answers for the following script, doesn't
matter what table or columns.
CREATE TABLE customer
(c_id NUMBER(5),
c_last VARCHAR2(30),
c_first VARCHAR2(30),
c_mi CHAR(1),
c_birthdate DATE,
c_address VARCHAR2(30),
c_city VARCHAR2(30),
c_state CHAR(2),
c_zip VARCHAR2(10),
c_dphone VARCHAR2(10),
c_ephone VARCHAR2(10),
c_userid VARCHAR2(50),
c_password VARCHAR2(15),
CONSTRAINT customer_c_id_pk PRIMARY KEY (c_id));
CREATE TABLE order_source
(os_id NUMBER(3),
os_desc VARCHAR2(30),
CONSTRAINT order_source_os_id_pk PRIMARY KEY(os_id));
CREATE TABLE orders
(o_id NUMBER(8),
o_date DATE,
o_methpmt VARCHAR2(10),
c_id NUMBER(5),
os_id NUMBER(3),
CONSTRAINT orders_o_id_pk PRIMARY KEY (o_id),
CONSTRAINT orders_c_id_fk FOREIGN...
Query #2: List the name of the project and total number of hours worked on by all the employees on this project, also report the number of employees working on each project. Database: //STEP #1: CREATE TABLE employee ( fname varchar(15) not null, minit varchar(1), lname varchar(15) not null, ssn char(9), bdate date, address varchar(50), sex char, salary decimal(10,2), Super_ssn char(9), dno char(4), primary key (ssn)); CREATE TABLE department ( dname varchar(25) not null, dnumber char(4), Mgr_ssn char(9) not null,...
I am using oracle sql developer to create some queries to generated reports and it is not working. I am not sure how to use count, group by, and order by. Help me fix my query and explain to me how you did, so can do it next time. Also, I have to convert this query to a stored procedure, so can you help me do it too? Here is my query: SELECT COUNT(GUEST.FIRSTNAME), GUEST.FIRSTNAME, GUEST.LASTNAME, GUEST.GUESTTYPE, RESERVATION.RESERVATIONDATE, GUEST.EMAIL, FROM...
I am using Oracle SQL and am new to it. I have seven tables, one
of them is a subtable of two of the others. I need to do the
following queries:
1. List all Patients
and what Bed they are assigned to
2. List all patients
who had Treatments and what Treatment they received
3. List all patients
who had tests and what Test they had
4. List the employees
(doctors, nurses, etc.) who assisted each patient.
5. List...
SQL
I have a database
CREATE TABLE vendor
( vid CHAR(2) NOT NULL,
vname VARCHAR(25) NOT NULL,
PRIMARY KEY (vid) );
CREATE TABLE category
( catid CHAR(2) NOT NULL,
catname VARCHAR(25) NOT NULL,
PRIMARY KEY (catid) );
CREATE TABLE product
( pid CHAR(3) NOT NULL,
pname VARCHAR(25) NOT NULL,
price NUMERIC (7,2) NOT NULL,
vid CHAR(2) NOT NULL,
categoryid CHAR(2) NOT NULL,
PRIMARY KEY (pid));
CREATE TABLE region
( rid CHAR NOT NULL,
rname VARCHAR(25) NOT NULL,
PRIMARY KEY (rid)...
oracle only
database:
DROP TABLE ORDERITEMS;
DROP TABLE Orders;
DROP TABLE BOOKAUTHOR;
DROP TABLE BOOKS;
DROP TABLE PROMOTION;
DROP TABLE AUTHOR;
DROP TABLE CUSTOMERS;
DROP TABLE PUBLISHER;
CREATE TABLE Customers
( Customer# NUMBER(4),
LastName VARCHAR2(10) NOT NULL,
FirstName VARCHAR2(10) NOT NULL,
Email VARCHAR(40),
Address VARCHAR2(20),
City VARCHAR2(12),
State VARCHAR2(2),
Zip VARCHAR2(5),
Referred NUMBER(4),
Region CHAR(2),
CONSTRAINT customers_customer#_pk PRIMARY KEY(customer#)
);
INSERT INTO CUSTOMERS
VALUES (1001, 'MORALES', 'BONITA', 'bomor@gmail.com', 'P.O.
BOX 651', 'EASTPOINT', 'FL', '32328', NULL, 'SE');
INSERT INTO CUSTOMERS
VALUES...
Assume the following employees.sql file: create table employees ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT NOT NULL, first_name VARCHAR(50), last_name VARCHAR(50), email VARCHAR(50), age INT, gender VARCHAR(50), company VARCHAR(50) ); insert into employees (id, first_name, last_name, email, age, gender, company) values (1, 'Nicolas', 'Skeates', 'nskeates0@zdnet.com', 50, 'Male', 'Kwinu'); insert into employees (id, first_name, last_name, email, age, gender, company) values (2, 'Valentijn', 'Digwood', 'vdigwood1@washingtonpost.com', 40, 'Male', 'Yabox'); insert into employees (id, first_name, last_name,...