Question

Consider the following three relations: TRAVEL_AGENT (name, age, salary) CUSTOMER (name, departure_city, destination, journey_class) TRANSACTION (number,...

Consider the following three relations:

TRAVEL_AGENT (name, age, salary)
CUSTOMER (name, departure_city, destination, journey_class)
TRANSACTION (number, cust_name, travel_agent_name, amount_paid)

Write SQL statements to answer the following questions.

1. Display the names and salaries of all travel agents who did not arrange journeys for customer “John Smith”, in ascending order of salary.

2. Display the names of travel agents who have five or more transactions.

3. Display the names of all travel agents who have arranged at least ten journeys to “Ottawa”.

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

1.

SQL query that retrieves the name and salary of Travel agents who did not arrage journey for John Smith

select tg.name,tg.salary from TRAVEL_AGENT tg, CUSTOMER c, TRANSACTION t where tg.name = t.travel_agent_name and t.cust_name = c.name and c.name not in ("John Smith") order by tg.salary ASC;

2.

SQL query that retrieves the names of travel agents who have five or more transactions.

select t.travel_agent_name from TRANSACTION t group by t.travel_agent_name HAVING COUNT(t.travel_agent_name) >= 5;

3.

SQL query that the names of all travel agents who have arranged at least ten journeys to “Ottawa”.

select t.travel_agent_name from TRANSACTION t,CUSTOMER c where (t.cust_name=c.name and c.destination = "Ottawa") group by t.travel_agent_name HAVING COUNT(t.travel_agent_name) >= 10;

Add a comment
Know the answer?
Add Answer to:
Consider the following three relations: TRAVEL_AGENT (name, age, salary) CUSTOMER (name, departure_city, destination, journey_class) TRANSACTION (number,...
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
  • Consider the following three relations: TRAVEL_AGENT (name, age, salary) CUSTOMER (name, departure_city, destination, journey_class) TRANSACTION (number,...

    Consider the following three relations: TRAVEL_AGENT (name, age, salary) CUSTOMER (name, departure_city, destination, journey_class) TRANSACTION (number, cust_name, travel_agent_name, amount_paid) Write SQL statements to answer the following questions. Compute the number of different customers who have a transaction. Display the name of the oldest travel agent. List the total number of transactions for each travel agent. Consider only those transactions where the amount paid exceeds 1 000.

  • 3. Consider the following relations: salesperson(emp#, name, age, salary); key is emp# order(order#, cust#, emp#, amount);...

    3. Consider the following relations: salesperson(emp#, name, age, salary); key is emp# order(order#, cust#, emp#, amount); key is order# customer(cust#, name, city, industry-type); key is cust# Show the SQL expressions for the following queries: a. Get all the information of customers who have placed at least one order b. Get all the information of customers who have placed more than one order. c. Get all the information of customers who have placed an order with the salesperson, Scott Tiger. d....

  • Consider the relational database schema for a company below. EMPLOYEE/NAME, SSN, BDATE, ADDRESS, SEX, SALARY, SUPERSSN,...

    Consider the relational database schema for a company below. EMPLOYEE/NAME, SSN, BDATE, ADDRESS, SEX, SALARY, SUPERSSN, DNA) TA DEPARTMENT(DNAME, DNUMBER. MESSINS, MGRSTARTDATE) DEPT_LOCATIONS(DNUMBER. DLOCATION PROJECT(PNAME, PNUMBER. PLOCATION, DNLIM) WORKS_ONCESSN.PNG, HOURS) DEPENDENTESSN, DEPENDENT-NAME, SEX, BDATE, RELATIONSHIP) Write SQL statements for the following queries: a) List the names of those employees who work in the "Production" department (6 marks). b) Find the maximum salary, minimum salary, and the average salary among employees who work for the "Production department (6 marks). Count the...

  • consider the following schema: Product(pid, name, type, manufacturer, price) key: pid Buys(cid, pid) key: cid and...

    consider the following schema: Product(pid, name, type, manufacturer, price) key: pid Buys(cid, pid) key: cid and pid together Customer(cid, cname, age, gender) key: cid 1) write the following query in relational algebra; find the names of all customers who have purchased all products manufactured by sears. 2)write the following in sql: find the names of all the customers who have not purchased the most expensive product. 3)write the following query in sql: find the best selling products (in terms of...

  • consider the following schema: Product(pid, name, type, manufacturer, price) key: pid Buys(cid, pid) key: cid and...

    consider the following schema: Product(pid, name, type, manufacturer, price) key: pid Buys(cid, pid) key: cid and pid together Customer(cid, cname, age, gender) key: cid 1) write the following query in relational algebra; find the names of all customers who have purchased all products manufactured by sears. 2)write the following in sql: find the names of all the customers who have not purchased the most expensive product. 3)write the following query in sql: find the best selling products (in terms of...

  • SQL Queries 1) Use the following relations to answer the problems below. Person(SSN, Age, Name) P...

    SQL Queries 1) Use the following relations to answer the problems below. Person(SSN, Age, Name) Professor(SSN, Rank, Specialty) GraduateStudent(SSN, DegreeProgram, AdvisorSSN, DepartmentNumber) Project Number, StartDate, EndDate, Budget, SponsorOrganizationName) DepartmentNumber, Name, Abbreviation, MainOffice, ChairmanSSN) WorksFor(ProfessorSSN, Department Number, TimePercentage) WorksOn(GraduateStudentSSN, ProjectNumber, SupervisingProfessorSSN) Retrieve the Name and Specialty of all Professors who do not supervise work projects. This solution must meet the following conditions: D a. Uses at most one inner joirn b. Uses at most one outer join cNo subqueries al d....

  • Consider the following relations: Patient (pid: integer, lname: string, fname: string, primary_did: integer, age: integer) Doctor...

    Consider the following relations: Patient (pid: integer, lname: string, fname: string, primary_did: integer, age: integer) Doctor (did: integer, lname: string, fname: string, deptid: integer, age: integer, salary: integer) Nurse (nid: integer, lname: string, fname: string, deptid: integer, rank: string, age: integer) Department (deptid: integer, name: string, budget: integer) Menu (menuid: integer, pid: integer, caloriecount: integer, saltlevel: integer, vegetarian: bit, diabetic: bit, nauseaSafe: bit, notes: string) Vaccination (vaccinationid: integer, pid: integer, vaccinationname: string, dategiven: date, dateexpires: date) Prescription (presid: integer, pid:integer,...

  • 31. (15 pts) Consider the following relations and relationship: Student (studentID, name, address, gender, major) Course...

    31. (15 pts) Consider the following relations and relationship: Student (studentID, name, address, gender, major) Course (courselD, title, hour, department) Enrollment (StudentID, courselD, date Write the SQL statements to perf orm the following operations: List all the students' information for those majoring in "Computer Science". (2 pts) List the majors, and the numbers of the students in every major. (2 pts) List the departments, and the total number of hours of the courses offered by every department. (2 pts) List...

  • The following ERD and two tables represent a partial model similar to what we used in...

    The following ERD and two tables represent a partial model similar to what we used in class. Answer all questions by writing SQL syntax to solve each. If a question requires more time, please move on to the next. Employee EmpNo (PK) Ename Job ManagerID HireDate Salary Commission DeptNo (FK) Department DeptNo Dname Location 10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON Department DeptNo (PK) Dname Location 1400 Employee Monthly EmpNo Ename Job ManagerID HireDate...

  • SQL Homework 1. For each reservation, list the reservation ID, trip ID, customer number, and customer...

    SQL Homework 1. For each reservation, list the reservation ID, trip ID, customer number, and customer last name. Order the results by customer last name. 2. For each reservation for customer Ryan Goff, list the reservation ID, trip ID, and number of persons. 3. List the trip name of each trip that has Miles Abrams as a guide. 4. List the trip name of each trip that has the type Biking and that has Rita Boyers as a guide. 5....

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