Task 10- Aggregate function COUNT() and SUM() are used along with group by clause to get the result. ORDER BY is used to display the result in ascending order.
SELECT f.FANCATEGORY,COUNT(t.TICKETID) AS "NUMBER OF TICKET
PURCHASED",
SUM(t.PRICE) AS "TOTAL PRICES"
FROM FAN AS f
INNER JOIN TICKET AS t
ON f.FANID = t.FANID
GROUP BY f.FANCATEGORY
ORDER BY "TOTAL PRICES" ASC;
Task 11- Aggregate function COUNT() is used with group by clause. HAVIN is used to filter the result for greater than 1 count of ticket
SELECT t.MATCHID, COUNT(t.TICKETID)
FROM TICKET AS t
INNER JOIN MATCHES AS m
m.MATCHID = t.MATCHID
WHERE YEAR(m.MATCHID) <> '2013'
GROUP BY t.MATCHID
HAVING COUNT(t.TICKETID) > 1;
Task 12- Aggragate function COUNT() is used to get the result. LIMIT is used to limit the result to top two rows.
SELECT s.STADIUMNAME, COUNT(m.MATCHID) AS "NUMBER OF
MATCHES"
FROM STADIUM AS s
INNER JOIN MATCHES AS m
ON m.STADIUMID = s.STADIUMID
GROUP BY s.STADIUMNAME
ORDER BY "NUMBER OF MATCHES" DESC
LIMIT 2;
Task 13- Subquery is used to get the result. String function LEFT() and CONCAT() is used to display the manager name in a specified way.
SELECT m.FIRSTTEAM, (SELECT COUNTRY, CONCAT(LEFT(MANAGER, 1), ".
",RIGHT(MANAGER, charindex(' ', MANAGER)-1) FROM TEAMS WHERE TEAMID
= m.FIRSTTEAM),
m.SECONDTEAM, (SELECT COUNTRY, CONCAT(LEFT(MANAGER, 1), ".
",RIGHT(MANAGER, charindex(' ', MANAGER)-1) FROM TEAMS WHERE TEAMID
= m.SECONDTEAM)
FROM MATCHES;
pls help me with these SQL questions Here are tables TEAM table Task 10 (4 marks)...
database and sql problme THE QUESTIONS 3, 4,5 and 6 REFER TO THE RELATIONAL TABLES LISTED BELOW CREATE TABLE Department ( DECIMAL(5) VARCHAR(30) CHAR(5) DATE NOT NULL NOT NULL NOT NULL * Department number /*Department name * Department manager number */ /Manager start date DNumber DName Manager MSDate CONSTRAINT Department_PK PRIMARY KEY(DNumber) CONSTRAINT Department_CK UNIQUE(DName) CREATE TABLE DeptLocation DECIMAL(5) VARCHAR(50) NOT NULL NOT NULL DNumber * Department number */ * Department location */ Address CONSTRAINT DeptLocation_PK PRIMARY KEY(DNumber, Address) CONSTRAINT...
Please help me on the SQL queries, thank you so much. Write a query to display the title and publisher as well as the publisher contact for each book using JOIN...USING clause. Write a query to show the first and last names of customers who have ordered cooking books. Use the WHERE clause to join the tables. Write a query to show the title, cost and ISBN of each book in the books table. If the book has been ordered,...
If possible please just send the SQL statement. Thank you Each question within deliverable 3 must begin on a new page and be sure to document the question as the title of each item at the top of each page. Also, using a 12-point font, include the SQL statement and then provide a screen shot of each query. The screen shots must include both the SQL statement and the results for each item below based on the data entered in...
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...
In Java Burdell and the Buzz Problem Description As an aspiring band manager, you need to promote your band and expand publicity. Being hip with the times, you know that social media can make or break a band’s popularity. So, you decide to bring some ‘lucky’ Georgia Tech students to spread the good word! Solution Description Write the Concert, Musician, and Fan classes to guide your band on their rock star journey. You will design these classes from scratch following...
The lab for this week addresses taking a logical database design (data model) and transforming it into a physical model (tables, constraints, and relationships). As part of the lab, you will need to download the zip file titled CIS336Lab3Files from Doc Sharing. This zip file contains the ERD, Data Dictionary, and test data for the tables you create as you complete this exercise. Your job will be to use the ERD Diagram found below as a guide to define the...