ah muchas gracias por tu ayuda lo coloco,
Código SQL:
Ver originalIF @TYPE = 24
BEGIN
INSERT #idleppt SELECT [team],[YEAR],[week],0 FROM [RIA].[dbo].[ReportSapAll] WHERE [USER]=@USER GROUP BY [team],[YEAR],[week]
IF @GROUP = '' AND @team = ''
BEGIN
INSERT #idlepptA SELECT [team],[YEAR],[week],SUM([hours])AS[hours] FROM [RIA].[dbo].[ReportSapAll] WHERE [USER]=@USER AND [statusSAP]IN('Idle') GROUP BY [team],[YEAR],[week] ORDER BY [week]
SELECT * FROM #idlepptA
END
IF @GROUP = '' AND @team <> ''
BEGIN
INSERT #idlepptB SELECT [team],[YEAR],[week],SUM([hours])AS[hours] FROM [RIA].[dbo].[ReportSapAll] WHERE [team]=@team AND [USER]=@USER AND [statusSAP]IN('Idle') GROUP BY [team],[YEAR],[week] ORDER BY [week]
SELECT * FROM #idlepptB
END
IF @GROUP <> '' AND @team = ''
BEGIN
INSERT #idlepptC SELECT [team],[YEAR],[week],SUM([hours])AS[hours] FROM [RIA].[dbo].[ReportSapAll] WHERE [team] IN (SELECT c.[description] FROM [RIA].[dbo].[group_details] a,[RIA].[dbo].[GROUP] b,[RIA].[dbo].[cat_team] c WHERE a.[description]=@GROUP AND a.[id_group]=b.[id_group] AND b.[id_team]=c.[id_team]) AND [USER]=@USER AND [statusSAP]IN('Idle') GROUP BY [team],[YEAR],[week] ORDER BY [week]
SELECT * FROM #idlepptC
END
END