Question

The Language Is SQL

13- List full details of agents with first names having exactly three or four letters sorted by the state attribute. 14- List

The language is SQL

Table: Agents New Record Delete Reco state agentNo Filter fName Filter IName Filter branchNo Filter salary Filter phone1 Filt

S Gayla Schnitzler 30000 08-NOV-1989 Alameda 94545 NULL B002 B002 NULL 410-234-2267 gschnitzler@g... annelle@yaho. Annelle 41Kimberlie Duenas B005 38400 26-JUN-1990 8100 Jackson... Hays Ellis 67601 785-629-8542 Detra Coyier B005 46200 06-FEB-1986 969Stephen Emigh B010 42000 44302 Twana Felger 97224 B010 B010 52200 33000 25-JAN-1955 27-MAR-1975 18-OCT-1964 08-SEP-1975 Bok S

0 0
Add a comment Improve this question Transcribed image text
Answer #1

13.

SELECT *fROM AGENTSTABLE WHERE LENGTH(FNAME)=3 OR LENGTH(FNAME)=4 ORDER BY STATE ;

//USE LENGTH() FUNCTION TO COUNT LENGTH OF FNAME

SQL> SELECT * FROM AGENTSTABLE WHERE LENGTH(FNAME) =3 OR LENGTH(FNAME=4 ORDER BY STATE ; AGENT FNAME LNAME ADDRESS CITY STATE

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'

SOL> select fname, 1name, address, city, state,branchNo, email from agentstable where branchNo=Bee5 and 2 substr(email,inst

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

SQL> select fname, lname, address, city, state, branchNo, email from agentstable where 2 substr(email, instr(email,.,1,1)+1

16.

select *From agentstable where email is null;

//IS NULL IS USED TO FIND NULL CONTAINIG ROWS

SQL> select *From agentstable where email is null; AGENT FNAME LNAME ADDRESS CITY STATE SALARY BRANCHNUMB EMAIL - -------- BO

17.

select count(agentNo) from agentstable;

//COUNT FUNCTION IS USED TO KEEP THE COUNT OF AGENTNO

SQL> select count(agentNo) from agentstable; COUNT (AGENTNO)

18.

select min(salary),avg(salary),max(salary) from agentstable;

//MIN(), MAX() AND AVG() RETURNS THE MINIMUM , MAXIMUM AND AVERAGE

SQL> select min(salary), avg(salary), max(salary) from agentstable; MIN( SALARY) AVG(SALARY) MAX( SALARY) 900 52971.4286 9900

19.

select count(agentNo),sum(salary) from agentstable where state='NEW YORK';

NOTE PLEASE USE 'NY' IN PLACE OF 'NEW YORK'

SQL> select count(agentid), sum( salary) from agentstable where state=NEW YORK; COUNT (AGENTID) SUM( SALARY) 1 40000

20.

select count(agentNo) from agentstable where email is null;

SQL> select count(agentNo) from agentstable where email is null; COUNT (AGENTNO)

21.

select count(agentNo) from agentstable where branchNo='B002' and salary>40000;
SQL> select count(agentNo) from agentstable where branchNo-B002 and salary>40000; COUNT (AGENTNO) 2

22.

select count(distinct(branchNo)) from agentstable;

//DISTINCT RETURNS THE UNIQUE VALUE

SQL> select count(distinct(branchNo)) from agentstable; COUNT(DISTINCT (BRANCHNO))

23.

select state,count(agentNo) from agentstable group by state order by state;

SQL> select state, count(agentNo) from agentstable group by state order by state; STATE COUNT (AGENTNO) BALTIMORE JHARKHAND J

24.

select branchNo,count(agentNo) from agentstable group by branchNo;

SQL> select branchNo, count(agentNo) from agentstable group by branchNo; BRANCHNO COUNT (AGENTNO) -------- B005 B002

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'

SOL> select branchNo,count (agentNo), avg(salary) from agentstable where state=NEW JERSEY or state-NEW YORK group by bran

26.

select branchNo,count(agentNo),avg(salary) from agentstable where state='NEW JERSEY' or state='NEW YORK' group by branchNo
having avg(salary)<34000;

select branchNo,count (agentNo), avg(salary) from agentstable where state-NEW JERSEY or state=NEW YORK group by branchNo

DON'T FORGET TO LIKE.

THANKS BY HEART.

Add a comment
Know the answer?
Add Answer to:
The Language Is SQL The language is SQL 13- List full details of agents with first...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need the answer to #2 listed above. This is the code I have come up...

    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...

    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...

    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...

    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...

    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...

    * 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 p...

    . 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;...

    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....

    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...

    -- 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...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT