T-SQL select performance
Cliente: PK = cdCli.
FoneCli: PK = isnFone. One client can have many fones (home, work, moblile, neighbor, father, etc)
I need in a query, get the clients and yours fones home, work and moblile.
I do this now with the follow command:
select Cliente.cdCli, Cliente.nmCli,
(select nuFone from FoneCli where FoneCli.cdCli = Cliente.cdCli and FoneCli.tpCli = 'H') as FoneHome,
(select nuFone from FoneCli where FoneCli.cdCli = Cliente.cdCli and FoneCli.tpCli = 'W') as FoneWork,
(select nuFone from FoneCli where FoneCli.cdCli = Cliente.cdCli and FoneCli.tpCli = 'M') as FoneMob
from Cliente
BUT THE PERFORMANCE FOR THIS COMAND IS BAD.
HOW CAN I REWRITE THIS COMAND WITH A BETTER PERFORMANCE?
Thanks
Alessandro

