0% found this document useful (0 votes)
142 views4 pages

06 RIO ANSI SQL Clauses Hands-On Exercise 1

This document provides hands-on exercises to practice writing ANSI SQL queries using various clauses. It includes 5 problems to solve involving writing queries with GROUP BY, HAVING, ORDER BY clauses to retrieve and aggregate data from multiple tables, such as getting counts of records grouped by dates and ordering results. Sample solution queries are provided using joins, aggregation functions, and clauses to group, filter, and sort the records.

Uploaded by

sappa vinay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
142 views4 pages

06 RIO ANSI SQL Clauses Hands-On Exercise 1

This document provides hands-on exercises to practice writing ANSI SQL queries using various clauses. It includes 5 problems to solve involving writing queries with GROUP BY, HAVING, ORDER BY clauses to retrieve and aggregate data from multiple tables, such as getting counts of records grouped by dates and ordering results. Sample solution queries are provided using joins, aggregation functions, and clauses to group, filter, and sort the records.

Uploaded by

sappa vinay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Hands-on Exercise:

ANSI SQL Clauses


Version: ANSI SQL/Hands-on Exercise/04/1.0
Hands-on Exercise – ANSI SQL Operators - 04

Table of Contents
ANSI SQL 06: ANSI SQL CLAUSES.................................................................................3

Exercise.1......................................................................................................................3

Page 2
Page 2
Cognizant Technology Solutions, All Rights Reserved
C3: Protected
Hands-on Exercise – ANSI SQL Operators - 04

ANSI SQL 06: ANSI SQL Clauses


Pre-requisites: Tables should be created and data should be loaded into the tables.

Exercise.1
Estimated Completion Time: 60 Minutes Marks
: xx

Hands-on Exercise Objective


After completing the hands-on exercises, you will be able to:
Write queries using ANSI SQL Clauses.

Problem Statement:
Problem 1: Develop a SQL query which would retrieve the number of associates enrolled
for modules on a specific date grouped by start date and display start date and total
number of associates.

Problem 2: Develop a SQL query which would retrieve the number of associates enrolled
for modules where trainer id is ‘F001’ grouped by start date and display start date and total
number of associates.

Problem 3: Develop a SQL query which would retrieve the number of associates enrolled
for modules where trainer id is ‘F001’ grouped by module start date and display module
start date and total number of associates where the total number of associates > 2.

Problem 4: Develop a SQL query which displays all the modules in increasing order of
module duration.

Problem 5: Develop a SQL query which would retrieve and display the associates name,
their module enrolled (module name and module id), base fees. Display the records
ordering the base fees in descending order.

Deliverables Expected:
Solution Queries

1)select start_date,count(associate_id) from associate_status


group by start_date;
2)select start_date,count(associate_id) from associate_status
where trainer_id="F001"
group by start_date;
3)select start_date,count(associate_id) from associate_status
where trainer_id="F001"
group by start_date
having count(associate_id)>2;
4)select * from module_info
Page 3
Page 3
Cognizant Technology Solutions, All Rights Reserved
C3: Protected
Hands-on Exercise – ANSI SQL Operators - 04

order by module_duration;
5)select ar.associate_name,m.module_id,m.module_name,m.base_fees from
associate_status a inner join module_info m inner join associate_info ar
on a.module_id=m.module_id and
ar.associate_id=a.associate_id
order by base_fees desc;
Tips:
http://dev.mysql.com/doc/refman/5.0/en/group-by-functions-and-modifiers.html

http://dev.mysql.com/doc/refman/5.0/en/select.html

Page 4
Page 4
Cognizant Technology Solutions, All Rights Reserved
C3: Protected

You might also like