SlideShare a Scribd company logo
2
Most read
5
Most read
14
Most read
P2CINFOTECH
www.p2cinfotech.com
Contact : +1-732-546-3607
Email id:training@p2cinfotech.com
IT Online Training and Placement
(QA, BA, QTP, JAVA, Mobile apps..)
Mock interviews.
100% job Placement assistance.
Free Training for Opt/MS Students.
Placement with one of our Fortune 500 clients.
Live Instructor Led Face2Face Online Training.
SQL FOR ETL TESTING
 What is Web Services?
It is a middleware developed in XML. Exchange the data between multiple
platforms.
 What is web services?
It is middleware technology developed in XML to exchange the data between
multiple platforms and languages.
 what is rest protocol ?
REST stands for Representational State Transfer. (It is sometimes spelled
"ReST".)
EST is a lightweight alternative to mechanisms like RPC (Remote Procedure
Calls) and Web Services (SOAP, WSDL, et al.). Later, we will see how much
more simple REST is.
Despite being simple, REST is fully-featured; there's basically nothing you can do
in Web Services that can't be done with a RESTful architecture.
REST is not a "standard". There will never be a W3C recommendation for REST,
for example. And while there are REST programming frameworks, working with
REST is so simple that you can often "roll your own" with standard library
features in languages like Perl, Java, or C#.
P2cinfotech.com
 In Interviews they ask do you have work experience in web based
applications, does that mean having experience in web services in
SOAPUI ?
Ans: NO
 What is synchronous web services? -- get response immediately.
 What is asynchronous web services? --Response will be sent when the
service is available.
 What is SOAPUI? It is a tool to test the Web Services.
 what is xml schema?-- XML schema is well defined xml structure. It is w3
standards.
+1-732-546-3607
P2cinfotech.com
 9). In Interviews if they ask do you have work experience in
web based applications, does that mean having experience
in web services in soapUI?
Ans: NO.
Create a table:
CREATE TABLE customer
(First_Namechar (50),
Last_Namechar(50),
Address char(50),
City char(50),
Country char(25),
Birth_Date date) ;
+1-732-546-3607
P2cinfotech.com
2. Add a column to a table:
ALTER TABLE customer ADD SO_INSURANCE_PROVIDER
Varchar2(35);
3. DROP a column to a table
ALTER TABLE customer DROP column
SO_INSURANCE_PROVIDER
Varchar2(35);
4. Add a default value to a column
ALTER TABLE customer MODIFY SO_INSURANCE_PROVIDER
Varchar2(35) DEFAULT 'ABC Ins';
5. Renaming a table:
ALTER TABLE suppliers RENAME TO vendors;
+1-732-546-3607
P2cinfotech.com
6. Modifying column(s) in a table:
ALTER TABLE supplier MODIFY supplier_namevarchar2(100)
not null;
7. Drop column(s) in a table:
ALTER TABLE supplier DROP COLUMN supplier_name;
8. Primary key:
CREATE TABLE supplier
(
supplier_id numeric(10) not null,
supplier_namevarchar2(50) not null,
contact_namevarchar2(50),
CONSTRAINT supplier_pk PRIMARY KEY (supplier_id,
supplier_name)
);
+1-732-546-3607
P2cinfotech.com
 Add primary key:
ALTER TABLE supplier add CONSTRAINT supplier_pk
PRIMARY KEY
(supplier_id);
 Drop primary key:
ALTER TABLE supplier drop CONSTRAINT supplier_pk;
 Disable primary key:
ALTER TABLE supplier disable CONSTRAINT supplier_pk;
 Enable primary key:
ALTER TABLE supplier enable CONSTRAINT supplier_pk;
+1-732-546-3607
 Foreign key creation:
