SQL - is it possible to do this in single query?
I've got a problem with my sql query (SQL Server) I've got two tables -
persons and accounts persons have fields - id,account_id, person_type(can
by A,B,C,D accounts have fields - id, account_type(which is null now, can
by X or Y)
there are 2000 accounts, but persons table has 3500 records. For example
person table can hold 3 records with the same account_id, but different
person_type Here is what I want: Based on person table update (in one
query) accounts table - this seems easy at that point. if person type is
A,B,C put X into account type, if D put Y. But if persons table holds
person with B and different person with D and the same accont_id I want to
put Y in the accounts and i don't know how to perform it...
Now, I've got a ssis for each loop which is iterating every account_id and
checking type but it's very inefficient and takes about 80% of my whole
process.
Hope that someone will undersand what I described above :) Thanks
No comments:
Post a Comment