The Language Is SQL
The language is SQL
13.
SELECT *fROM AGENTSTABLE WHERE LENGTH(FNAME)=3 OR LENGTH(FNAME)=4 ORDER BY STATE ;
//USE LENGTH() FUNCTION TO COUNT LENGTH OF FNAME
14.
select fname,lname,address,city,state,branchNo,email from
agentstable where branchNo='B005' and
substr(email,instr(email,'@',1,1)+1)='YAHOO.COM';
HERE INSTR RETURNS THE NEXT POSITION OF @ WHICH IS PASSED IN SUBSTR TO SET THE STARTING CHARACTER OF SUBSTR WHICH MUST BE EQUAL TO 'YAHOO.COM'
15.
select fname,lname,address,city,state,branchNo,email from
agentstable where
substr(email,instr(email,'.',1,1)+1) not in('COM');
//NOT IN USED TO EXCLUDE COM EXTENSION
16.
select *From agentstable where email is null;
//IS NULL IS USED TO FIND NULL CONTAINIG ROWS
17.
select count(agentNo) from agentstable;
//COUNT FUNCTION IS USED TO KEEP THE COUNT OF AGENTNO
18.
select min(salary),avg(salary),max(salary) from agentstable;
//MIN(), MAX() AND AVG() RETURNS THE MINIMUM , MAXIMUM AND AVERAGE
19.
select count(agentNo),sum(salary) from agentstable where state='NEW YORK';
NOTE PLEASE USE 'NY' IN PLACE OF 'NEW YORK'
20.
select count(agentNo) from agentstable where email is null;
21.
select count(agentNo) from agentstable where branchNo='B002' and
salary>40000;
22.
select count(distinct(branchNo)) from agentstable;
//DISTINCT RETURNS THE UNIQUE VALUE
23.
select state,count(agentNo) from agentstable group by state order by state;
24.
select branchNo,count(agentNo) from agentstable group by
branchNo;
25.
select branchNo,count(agentNo),avg(salary) from agentstable where state='NEW JERSEY' or state='NEW YORK' group by branchNo;
NOTE PLEASE USE 'NJ' IN PLACE OF 'NEW JERSEY' AND 'NY' IN PLACE OF 'NEW YORK'
26.
select branchNo,count(agentNo),avg(salary) from agentstable
where state='NEW JERSEY' or state='NEW YORK' group by
branchNo
having avg(salary)<34000;
DON'T FORGET TO LIKE.
THANKS BY HEART.
The Language Is SQL The language is SQL 13- List full details of agents with first...
I need the answer to #2 listed above. This is the code I have come up with, and it is wrong. I am new to this and need help. group by sust.cida Q2 (7 Points) Show customer id (CID) for customers who have spent 30,000 or more with the company in 2019. Money is considered "spent" when the entire work order is completed as recorded in workorder.completionDate. (Correct query will find customer 2). Use ONE SQL statement. select workarder.id from...
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...
Assignment Chapter 6 Part - Assignment Chapter 6 Part 2 - Write Queries that: 1. List all Staff first and last names that have a branch number listed the Branch table. 2. Sort the query results from the query above is descending order 3. Join Branch and Staff tables where branch No are equal 4. Execute Left Outer Join for query 3 5. Execute Right Outer Join for query 3. 6. Insert record - 'CR76', 'PL94', '2018-02-28', 'To Big' into...
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',...
Oracle 12c SQL Chapter 12 Determine which orders were shipped to the same state as order 1014. CREATE TABLE Orders (Order# NUMBER(4), Customer# NUMBER(4), OrderDate DATE NOT NULL, ShipDate DATE, ShipStreet VARCHAR2(18), ShipCity VARCHAR2(15), ShipState VARCHAR2(2), ShipZip VARCHAR2(5), ShipCost NUMBER(4,2), CONSTRAINT orders_order#_pk PRIMARY KEY(order#), CONSTRAINT orders_customer#_fk FOREIGN KEY (customer#) REFERENCES customers(customer#)); INSERT INTO ORDERS VALUES (1000,1005,TO_DATE('31-MAR-09','DD-MON-YY'),TO_DATE('02-APR-09','DD-MON-YY'),'1201 ORANGE AVE', 'SEATTLE', 'WA', '98114' , 2.00); INSERT INTO ORDERS VALUES (1001,1010,TO_DATE('31-MAR-09','DD-MON-YY'),TO_DATE('01-APR-09','DD-MON-YY'), '114 EAST SAVANNAH', 'ATLANTA', 'GA', '30314', 3.00); INSERT INTO ORDERS VALUES (1002,1011,TO_DATE('31-MAR-09','DD-MON-YY'),TO_DATE('01-APR-09','DD-MON-YY'),'58...
* myCompany.SQL Introduction to SQL Script file for ORACLE DBMS This script file creates the following tables: VENDOR, PRODUCT, CUSTOMER, INVOICE, LINE EMPLOYEE and loads the default data rows */ set echo on; set serveroutput on; select systimestamp from dual; show user; ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY'; DROP TABLE LINE CASCADE CONSTRAINTS; DROP TABLE INVOICE CASCADE CONSTRAINTS; DROP TABLE CUSTOMER CASCADE CONSTRAINTS; DROP TABLE PRODUCT CASCADE CONSTRAINTS; DROP TABLE VENDOR CASCADE CONSTRAINTS; DROP TABLE EMPLOYEE CASCADE CONSTRAINTS; CREATE TABLE...
. An Excel spreadsheet containing data tables is available 2. All data in this problem set are fictitious. 3. Please round the number of required workers/agents up to the next highest integer in all problems. Problem 1 PrintEverything is a leading 3D-printer manufacturer. Their products are quite popular recently. The following table provides the demand forecast for their most popular 3D-printer. Month Demand Forecast (Number of 3D-Printers) OCT-15 5760 NOV-15 3697 DEC-15 5587 JAN-16 4815 FEB-16 6325 MAR-16 6145 APR-16...
I need help for SQL homework. the question: the code for part 1,2: drop table Customer; drop table Company; drop table Cruise; drop table TravelAgent; drop table Reservation; drop sequence customerID_seq; drop sequence cruiseID_seq; drop sequence travelAgentID_seq; drop sequence reservationID_seq; create table Customer( customerID number, firstName varchar2(15), lastName varchar2(15), address varchar2(30), phone number(10) not null, age number(3), Constraint Customer_PK Primary Key (customerID), constraint Customer_unique unique (firstName,lastName,phone), constraint Customer_check check(phone is not null) ); create sequence customerID_seq start with 1 increment...
Using SQL, carry out the various DML and DDL functions on the tables mentioned below: 1. Insert the data given above in both employee, department and project tables. 2. Display all the employees’ information. 3. Display Employee name along with his SSN and Supervisor SSN. 4. Display the employee names whose bdate is ’29-MAR-1959’. 5. Display salary of the employees without duplications. 6. Display the MgrSSN, MgrStartDate of the manager of ‘Finance’ department. 7. Modify the department number of an...
-- echo Building demo tables. Please wait. DROP TABLE EMP CASCADE CONSTRAINTS; DROP TABLE DEPT; DROP TABLE SALGRADE; DROP TABLE Prod CASCADE CONSTRAINTS; DROP TABLE Vend; CREATE TABLE DEPT ( DEPTNO NUMBER(2) NOT NULL, DNAME CHAR(14), LOC CHAR(13), CONSTRAINT DEPT_PRIMARY_KEY PRIMARY KEY (DEPTNO)); INSERT INTO DEPT VALUES (10,'ACCOUNTING','NEW YORK'); INSERT INTO DEPT VALUES (20,'RESEARCH','DALLAS'); INSERT INTO DEPT VALUES (30,'SALES','CHICAGO'); INSERT INTO DEPT VALUES (40,'OPERATIONS','BOSTON'); CREATE TABLE EMP ( EMPNO NUMBER(4) NOT NULL, ENAME CHAR(10), JOB CHAR(9), MGR NUMBER(4) CONSTRAINT EMP_SELF_KEY...