0% found this document useful (0 votes)
18 views

DBMS Microproject

This document discusses SQL clauses like SELECT, WHERE, HAVING, GROUP BY and ORDER BY. It explains how to use these clauses to retrieve specific data from database tables using queries and provides examples of queries using each clause.

Uploaded by

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

DBMS Microproject

This document discusses SQL clauses like SELECT, WHERE, HAVING, GROUP BY and ORDER BY. It explains how to use these clauses to retrieve specific data from database tables using queries and provides examples of queries using each clause.

Uploaded by

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

PART A: Micro project proposal

Execute Queries Using SELECT Command With WHERE, HAVING


Clause, GROUP by Clause and ORDER by Clause

1.0 Rationale

Database Management Systems (DBMS) are vital components of modern information systems.
Database applications are pervasive and range in size from small in-memory databases to terra bytes
or even larger in various applications domains. The course focuses on the fundamentals of
knowledgebase and relational database management systems, and the current developments in
database theory and their practice.

2.0 Course Outcomes Addressed

A) Create and Manage Database using SQL.

B) Design Normalized database on given data.

C) Create and manage Data base using SQL command.

D) Write a SQL command using Group by, Queries having, and Order by clause given data base.

E) Apply security and confidentiality on given database.

3.0 Literature Review

To satisfy the needs of users outside of business applications, DBMS must be expanded to offer
services in two other dimensions, namely object management and knowledge management. Object
management entails efficiently storing and manipulating non-traditional data types such as bitmaps,
icons, text, and polygons. Object management problems abound in CAD and many other engineering
applications. Knowledge management entails the ability to store and enforce a collection of rules
that are part of the semantics of an application. Such rules describe integrity constraints about the
application, as well as allowing the derivation of data that is not directly stored in the database.
1

4.0 Resources required


Page

Sr.No Name of resources Specification Quantity Remark


1. Computer 4GB RAM with 32bit 1 Used

1
OS windows 7
2. Software Oracle 10g 1 Used

3. Printer HP Deskjet P2 6200 1 Used

5.0 Proposed Methodology

Clauses in SQL are similar to conditionals in high-level languages.SQL being a query language
requires a method to apply constraints on the data and for this we use Clauses. We have a large
variety in the SQL clauses like the Where clause, Group By clause, Order By clause etc.

Sr.no Details of activity Planned Planned Name of


started finish Responsible team
date date members.

1. Search the project Yashodhan N


Jagtap

2. To select the title Rushikesh M Patil


project

3. Collect the Ashwed A


information about Arabhavi
project

4. Run queries and Sanket S


insert the output Wadagule

5. Then show the soft Aditya S Benade


copy of project
report to the
subject teacher and
correct the
correction
2 Page

2
Part B-Micro project report

Execute Queries Using SELECT Command With WHERE, HAVING


Clause, GROUP by Clause and ORDER by Clause

1.0 Rationale

Database Management Systems (DBMS) are vital components of modern information systems.
Database applications are pervasive and range in size from small in-memory databases to terra bytes
or even larger in various applications domains. The course focuses on the fundamentals of
knowledgebase and relational database management systems, and the current developments in
database theory and their practice.

2.0 Aim Micro-project Creating

Creating database with two tables holding specific data in its tuples. Executing queries with the use
of select command with WHERE, HAVING, GROUP BY, ORDER BY Clauses to get desired
output through certain condition.

3.0 Course Outcomes Addressed

A) Create and Manage Database using SQL.

B) Design Normalized database on given data.

C) Create and manage Data base using SQL command.

D) Write a SQL command using Group by, Queries having, and Order by clause given data base.

E) Apply security and confidentiality on given database.

4.1 Literature Review

To satisfy the needs of users outside of business applications, DBMS must be expanded to offer
services in two other dimensions, namely object management and knowledge management. Object
management entails efficiently storing and manipulating non-traditional data types such as bitmaps,
icons, text, and polygons. Object management problems abound in CAD and many other engineering
3

applications. Knowledge management entails the ability to store and enforce a collection of rules
Page

that are part of the semantics of an application. Such rules describe integrity constraints about the
application, as well as allowing the derivation of data that is not directly stored in the database.

3
4.2 SELECT COMMAND -

4.3 WHERE CLAUSE –

4.4 HAVING CLAUSE -

4.5 GROUP BY CLAUSE -

4.6 ORDER BY CLAUSE -

4.2 SELECT COMMAND –

Select command is used to fetch the data in a set of records from a table, view or a group of tables,
views by making use of SQL joins. A SELECT COMMAND statement retrieves zero or more rows
from one or more database tables or database views. In most applications, SELECT is the most
commonly used data query language (DQL) command. As SQL is a declarative programming
language, SELECT queries specify a result set, but do not specify how to calculate it. The database
translates the query into a "query plan" which may vary between executions, database versions and
database software. This functionality is called the "query optimizer" as it is responsible for finding
the best possible execution plan for the query, within applicable constraints.

Retrieval of data using SQL statements can be done by using different predicates like −

 Where
 Group By
 Having
 Order By
Syntax of select command
 Selecting specific column from the table syntax

Select column 1, column 2 ... Column N From table_name;

 Selecting whole table syntax as follows


Select table table_name ;

Example of select command as follows


 Selecting specific columns from table
4 Page