CREATE TABLE supplier
(
supplier_id numeric(10) not null,
supplier_namevarchar2(50) not null,
contact_namevarchar2(50),
CONSTRAINT supplier_pk PRIMARY KEY (supplier_id)
);
CREATE TABLE products
(
product_id numeric(10) not null,
supplier_id numeric(10) not null,
CONSTRAINT fk_supplier
FOREIGN KEY (supplier_id)
REFERENCES supplier(supplier_id)
);
+1-732-546-3607
14. More than column :
CREATE TABLE supplier
(
supplier_id numeric(10) not null,
supplier_namevarchar2(50) not null,
contact_namevarchar2(50),
CONSTRAINT supplier_pk PRIMARY KEY (supplier_id, supplier_name)
);
CREATE TABLE products
(
Product_id numeric (10) not null,
Supplier_id numeric (10) not null,
supplier_name varchar2 (50) not null,
CONSTRAINT fk_supplier_comp
FOREIGN KEY (supplier_id, supplier_name)
REFERENCES supplier (supplier_id, supplier_name)
);
P2CINFOTECH.COM +1-732-546-3607
Alter foreign key:
ALTER TABLE products add CONSTRAINT fk_supplier FOREIGN KEY
(supplier_id) REFERENCES supplier (supplier_id);
Drop foreign key:
ALTER TABLE SALES_ORDER_LINE DROP FOREIGN KEY
FK_SALES_ORDER_LINE_PRODUCT
Check constraint:
ALTER TABLE EMPLOYEE ADD CONSTRAINT REVENUE CHECK
(SALARY + COMM > 25000)
Drop check constraint:
ALTER TABLE EMPLOYEE DROP CONSTRAINT REVENUE CHECK
(SALARY + COMM > 25000)
19. Drop Table:
DROP TABLE customer;
P2CINFOTECH.COM +1-732-546-3607
 Truncate Statement:
