PubOps - Initial Assessment

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

PubOps - Initial Assessment

1. Provide your name and email-id *

Raghavendra K
Email: raghavendrak@aol.in

2. Consider the below table:

Salaries: Contains the employee's name and employee's annual salary. 

Using the table you have to find the average monthly salary and maximum monthly salary of the
employees with first letter of their names equal to A.

NOTE: Average monthly salary and Maximum monthly salary are guaranteed to be integers.

Input Format:

Table : Salaries

Field - Type

Name - string

Salary - integer

Output Format:

Field - Type

Average - integer

Maximum - integer

Sample Input:

Sample Salaries Table:

Name - Salary

Akash- 360000

Saurabh - 240000

Shubham - 120000

Anand - 240000

Pratek - 480000

Sample Output:

Average - Maximum

300000 - 360000

select avg(Salary/12) , max(Salary/12) from Salaries where Name like 'A%';

3. You are given data of few cricket players in a table. 

Table Description: 

Table Name: Match_data

Table Columns: match_id,name,batting_status 

match_id: Id of the match for which batting_status of the player is given.

name: Name of the player.

batting_status: Batting status of the player for particular match_id. Batting status can only hold
two values: 1 or 0. 1 means player has got out in the match, 0 means player was not out in the
match. 

You have to output a table consisting of name of each player and number of matches in which
the player remained not out (that is, count of match_id for which batting_status for that player is
0).

The output table should be sorted in increasing order of names. 

Input Format:

Table : Match_data

Field - Type

match_id - integer

name - string

batting_status - integer

Output Format:

Field - Type

name - string

not_out_count - integer

Sample Input:

Sample Match_data Table:

match_id - name - batting_status

20 - Dhawan - 0

65 - Rohit - 0

43 - Dhawan - 1

77 - Dhawan - 1

101 - Rohit - 0

Sample Output:

name - not_out_count

Dhawan - 1

Rohit - 2

Explanation: 

Rohit has two entries of 0 for him, so not_out_count for him is 2.

Similarly, Dhawan has not_out_count as 1.

SELECT Name, COUNT(g.matchid)


FROM Match_data g, Match_datap
WHERE g.matchid=p.matchid

GROUP BY g.matchid

HAVING COUNT(g.matchid) > 1

ORDER BY g.batting_status DESC

4. You are analyzing the data of hackathons conducted on HackerEarth. You are given three tables:

Tag_info,Event_themes,Event_tags. 

Table Description: 

Table Name: Tag_info

Table Columns: tag_id,tag_title

tag_id: Unique id of each tag.

tag_title: Unique title of each tag. 

Table Name: Event_themes

Table Columns: event_id, theme_title

event_id: Id of the event.

theme_title: Theme name. 

Table Name: Event_tags

Table Columns: event_id,id

event_id: Id of the event.

id: Id of the tag. 

You have to output a table consisting of event_id,all tag names used in the event separated
by '#' (the tag whose id is less should come first), all theme names used in the event separated
by '#'(the theme names should be sorted alphabetically in increasing order). The table should be
sorted in increasing order of event_id.

Input Format:

Table : Tag_info

Field - Type

tag_id - integer

tag_title - string

Table : Event_themes

Field - Type

event_id - integer

theme_title - string

Table : Event_tags

Field - Type

event_id - integer

id - integer

Output Format:

Field - Type

event_id - int

tag_names - string

theme_names - string

Sample Input:

Sample Tag_info Table:

tag_id - tag_title

20 - Modelling

44 - Advertising

53 - Agriculture

Sample Event_themes Table:

event_id - theme_title

1 - Productivity

2 - Banking

1 - Fun

Sample Event_tags Table:

event_id - id

1 - 20

1 - 53

2 - 44

1 - 44

2 - 20

Sample Output:

event_id - tag_names - theme_names

1 - Modelling#Advertising#Agriculture - Fun#Productivity

2 - Modelling#Advertising - Banking

Explanation: 

Event with event_id 1 has all three tags, the tags in output table are ordered by their ids.
SImilarly, theme_names are ordered in alphabetically increasing order in the output table. The
ne
output table is sorted in increasing order of event_id.

SELECT C.EVENT_ID,
LISTAGG(A.TAG_TITLE,
'#'),
This content is created by the owner of the form. The data you submit will be sent to the form owner. Microsoft is not responsible for the
privacy or security practices of its customers, including those of this form owner. Never give out your password.

Powered by Microsoft Forms | Privacy and cookies | Terms of use

LISTAGG(B.THEME_TITL
E, '#') WITHIN GROUP
(ORDER BY
C.EVENT_ID)
FROM TAG_INFO A,
EVENT_THEMES B,
EVENT_TAGS C
WHERE
B.EVENT_ID=C.EVENT_I
D

You might also like