Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 WHERE EXIST QUESTION HELP PLZ?

Author  Topic 

rv498
Yak Posting Veteran

60 Posts

Posted - 2014-03-03 : 18:53:56
Use a subquery and the EXISTS predicate to find customers that respond to surveys. List full name and email address.
-- Try the CONCAT() function for the name.
-- 1656 rows

SELECT CONCAT(C.LastName,', ',C.FirstName,C.MiddleName), C.EmailAddress
FROM dbo.DimCustomer AS C
WHERE EXISTS
(SELECT SurveyResponseKey
FROM dbo.FactSurveyResponse
WHERE dbo.DimCustomer.CustomerKey = CustomerKey)

This is my first attempt at EXISTS AND so far it doesn't work. Any help would be greatly appreciated.

bitsmed
Aged Yak Warrior

545 Posts

Posted - 2014-03-03 : 19:01:04
quote:
Originally posted by rv498

Use a subquery and the EXISTS predicate to find customers that respond to surveys. List full name and email address.
-- Try the CONCAT() function for the name.
-- 1656 rows

SELECT CONCAT(C.LastName,', ',C.FirstName,C.MiddleName), C.EmailAddress
FROM dbo.DimCustomer AS C
WHERE EXISTS
(SELECT SurveyResponseKey
FROM dbo.FactSurveyResponse
WHERE dbo.DimCustomerFactSurveyResponse.CustomerKey = C.CustomerKey)

This is my first attempt at EXISTS AND so far it doesn't work. Any help would be greatly appreciated.

Go to Top of Page

rv498
Yak Posting Veteran

60 Posts

Posted - 2014-03-04 : 00:08:21
Thanks bitsmed, I see I didn't catch that.
Go to Top of Page
   

- Advertisement -