StudentShare solutions
Triangle menu

SQL Queries - Essay Example

Nobody downloaded yet

Extract of sample
SQL Queries

I have added a sub query in WHERE clause to filter those students who have no placement.

List the names and student ids for students who have gained employment with the company that they undertook a placement at.

SELECT DISTINCT Student.stu_fname, Student.stu_no
FROM Employment, Student, Placement
WHERE Student.stu_no=Employment.stu_no And Student.stu_no=Placement.stu_no And Placement.co_id=Employment.co_id;

In this query I have selected Employment, Student, Placement tables and have joined them. In addition to that, I have also patched Company ID of Placement with Employment table as well.

List the names and student ids for students that have undertaken precisely two (2) placements.

SELECT DISTINCT Student.stu_fname, Student.stu_no
FROM Student
WHERE (( SELECT count(*) FROM Placement WHERE
(Student.stu_no=Placement.stu_no) ) >= 2 );

I have added a sub query in WHERE clause to filter those students who have at least two placements.

List the names and student ids for all students and sort the list in reversed alphabetical order (Z to A).

SELECT DISTINCT Student.stu_fname, Student.stu_no
FROM Student
ORDER BY Student.stu_fname DESC;

In this query I have added ORDER BY clause to sort data in Descending order.

Show the average length for placements, where the placement is with Sony and the student goes on to gain employment (with any company).

SELECT Company.co_name, avg(SELECT count(*) FROM Placement, Student, Employment WHERE Placement.co_id=Company.co_id and student.stu_no=Employment.stu_no And student.stu_no=Placement.stu_no )
FROM company
GROUP BY Company.co_name, Company.co_id
HAVING Company.co_name='Sony';

First I have selected the Average number of placements...
In a correctly implemented database a student may not be employed and on a placement at the same point in time. However in such a database it is still possible for a student to secure employment before they have completed their placement (i.e. having a starting date for employment while still on placement). Create a query that lists all such occurrences. ...Show more


WHERE Company.co_id=Representative.co_id And Representative.rep_id=Rep_attendance.rep_id And Event.ev_id=Rep_attendance.ev_id And Event.ev_id=Student_attendance.ev_id And Student_attendance.stu_no=Student.stu_no And Representative.rep_id=Rep_attendance.rep_id And Event.ev_id=Rep_attendance.ev_id And Company.co_name='Perception';
Author : edison29
SQL Queries essay example
Read Text Preview
Save Your Time for More Important Things
Let us write or edit the essay on your topic
"SQL Queries"
with a personal 20% discount.
Grab the best paper

Check these samples - they also fit your topic

Lanchester Liners Hospitality Database, SQL
5 pages (1250 words) Essay
Some of these include flat databases and a relational databases. A flat database contains only one table. A database which contains one or several related tables is referred to as a relational database (Harrington, 2002). In a relational database, symbols are organized into a collection of relations.
4 pages (1000 words) Essay
Database Architecture and Administration
While databases have been used since the beginning of electronic computing, the earliest databases were custom made for organizations, difficult to operate and extremely inefficient. These file-based systems needed specific, custom-built programs to access and manage it. Since each file was isolated from others, it often resulted in redundancy and duplication of data.
10 pages (2500 words) Essay
This a DATABASE I.T assignment - EE-R Diagram, EE-R Model with 3NF relations and SQL statments
The symbol – “O” represents the overlapping nature of the relation. It also contemplates the fact that there can be an entity overlapping in both the sections, Elite and Sessional. The relationship “arranged” between the entities Elite Musician and Song is N
6 pages (1500 words) Essay
Data Analysis
Every product has only one product category, therefore the association between the Product class and Product category class is one to one, i.e. one product have only one category. One customer can place one or more order,
10 pages (2500 words) Essay
Modern Database Managment Assignment Three
The relational model employs a set of tables/relations to demonstrate both data as well as the associations between those data. In addition, each table contains numerous columns and each column has a unique name. Moreover, each
3 pages (750 words) Essay
Information Systems
Following are the basic requirements of the proposed CDMS; CDMS is the hub of activities for the business. These activities are broad based and extend all over the business domain. The Chief Executive has to have a good idea of the all the business activities. He
6 pages (1500 words) Essay
Database, SQL
The primary function of a database is not only to store and retrieve data but also to efficiently handle concurrent request for data from
5 pages (1250 words) Essay
Database Administration -2
The following list provides all the required skills of the database administrator for information system database of large organizations (Kioskea,
4 pages (1000 words) Essay
Advance Database
This aim of this report is to give a detailed description of the design for a relational database specifically proposed to fulfil the TFR data needs. The relational database system will enable TFR to
4 pages (1000 words) Essay
Hire a pro to write
a paper under your requirements!
Win a special DISCOUNT!
Put in your e-mail and click the button with your lucky finger
Your email
Comments (0)
Click to create a comment
Contact Us