Truncate table customer;
*********************************************************************End of DDL
Statements*********************************************************************
**
****************************************************************** DML
Statements
***************************************************************************
Insert rows in table:
1) INSERT INTO Store_Information (store_name, Sales, Date)
VALUES ('Los Angeles', 900, 'Jan-10-1999')
2) INSERT INTO Store_Information (store_name, Sales, Date) SELECT
store_name, Sales, Date FROM Sales_Info WHERE Year
(Date) = 1998
P2CINFOTECH.COM +1-732-546-3607
Update Statement in table:
UPDATE suppliers SET name = 'HP' WHERE name =
'IBM';
UPDATE suppliers
SET supplier_name =
(SELECT customers.name
FROM customers
WHERE customers. customer_id = suppliers.
supplier_id);
P2CINFOTECH +1-732-546-3607
24. Delete Statement in table:
25 DELETE FROM suppliers WHERE
supplier_name = 'IBM';
26 DELETE FROM suppliers
WHERE EXISTS
( select customers.name
from customers
wherecustomers.customer_id =
suppliers.supplier_id
andcustomers.customer_name = 'IBM' );
************************** select statement
P2CINFOTECH.COM +1-732-546-3607
Select Statement in table:
1. SELECT LastName, FirstName FROM Persons;
2. SELECT * FROM Persons;
The SELECT DISTINCT Statement:
SELECT DISTINCT Company FROM Orders;
The WHERE Clause:
SELECT * FROM Persons WHERE City='Sandnes‘
Using LIKE
SELECT * FROM Persons WHERE FirstName LIKE 'O%'
P2CINFOTECH.COM +1-732-546-3607
31. Arithmetic Operation:
Operator Description
= Equal
<> Not equal
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal
BETWEENBetween an inclusive range
LIKE Search for a pattern
IN If you know the exact value you
want to return for at least one of the
columns
P2CINFOTECH.COM +1-732-546-3607
BETWEEN ... AND:
SELECT * FROM Persons WHERE LastName
BETWEEN 'Hansen' AND
'Pettersen';
IN
SELECT * FROM Persons WHERE LastName IN
('Hansen','Pettersen');
Column Name Alias
SELECT LastName AS Family, FirstName AS Name
FROM Persons
P2CINFOTECH.COM +1-732-546-3607
AND & OR
SELECT * FROM Persons WHERE FirstName='Tove' AND
LastName='Svendson'
SELECT * FROM Persons WHERE firstname='Tove' OR
lastname='Svendson'
ORDER BY
SELECT Company, OrderNumber FROM Orders ORDER
BY Company
SELECT Company, OrderNumber FROM Orders ORDER
BY Company
DESC, OrderNumber ASC
P2CINFOTECH.COM +1-732-546-3607
Group by Clause:
SELECT Company, SUM (Amount) FROM Sales GROUP BY
Company;
Having Clause:
SELECT Company, SUM (Amount) FROM Sales GROUP BY
Company
HAVING SUM (Amount)>10000;
Using UNION Clause:
SELECT E_Name FROM Employees_Norway
UNION
SELECT E_Name FROM Employees_USA
P2CINFOTECH.COM +1-732-546-3607
UNION ALL Clause:
SELECT E_Name FROM Employees_Norway
UNION ALL
SELECT E_Name FROM Employees_USA
JOINS:
Referring to Two Tables:
SELECT Employees.Name, Orders.Product
FROM Employees, Orders
WHERE Employees.Employee_ID=Orders.Employee_ID
INNER JOIN:
SELECT Employees.Name, Orders.Product
FROM Employees
INNER JOIN Orders
ON Employees.Employee_ID=Orders.Employee_ID;
P2CINFOTECH.COM +1-732-546-3607
LEFT JOIN:
SELECT Employees.Name, Orders.Product
FROM Employees
LEFT JOIN Orders
ON Employees.Employee_ID=Orders.Employee_ID;
RIGHT JOIN:
SELECT Employees.Name, Orders.Product
FROM Employees
RIGHT JOIN Orders
ON Employees.Employee_ID=Orders.Employee_ID;
P2CINFOTECH.COM +1-732-546-3607
Subqueries:
1) Select distinct country from Northwind.dbo.Customers
where country not in (select distinct country from
Northwind.dbo.Suppliers);
2) Select top 1 OrderId, convert (char (10),
OrderDate, 121) Last_Paris_Order,
(Select convert (char (10), max (OrderDate), 121) from
Northwind.dbo.Orders) Last_OrderDate,
datediff(dd,OrderDate,
(select Max(OrderDate) from Northwind.dbo.Orders))
Day_Diff
fromNorthwind.dbo.Orders
whereShipCity = 'Paris' order by OrderDatedesc;
P2CINFOTECH.COM +1-732-546-3607
Commit & Rollback Statements:
1) UPDATE suppliers SET name = 'HP' WHERE name
= 'IBM';
Commit;
2) UPDATE suppliers SET name = 'HP' WHERE name
= 'IBM';
Rollback;
SavepointStatement:
INSERT INTO DEPARTMENT VALUES ('A20', 'MARKETING',
301);
SAVEPOINT SAVEPOINT1;
INSERT INTO DEPARTMENT VALUES ('B30', 'FINANCE', 520);
SAVEPOINT SAVEPOINT2;

More Related Content

PPTX
ETL Testing Interview Questions and Answers
PDF
Unix commands in etl testing
DOCX
Top 40 sql queries for testers
PDF
Partitioning tables and indexing them
PPTX
DATA WAREHOUSE -- ETL testing Plan
PPTX
Data Warehouse Fundamentals
DOCX
DBMS lab manual
PDF
Basic Sql Handouts
ETL Testing Interview Questions and Answers
Unix commands in etl testing
Top 40 sql queries for testers
Partitioning tables and indexing them
DATA WAREHOUSE -- ETL testing Plan
Data Warehouse Fundamentals
DBMS lab manual
Basic Sql Handouts

What's hot (20)

DOCX
Complex queries in sql
PPT
SQL Tutorial - Basic Commands
DOC
Data Warehouse (ETL) testing process
PPTX
SQL Data Manipulation
PPTX
Understanding SQL Trace, TKPROF and Execution Plan for beginners
PPTX
SQL Queries Information
PPTX
Sql operator
PPTX
Inner join and outer join
PDF
[APJ] Common Table Expressions (CTEs) in SQL
 