Select emp_id , emp_name , emp_city from employee_details;


 Selecting whole table
Select table employee_details;

4
4.3 WHERE CLAUSE –

A WHERE clause in SQL specifies that a SQL Data Manipulation Language (DML) statement
should only affect rows that meet specified criteria. The criteria are expressed in the form of
predicates. Where clauses are not mandatory clauses of SQL DML statements, but can be used to
limit the number of rows affected by a SQL DML statement or returned by a query. In brief SQL
WHERE clause is used to extract only those results from a SQL statement, such as: SELECT,
INSERT, UPDATE, or DELETE statement. The WHERE clause is used in conjunction with SQL
DML statements.

 Syntax ---

Select * or column1, column2, ………… from {table_name} where condition;

 Example = SELECT * FROM Customer WHERE customer_id = 101;

4.4 HAVING CLAUSE -

A HAVING clause in SQL specifies that an SQL SELECT statement should only return rows where
aggregate values meet the specified conditions. It was added to the SQL language because the
WHERE keyword could not be used with aggregate functions.
The HAVING clause filters the data on the group row but not on the individual row. To view the
present condition formed by the GROUP BY clause, the HAVING clause is used.
 Syntax:

SELECT column_name(s) ,aggregate function FROM {table_name} WHERE condition


GROUP BY column_name(s) HAVING (condition) ;

 Example:
SELECT deptid, SUM(saleamount) FROM Sales WHERE salenumber = 8872 GROUP BY deptid
HAVING SUM(saleamount) > 1000;

4.5 GROUP BY CLAUSE –

The GROUP BY statement groups rows that have the same values into summary rows like "find the
number of customers in each country".
5 Page

The GROUP BY statement is often used with aggregate functions


COUNT(), MAX(), MIN(), SUM(), AVG() to group the result-set by one or more columns.

 GROUP BY Syntax

5
SELECT column_name(s)FROM table_namewhere

Condition GROUP BY column_name(s);

 Example

select count ( Customer _ ID ) , Country


FROM Customer GROUP BY Country;

4.6 ORDER BY CLAUSE –

Order by command is used to sort the result set in ascending or descending order.The order
by command sorts the result set in ascending order by default. To sort the records in descending
order, use the desc keyword .ASC command is used to sort the data returned in ascending order.
DESC command is used to sort the data returned in descending order.

 Syntax ---SELECT * FROM table_name ORDER BY column_Name asc /dcs;

 Example ---- SELECT * FROM Customer ORDER BY customer_name asc;

5.0 Actual Procedure Followed

1. Designed plans through which we can get ideology of executing queries.

2. Created two tables using dml commands.

3. Inserted values into those two tables.

4. Displayed the tables with their records with select command.

5. Executed queries by using where , having group by , order by clause with the help of select
command to tackle and get output according to the conditions.

6. Tested the queries 4-5 times before the final confirmation.

7. Attached the output of project at the end.


6 Page

8. Finalized report.

6
6.0 Resources Required

Sr. Name of Specifications Qty Remarks


No Resource/material
1 Computer 4.00 GB RAM 1 _
with 32 bit OS
windows 7
2 Software Oracle 11g SQL 1 _

3 Printer HP Deskjet P2 1 _
6200 printer
7.0 Skill
Developed / Learning Out Of This Micro-Project

The project can be used in many aspects where there is a need of the database to store the records of
specific things be it a school, university or office. It can also be used in storing data of any sport
player, game’s statistics and many other things. Secondly the queries can be used to learn DBMS
more clearly and its various features.

8.0 Outputs of the Micro-Projects

 QUERY:

Creating two tables : EMPLOYEE and DEPARTMENT

1. Create table EMPLOYEE (empno int primary key, empname varchar2(40), salary int);

2. Create table DEPARTMENT (deptname varchar2(40), deptid int, empno int,foreign key(empno)
references emp11);

 Inserting values or records in two tables

a. Inserting for EMPLOYEE :

insert into EMPLOYEE values (101,'diksha patil',60000);


7 Page

insert into EMPLOYEE values (102,'sushant chougule',70000);

insert into EMPLOYEE values (103,'varsha mane',80000);

insert into EMPLOYEE values (104,'sanika patil',50000);

7
insert into EMPLOYEE values (105,'shreyash jadhav',40000);

b. Inserting for DEPARTMENT

insert into DEPARTMENT values('sales',1,101);

insert into DEPARTMENT values('sales',2,102);

insert into DEPARTMENT values('production',3,103);

insert into DEPARTMENT values('banking',4,104);

insert into DEPARTMENT values('production',5,105);

 Displaying the table with its attributes and records

a. Displaying EMPLOYEE: Select * from EMPLOYEE;

b. Displaying DEPARTMENT: Select * from DEPARTMENT;

 Executing Queries Using Where, Having Clause, Group by Clause and Order by Clause

select empname, salary, deptid from employee e, department d


8 Page

where e. empno =d.empno group by empname , salary , deptid

having salary >= 50000 order by deptid;

8
9.0 Conclusion

With the help of clauses we have learnt that, we can deal with data easily stored in the table. Clauses
help us filter and analyze data quickly. When we have large amounts of data stored in the database,
we use Clauses to query and get data required by the user.

10.0 References

https://www.w3schools.com/sql

https://www.geeksforgeeks.org/sql-tutorial/

9 Page

You might also like