Good morning from Santo Domingo
Please can you help me with this ? How could I simplify or improve this ?:
SELECT
@total1 = (case when @RT = 0 then AVG(ButacaADLida*@ADL1)+AVG(ButacaNinos212Ida*@CHD1) else AVG(ButacaADL*@ADL1)+AVG(ButacaNinos212*@CHD1) end ),
@total2 = (case when @RT = 0 then AVG(ButacaADLida*@ADL2)+AVG(ButacaNinos212Ida*@CHD2) else AVG(ButacaADL*@ADL2)+AVG(ButacaNinos212*@CHD2) end ),
@total3 = (case when @RT = 0 then AVG(ButacaADLida*@ADL3)+AVG(ButacaNinos212Ida*@CHD3) else AVG(ButacaADL*@ADL3)+AVG(ButacaNinos212*@CHD3) end ),
@Interna = (case when @RT = 0 then AVG(CabInteriorIda) else AVG(CabInteriorReg) end ),
@Externa = (case when @RT = 0 then AVG(CabExteriorIda) else AVG(CabExteriorReg) end ),
@Suite = (case when @RT = 0 then AVG(suiteida) else AVG(suitereg) end ),
@Master = (case when @RT = 0 then AVG(masterida) else AVG(masterReg) end ), ...
Go to the complete details ...