PPTX
SQL JOIN
PDF
SSIS Tutorial For Beginners | SQL Server Integration Services (SSIS) | MSBI T...
DOC
Sql queires
ODP
Ms sql-server
PPTX
PPTX
Oraclesql
PPT
Introduction to SQL
PDF
MySQL Indexing : Improving Query Performance Using Index (Covering Index)
PPT
Sql operators & functions 3
PDF
Understanding index
Complex queries in sql
SQL Tutorial - Basic Commands
Data Warehouse (ETL) testing process
SQL Data Manipulation
Understanding SQL Trace, TKPROF and Execution Plan for beginners
SQL Queries Information
Sql operator
Inner join and outer join
[APJ] Common Table Expressions (CTEs) in SQL
 
SQL JOIN
SSIS Tutorial For Beginners | SQL Server Integration Services (SSIS) | MSBI T...
Sql queires
Ms sql-server
Oraclesql
Introduction to SQL
MySQL Indexing : Improving Query Performance Using Index (Covering Index)
Sql operators & functions 3
Understanding index
Ad

Similar to SQL for ETL Testing (20)

PPTX
Introducing N1QL: New SQL Based Query Language for JSON
PPTX
Advanced app building with PowerApps expressions and rules
PDF
Big Data for Small Businesses & Startups
PPTX
Integrating Force.com with Heroku
PDF
70433 Dumps DB
PPTX
Introduction to SQL
PPT
Intro to AppExchange - Building Composite Apps
PPTX
ELEVATE Advanced Workshop
PPTX
Detroit ELEVATE Track 2
PPTX
SQL for JSON: Rich, Declarative Querying for NoSQL Databases and Applications 
PPTX
How to Leverage APIs for SEO #TTTLive2019
PDF
On SQL Managment studioThis lab is all about database normalizatio.pdf
PDF
Top 100 .NET Interview Questions and Answers
PDF
PDF
DN 2017 | Reducing pain in data engineering | Martin Loetzsch | Project A
PPT
IBM Insight 2015 - 1824 - Using Bluemix and dashDB for Twitter Analysis
PDF
Oracle OCP 1Z0-007题库
PDF
Creating Beautiful Dashboards with Grafana and ClickHouse
PDF
7 Habits of Highly Efficient Visualforce Pages
PPTX
ATAGTR2017 Test Approach for Re-engineering Legacy Applications based on Micr...
Introducing N1QL: New SQL Based Query Language for JSON
Advanced app building with PowerApps expressions and rules
Big Data for Small Businesses & Startups
Integrating Force.com with Heroku
70433 Dumps DB
Introduction to SQL
Intro to AppExchange - Building Composite Apps
ELEVATE Advanced Workshop
Detroit ELEVATE Track 2
SQL for JSON: Rich, Declarative Querying for NoSQL Databases and Applications 
How to Leverage APIs for SEO #TTTLive2019
On SQL Managment studioThis lab is all about database normalizatio.pdf
Top 100 .NET Interview Questions and Answers
DN 2017 | Reducing pain in data engineering | Martin Loetzsch | Project A
IBM Insight 2015 - 1824 - Using Bluemix and dashDB for Twitter Analysis
Oracle OCP 1Z0-007题库
Creating Beautiful Dashboards with Grafana and ClickHouse
7 Habits of Highly Efficient Visualforce Pages
ATAGTR2017 Test Approach for Re-engineering Legacy Applications based on Micr...
Ad

More from Garuda Trainings (14)

PDF
SAP BI 7.0 Info Providers
DOC
Short definitions of all testing types
PPTX
Software testing life cycle
DOCX
Fundamental classes in java
DOCX
Java Exception handling
DOCX
Performance testing interview questions and answers
DOCX
Loadrunner interview questions and answers
DOCX
Business analysis interview question and answers
DOCX
Quality center interview questions and answers
PPT
Software development life cycle
DOCX
Interview Questions and Answers for Java
DOCX
Basic java important interview questions and answers to secure a job
PPT
Dot net Online Training | .Net Training and Placement online
PDF
Interview questions and answers for quality assurance
SAP BI 7.0 Info Providers
Short definitions of all testing types
Software testing life cycle
Fundamental classes in java
Java Exception handling
Performance testing interview questions and answers
Loadrunner interview questions and answers
Business analysis interview question and answers
Quality center interview questions and answers
Software development life cycle
Interview Questions and Answers for Java
Basic java important interview questions and answers to secure a job
Dot net Online Training | .Net Training and Placement online
Interview questions and answers for quality assurance

