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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Query help

Author  Topic 

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2014-01-29 : 17:46:44
I need a query which should update the master table with status based on the details records..

Below is the sample data with expected output.

Thanks for your help in advance..



TableA

SID
----
10
11
12

TableB

SID action
---- -------
10 1
10 3
11 5
11 6
11 5
12 1

Expected Output:

SID status
---- ------
10 Y
11 N
12 Y

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-01-29 : 18:11:39
What is the correlation between action and status? I don't understand why 10/12 are Y and 11 is N.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2014-01-29 : 18:45:36
I want to update "Y" when the actions are (1,3,4) else "N"
Go to Top of Page
   

- Advertisement -