Software requirements
Sql Server
Followthis link to download and install sql server
Sample Database to be used:
• Northwind
• Pubs
• Adventureworks
Follow this link for installation of northwind db
https://www.youtube.com/watch?v=yasfZuou3zI
INTRODUCTION TO SQL
Whatis a Database Management System?
Database management systems (DBMSs) are specially designed
software applications that interact with the user, other applications, and
the database itself to capture and analyze data.
Well-known DBMSs include MySQL, MariaDB, PostgreSQL, SQLite,
Microsoft SQL Server, Oracle, SAP, dBASE, FoxPro, IBM DB2,
LibreOffice Base and FileMaker Pro.
6.
INTRODUCTION TO SQL
Whatis a Server?
A server is a computer that serves information to other computers.
These other computers are called clients.
Connected through a local area network (LAN) or a wide area network
(WAN), such as the Internet.
7.
INTRODUCTION TO SQL
Whatis a Record?
A complete set of information.
Records are composed of fields.
8.
INTRODUCTION TO SQL
Whatis a field?
A space allocated for a particular item or information.
A collection of fields is called a record.
9.
INTRODUCTION TO SQL
Whatis SQL?
SQL stands for Structured Query LanguageSQL lets you access and manipulate databases.
What Can SQL do?
SQL can execute queries against a database
SQL can retrieve data from a database
SQL can insert records in a database
SQL can update records in a database
SQL can delete records from a database
SQL can create new databases
SQL can create new tables in a database
10.
INTRODUCTION TO SQL
TheSELECT ... FROM Clause
The most basic SELECT statement has only 2 parts:
(1) the columns you want to display and
(2) from the table(s) these columns belong to.
Where Clause
By addinga WHERE clause to the SELECT
statement, we add one (or more) conditions that
must be met by the selected data. This will limit
the number of rows that answer the query and are
fetched. In many cases, this is where most of the
"action" of a query takes place.
13.
Operators
There are fourtypes of operators:
1. Comparison Operators
2. Logical Operators
3. List Operators
4. Range Operators
14.
Operator
An operator isa character or a reserved word that
is used to specify a condition, or combine two or
more conditions. The operators are used with the
WHERE clause in the SELECT statement to set
the filter criteria for data.
15.
Comparison Operator
Comparison operatorsare used to compare the column
data with specific values in a condition.
Comparison Operator Description
= Equal to
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
<> Not equal to
16.
SQL WHERE andOPERATOR Syntax
SELECT column_name,column_name FROM
table_name WHERE column_name operator
value
Greater than orequal to
SELECT ProductName,UnitsInStock,UnitsOnOrder
FROM Products WHERE UnitsOnOrder >=70
19.
Not equal to
Ifyou wanted to get the opposite, the employees
who do not live in London, you would write
20.
Not equal to
SELECTEmployeeID, FirstName, LastName,
HireDate, City FROM Employees WHERE City
<> 'London'
21.
Logical Operators
Logical operatorsare used to test if a specified condition is true or not. They are also
used to combine multiple conditions.
Some of the commonly used logical operators are:
OR
• Retrieves rows that meet any one of the specified conditions.
AND
• Retrieves rows that meet both the conditions.
NOT
• Retrieves rows that do not meet the specified condition.
BETWEEN
• Retrieves rows where the tested value falls within the specified range.
USING AND andOR OPERATOR
SELECT * FROM Customers WHERE
Country='Germany' AND (City='Berlin' OR
City='Mannheim');
25.
Lab Tasks
• GetOrder id, Product id, Unit price from Order Details.
• Find Title of employee Nancy.
• Display data of all employees those working as Sales Representative
from London
• Display product name whose unit price are greater than 90$
• Write a query to get current Product list (Product ID and name).
• Fetch data of customers where country is "Germany" AND city must
be "Berlin" OR "München" (use parenthesis to form complex
expressions)
26.
Lab Tasks
• Fetchdata of customers from all countries except Germany and USA
• Fetch Discontinued products who’s price is greater than 20