Hi all,
I have 3 tables in sql server namely Owner, Asset and AssetOwner.
Owner:-
Owner, Domain, Position, Project, ID
1. Alex - ABC - 0 - X1 - 111
2. Peter - PQR - 1 - X2 - 222
3. Sam - GHI - 2 - X3 - 333
4. Alex - LMN - 3 - X4 - 111
Asset :-
Asset, Position, Center
1. ABC - 0 - Ivert
2. PQR - 1 - SGYt
3. GHI - 2 - RenGT
4. LMN - 3 - IUOy
AssetOwner:-
Owner, Asset, Center
1. Alex - ABC
2. Peter - PQR
3. Sam - GHI
4. Alex - LMN
Using the first 2 tables data(Asset and Owner table), I need to fill the value for column 3 -Center in AssetOwner table using below steps.
Find owner of a domain in Owner table. Check if any of the domain of an owner has same ID.
if yes (rows 1 & 4), take the first corresponding row (row 1) and get the value of Position(col 3). In Asset table, retrieve value of Center for the corresponding Position. Update value of Center in AssetOwner Table for the corresponding owner.
If no(rows 2 & 3), take ID column for Project ( col 4) get the value of Position(col 3). In Asset table, retrieve value of Center for the corresponding Position. Update value of Center in AssetOwner Table for the corresponding owner.
Please help me form the below query. Will a help be of any help
Thanks in advance.