Question
pls help me with these SQL questions

Task 10 (4 marks) Write an SQL statement to display fan categories, the number of tickets in each category the fan bought (change the alias to NUMBER OF TICKETS PURCHASED) along with the sum of prices (change the alias to TOTAL PRICES) in each category the fans paid. Sort the result by total price in an ascending order. Task 11 (5 marks) Write an SQL statement to display match ID and the count of tickets sold for each match ONLY if the number of tickets sold of this match is more than 1 and the open year of the stadium on which the match will be played is not 2013. Task 12 (5 marks) Write an SQL statement to display the stadium name and the number of matches played in each stadium (change the alias to NUMBER OF MATCHES). Display only the top two stadiums where most matches were held. Sort the result by the number of matches played on each stadium in a descending order. NOTE: Do Not use a static (fixed) value to determine the largest number of matches] Task 13 (5 marks) Write an SQL statement to display team name and its manager if Croatia is one of the teams in any match (either as a first or a second team). Managers name should be displayed as initialisation of first name followed by a dot and then the last name. The alias of the manager column should be changed to Manager Initials. For example, if managers name is David Smith, it will be displayed as D. Smith

media%2F077%2F077d1874-bf7f-48fc-96b8-7f
Here are tables

media%2Fd37%2Fd37f5a1c-7f57-471b-a973-84
media%2F662%2F66293ad5-e633-49ab-97e2-6f
TEAM table
media%2F84b%2F84b2bda0-3e9c-47ec-9e81-53

media%2F903%2F9035e363-3b2c-43ca-bb99-0b
0 0
Add a comment Improve this question Transcribed image text
Answer #1

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;

Add a comment
Know the answer?
Add Answer to:
pls help me with these SQL questions Here are tables TEAM table Task 10 (4 marks)...
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
  • database and sql problme THE QUESTIONS 3, 4,5 and 6 REFER TO THE RELATIONAL TABLES LISTED...

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

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

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

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

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

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

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