Recently uploaded (20)

PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
GDM (1) (1).pptx small presentation for students
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Computing-Curriculum for Schools in Ghana
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
01-Introduction-to-Information-Management.pdf
PDF
Insiders guide to clinical Medicine.pdf
PDF
Complications of Minimal Access Surgery at WLH
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Pre independence Education in Inndia.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
TR - Agricultural Crops Production NC III.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
human mycosis Human fungal infections are called human mycosis..pptx
Module 4: Burden of Disease Tutorial Slides S2 2025
Anesthesia in Laparoscopic Surgery in India
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
GDM (1) (1).pptx small presentation for students
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Computing-Curriculum for Schools in Ghana
2.FourierTransform-ShortQuestionswithAnswers.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
102 student loan defaulters named and shamed – Is someone you know on the list?
01-Introduction-to-Information-Management.pdf
Insiders guide to clinical Medicine.pdf
Complications of Minimal Access Surgery at WLH
Renaissance Architecture: A Journey from Faith to Humanism
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Pre independence Education in Inndia.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
TR - Agricultural Crops Production NC III.pdf

SQL for ETL Testing

  • 1. P2CINFOTECH www.p2cinfotech.com Contact : +1-732-546-3607 Email id:training@p2cinfotech.com IT Online Training and Placement (QA, BA, QTP, JAVA, Mobile apps..) Mock interviews. 100% job Placement assistance. Free Training for Opt/MS Students. Placement with one of our Fortune 500 clients. Live Instructor Led Face2Face Online Training.
  • 2. SQL FOR ETL TESTING  What is Web Services? It is a middleware developed in XML. Exchange the data between multiple platforms.  What is web services? It is middleware technology developed in XML to exchange the data between multiple platforms and languages.  what is rest protocol ? REST stands for Representational State Transfer. (It is sometimes spelled "ReST".) EST is a lightweight alternative to mechanisms like RPC (Remote Procedure Calls) and Web Services (SOAP, WSDL, et al.). Later, we will see how much more simple REST is. Despite being simple, REST is fully-featured; there's basically nothing you can do in Web Services that can't be done with a RESTful architecture. REST is not a "standard". There will never be a W3C recommendation for REST, for example. And while there are REST programming frameworks, working with REST is so simple that you can often "roll your own" with standard library features in languages like Perl, Java, or C#.
  • 3. P2cinfotech.com  In Interviews they ask do you have work experience in web based applications, does that mean having experience in web services in SOAPUI ? Ans: NO  What is synchronous web services? -- get response immediately.  What is asynchronous web services? --Response will be sent when the service is available.  What is SOAPUI? It is a tool to test the Web Services.  what is xml schema?-- XML schema is well defined xml structure. It is w3 standards. +1-732-546-3607
  • 4. P2cinfotech.com  9). In Interviews if they ask do you have work experience in web based applications, does that mean having experience in web services in soapUI? Ans: NO. Create a table: CREATE TABLE customer (First_Namechar (50), Last_Namechar(50), Address char(50), City char(50), Country char(25), Birth_Date date) ; +1-732-546-3607
  • 5. P2cinfotech.com 2. Add a column to a table: ALTER TABLE customer ADD SO_INSURANCE_PROVIDER Varchar2(35); 3. DROP a column to a table ALTER TABLE customer DROP column SO_INSURANCE_PROVIDER Varchar2(35); 4. Add a default value to a column ALTER TABLE customer MODIFY SO_INSURANCE_PROVIDER Varchar2(35) DEFAULT 'ABC Ins'; 5. Renaming a table: ALTER TABLE suppliers RENAME TO vendors; +1-732-546-3607
  • 6. P2cinfotech.com 6. Modifying column(s) in a table: ALTER TABLE supplier MODIFY supplier_namevarchar2(100) not null; 7. Drop column(s) in a table: ALTER TABLE supplier DROP COLUMN supplier_name; 8. Primary key: CREATE TABLE supplier ( supplier_id numeric(10) not null, supplier_namevarchar2(50) not null, contact_namevarchar2(50), CONSTRAINT supplier_pk PRIMARY KEY (supplier_id, supplier_name) ); +1-732-546-3607
  • 7. P2cinfotech.com  Add primary key: ALTER TABLE supplier add CONSTRAINT supplier_pk PRIMARY KEY (supplier_id);  Drop primary key: ALTER TABLE supplier drop CONSTRAINT supplier_pk;  Disable primary key: ALTER TABLE supplier disable CONSTRAINT supplier_pk;  Enable primary key: ALTER TABLE supplier enable CONSTRAINT supplier_pk; +1-732-546-3607
  • 8.  Foreign key creation: CREATE TABLE supplier ( supplier_id numeric(10) not null, supplier_namevarchar2(50) not null, contact_namevarchar2(50), CONSTRAINT supplier_pk PRIMARY KEY (supplier_id) ); CREATE TABLE products ( product_id numeric(10) not null, supplier_id numeric(10) not null, CONSTRAINT fk_supplier FOREIGN KEY (supplier_id) REFERENCES supplier(supplier_id) ); +1-732-546-3607
  • 9. 14. More than column : CREATE TABLE supplier ( supplier_id numeric(10) not null, supplier_namevarchar2(50) not null, contact_namevarchar2(50), CONSTRAINT supplier_pk PRIMARY KEY (supplier_id, supplier_name) ); CREATE TABLE products ( Product_id numeric (10) not null, Supplier_id numeric (10) not null, supplier_name varchar2 (50) not null, CONSTRAINT fk_supplier_comp FOREIGN KEY (supplier_id, supplier_name) REFERENCES supplier (supplier_id, supplier_name) );
  • 10. P2CINFOTECH.COM +1-732-546-3607 Alter foreign key: ALTER TABLE products add CONSTRAINT fk_supplier FOREIGN KEY (supplier_id) REFERENCES supplier (supplier_id); Drop foreign key: ALTER TABLE SALES_ORDER_LINE DROP FOREIGN KEY FK_SALES_ORDER_LINE_PRODUCT Check constraint: ALTER TABLE EMPLOYEE ADD CONSTRAINT REVENUE CHECK (SALARY + COMM > 25000) Drop check constraint: ALTER TABLE EMPLOYEE DROP CONSTRAINT REVENUE CHECK (SALARY + COMM > 25000) 19. Drop Table: DROP TABLE customer;
  • 11. P2CINFOTECH.COM +1-732-546-3607  Truncate Statement: Truncate table customer; *********************************************************************End of DDL Statements********************************************************************* ** ****************************************************************** DML Statements *************************************************************************** Insert rows in table: 1) INSERT INTO Store_Information (store_name, Sales, Date) VALUES ('Los Angeles', 900, 'Jan-10-1999') 2) INSERT INTO Store_Information (store_name, Sales, Date) SELECT store_name, Sales, Date FROM Sales_Info WHERE Year (Date) = 1998
  • 12. P2CINFOTECH.COM +1-732-546-3607 Update Statement in table: UPDATE suppliers SET name = 'HP' WHERE name = 'IBM'; UPDATE suppliers SET supplier_name = (SELECT customers.name FROM customers WHERE customers. customer_id = suppliers. supplier_id);
  • 13. P2CINFOTECH +1-732-546-3607 24. Delete Statement in table: 25 DELETE FROM suppliers WHERE supplier_name = 'IBM'; 26 DELETE FROM suppliers WHERE EXISTS ( select customers.name from customers wherecustomers.customer_id = suppliers.supplier_id andcustomers.customer_name = 'IBM' ); ************************** select statement
  • 14. P2CINFOTECH.COM +1-732-546-3607 Select Statement in table: 1. SELECT LastName, FirstName FROM Persons; 2. SELECT * FROM Persons; The SELECT DISTINCT Statement: SELECT DISTINCT Company FROM Orders; The WHERE Clause: SELECT * FROM Persons WHERE City='Sandnes‘ Using LIKE SELECT * FROM Persons WHERE FirstName LIKE 'O%'
  • 15. P2CINFOTECH.COM +1-732-546-3607 31. Arithmetic Operation: Operator Description = Equal <> Not equal > Greater than < Less than >= Greater than or equal <= Less than or equal BETWEENBetween an inclusive range LIKE Search for a pattern IN If you know the exact value you want to return for at least one of the columns
  • 16. P2CINFOTECH.COM +1-732-546-3607 BETWEEN ... AND: SELECT * FROM Persons WHERE LastName BETWEEN 'Hansen' AND 'Pettersen'; IN SELECT * FROM Persons WHERE LastName IN ('Hansen','Pettersen'); Column Name Alias SELECT LastName AS Family, FirstName AS Name FROM Persons
  • 17. P2CINFOTECH.COM +1-732-546-3607 AND & OR SELECT * FROM Persons WHERE FirstName='Tove' AND LastName='Svendson' SELECT * FROM Persons WHERE firstname='Tove' OR lastname='Svendson' ORDER BY SELECT Company, OrderNumber FROM Orders ORDER BY Company SELECT Company, OrderNumber FROM Orders ORDER BY Company DESC, OrderNumber ASC
  • 18. P2CINFOTECH.COM +1-732-546-3607 Group by Clause: SELECT Company, SUM (Amount) FROM Sales GROUP BY Company; Having Clause: SELECT Company, SUM (Amount) FROM Sales GROUP BY Company HAVING SUM (Amount)>10000; Using UNION Clause: SELECT E_Name FROM Employees_Norway UNION SELECT E_Name FROM Employees_USA
  • 19. P2CINFOTECH.COM +1-732-546-3607 UNION ALL Clause: SELECT E_Name FROM Employees_Norway UNION ALL SELECT E_Name FROM Employees_USA JOINS: Referring to Two Tables: SELECT Employees.Name, Orders.Product FROM Employees, Orders WHERE Employees.Employee_ID=Orders.Employee_ID INNER JOIN: SELECT Employees.Name, Orders.Product FROM Employees INNER JOIN Orders ON Employees.Employee_ID=Orders.Employee_ID;
  • 20. P2CINFOTECH.COM +1-732-546-3607 LEFT JOIN: SELECT Employees.Name, Orders.Product FROM Employees LEFT JOIN Orders ON Employees.Employee_ID=Orders.Employee_ID; RIGHT JOIN: SELECT Employees.Name, Orders.Product FROM Employees RIGHT JOIN Orders ON Employees.Employee_ID=Orders.Employee_ID;
  • 21. P2CINFOTECH.COM +1-732-546-3607 Subqueries: 1) Select distinct country from Northwind.dbo.Customers where country not in (select distinct country from Northwind.dbo.Suppliers); 2) Select top 1 OrderId, convert (char (10), OrderDate, 121) Last_Paris_Order, (Select convert (char (10), max (OrderDate), 121) from Northwind.dbo.Orders) Last_OrderDate, datediff(dd,OrderDate, (select Max(OrderDate) from Northwind.dbo.Orders)) Day_Diff fromNorthwind.dbo.Orders whereShipCity = 'Paris' order by OrderDatedesc;
  • 22. P2CINFOTECH.COM +1-732-546-3607 Commit & Rollback Statements: 1) UPDATE suppliers SET name = 'HP' WHERE name = 'IBM'; Commit; 2) UPDATE suppliers SET name = 'HP' WHERE name = 'IBM'; Rollback; SavepointStatement: INSERT INTO DEPARTMENT VALUES ('A20', 'MARKETING', 301); SAVEPOINT SAVEPOINT1; INSERT INTO DEPARTMENT VALUES ('B30', 'FINANCE', 520); SAVEPOINT SAVEPOINT2;