SQL Series...29 - IT Skills

This blog is for IT lovers, accounts and finance executives who want to add value in their professional life.

test

Welcome to our blog. This blog is for IT lovers, Accounts/Finance Executives who wants to add value in their career path.

Search This Blog

Saturday, 9 June 2018

SQL Series...29

test

Relational Operators

EXCEPT


The UNION operation acts on two source tables and returns all rows that appear in either table. The INTERSECT operation returns all rows that appear in both the first and the second table. In contrast, the EXCEPT (or EXCEPT DISTINCT) operation returns all rows that appear in the first table but that do not also appear in the second table.
Returning to the municipal pager database example, say that a group of pagers that had been declared out of service and returned to the vendor for repairs have now been fixed and placed back into service. The PAGERS table was updated to reflect the returned pagers, but the returned pagers were not removed from the OUT table as they should have been. You can display the PagerID numbers of the pagers in the OUT table, with the reactivated ones eliminated, using an EXCEPT operation:


SELECT *

FROM OUT
EXCEPT CORRESPONDING (PagerID)
SELECT *
FROM PAGERS;

This query returns all the rows in the OUT table whose PagerID is not also present in the PAGERS table.

No comments:

Post a Comment

Popular

Welcome to our blog. If you want to; learn writing skills, preparation for CSS/Corporate laws, IT skills, downloading Business/IT books, and many more; this blog is for you.