Informatics Practices

Consider the following tables:

Table 1:

ATHLETE, which stores AthleteID, Name, Country. The table displays basic information of the athletes.

Table 2:

MEDALS, which stores AthleteID, Sport, and Medals. The table displays the number of medals won by each athlete in their respective sports.

Table: ATHLETE

AthleteIDNameCOUNTRY
101ArjunINDIA
102PriyaINDIA
103AsifUAE
104RozyUSA
105DavidDENMARK

Table: MEDALS

AthleteIDSportMedals
101Swimming8
102Track3
103Gymnastics5
104Swimming2
105Track6

Write appropriate SQL queries for the following:

I. Display the sports-wise total number of medals won.

II. Display the names of all the Indian athletes in uppercase.

III. Display the athlete name along with their corresponding sports

SQL Joins & Grouping

3 Likes

Answer

I.

SELECT Sport, SUM(Medals) 
FROM MEDALS 
GROUP BY Sport;

II.

SELECT UPPER(Name) 
FROM ATHLETE 
WHERE Country = 'INDIA'; 

III.

SELECT Name, Sport 
FROM ATHLETE A, MEDALS M 
WHERE A.AthleteID= M.AthleteID; 

Answered By

2 Likes


Related Questions