Intersect ,Except in Sql(Set Operators);
keywords : intersect,except,set operators
Table Scripts:
create table PermanantCustomer
(
CustomerId int,
Name varchar(100),
Country varchar(100)
)
insert into PermanantCustomer values(1,'Arun','India')
insert into PermanantCustomer values(2,'kumar','India')
insert into PermanantCustomer values(3,'Sara','Uk')
create table TemporaryCustomer
(
CustomerId int,
Name varchar(100),
Country varchar(100)
)
insert into TemporaryCustomer values(1,'Sajan','UK')
insert into TemporaryCustomer values(2,'kumar','India')
insert into TemporaryCustomer values(3,'Meera','India')
--Set Operators
---Intersect and Except
-- returns distinct values by comparing the results of two queries.
--Intersect returns any distinct values returned by both the query on the left and right sides of the Intersect operand
select * from PermanantCustomer
select * from TemporaryCustomer
select * from PermanantCustomer
intersect
select * from TemporaryCustomer
--no of columns and datatype must be same in both Intersect and Except
--not allowed
--First Query 2 column and second query 3 column
select CustomerId,Name from PermanantCustomer
intersect
select CustomerId,Name,country from TemporaryCustomer
--not allowed
--First Query CustomerId=int type column and second Name= varchar type column
select CustomerId,Name,country from PermanantCustomer
intersect
select Name,CustomerId,country from TemporaryCustomer
--Allowed
select CustomerId,Name,country from PermanantCustomer
intersect
select CustomerId,Name,country from TemporaryCustomer
--Except
--select * from PermanantCustomer
--select * from TemporaryCustomer
--Except returns any distinct values from the left query not found on the right query.
select * from PermanantCustomer
Except
select * from TemporaryCustomer
---Using column values and order by diffrent column
select CustomerId,Name,Country from PermanantCustomer
Except
select CustomerId,Name,Country from TemporaryCustomer
order by name desc
Sql Query for jobs
# / @sqlqueryforjobs
Playlists:
• SQL Query Interview Questions
• Stored Procedure in sql
• Sql Basics Through Query
• User Defined Functions in sql
• Build in functions in sql
• Views in sql
set operators Links:
• Union ,Union All in Sql |Sql Server|S...
• Intersect ,Except in Sql(Set Operators)
Real time joins scenarios Links:
• Real time scenario on Inner join in sql
• Real time scenario on Left join in Sql
• Real time scenario on Right join in Sql
• Full join/Full outer join in Sql
• Real time scenario on Cross join in ...
Temp Tables Links:
• How to create Temporary tables in sql
• How to set Constraints in Temporary t...
Table Variables Links:
• Table variable in sql
• How to set constraints in Table varia...
SubQuery Links:
• Subquery In SQL |SQL Tutorial For Beg...
• Correlated Subquery In SQL |SQL Basics|
Build in Functions Links:
• STRING_AGG() in sql
• STRING_SPLIT in sql.
• Coalesce function in sql |Sql Server|.
Cte Links:
• CTE in sql.| Common Table Expression|
• CTE using multiple tables/multiple CT...
• How to insert,update,delete data usin...
• Recursive CTE in sql.| Recursive Comm...
Views Links:
• Views in sql
• How to insert,update,delete data thro...
• SQL Views, WITH CHECK OPTION
• How to update meta data of views in sql
• SCHEMABINDING option in sql views.
Stored procedure Links:
• How to create,alter,drop a stored pro...
• How to create a stored procedure with...
• Optional Parameter Stored Procedure i...
• How to Encrypt stored procedure in S...
• Return value of stored procedure in S...
• stored procedure summary in sql.
• How to use User defined Table type in...
• How to use Temp Tables in Stored Proc...
User Defined Functions Link:
• User Defined Scalar Functions in sq...
• Inline table valued function in sql |...
• Multi-Statement Table Valued Function...
• How to insert,update,delete datas to ...
• How to use User defined Table type in...
• How to set SchemaBinding in User defi...
Sql Query Interview Questions Link:
• Write a query to find the stock of ea...
• Write a query to fetch the employees ...
• Write a Query to Get Largest Sold Pr...
• Write a Query to find Diffrence of ea...
• How to delete duplicate records in sq...
• Write a query to merge source table d...
• Write a query to display two column v...
• Write a query to display converts the...
• Write a query to generate cricket tou...
• Write a Procedure to Get display Tabl...
#sql #sqlserver #sqlab #sqlinjection #mssql #sqldeveloper #sqlsaturday
#sql #programming #database #sqlserver #coding #developer #programmer #software #datascience #code #computerscience #data #dataanalytics
#technology #computer #development #bigdata #backend #coder #codinglife #microsoft #sqldatabase #softwaredeveloper #informationtechnology #programminglife #softwaredevelopment #programmerslife #sqlforbeginners #sqltraining #sqlinterviewquestions #mssqlserver
Смотрите видео Intersect ,Except in Sql(Set Operators) онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Sql Query for jobs 22 Октябрь 2023, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 25 раз и оно понравилось 1 людям.