AdventureWorks Database: A distinct businessentityid must be returned by both queries
SQL Query - AdventureWorks: Exercise-135 with Solution
135. From the following tables write a query in SQL to fetch distinct businessentityid that are returned by both the specified query. Sort the result set by ascending order on businessentityid.
Sample table: Person.BusinessEntity
Sample table: Person.Person
SELECT businessentityid FROM person.businessentity INTERSECT SELECT businessentityid FROM person.person WHERE person.persontype = 'IN' ORDER BY businessentityid;
businessentityid| ----------------+ 1699| 1700| 1701| 1702| 1703| 1704| 1705| 1706| 1707| 1708| 1709| 1710| 1711| ...
SQL AdventureWorks Editor:
Contribute your code and comments through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
SQL: Tips of the Day
How to select rows with no matching entry in another table?
SELECT t1.ID FROM Table1 t1 LEFT JOIN Table2 t2 ON t1.ID = t2.ID WHERE t2.ID IS NULL
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook