quote: Originally posted by Sachin.Nand
quote: Originally posted by Transact Charlie IN WHAT POSSIBLE WAY IS THIS VERY UREGENT?Is your server down because of this? No.You want to run some sort of report. Not urgent at all.Looks like you want a count of the distinct YesCounts per Company / Region.So a derived table with a group by and a COUNT is what you want.Work out the rest yourself.Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
You dont seem to be in a good mood today PBUH
Don't like URGENT when its not. And I'm getting a lot of **** today at work.itnagaraj: Sorry for being grumpy. Does this work for you?DECLARE @foo TABLE ( [Company] VARCHAR(255) , [Region] VARCHAR(255) , [ServiceType] CHAR(3) , [MTDCount] INT , [YesCount] VARCHAR(255) )INSERT @foo SELECT 'Maruti', NULL, 'BUG', 0, 'IM17778'UNION SELECT 'Maruti', NULL, 'BUG', 0, 'IM17813'UNION SELECT 'Maruti', NULL, 'BUG', 0, 'IM17828'UNION SELECT 'Maruti', NULL, 'BUG', 0, 'IM17873'UNION SELECT 'Maruti', NULL, 'BUG', 0, 'IM17873'UNION SELECT 'Maruti', NULL, 'BUG', 0, 'IM17909'UNION SELECT 'Maruti', NULL, 'BUG', 0, 'IM17909'SELECT [Company] , [Region] , [ServiceType] , [MTDCount] , COUNT(DISTINCT([YesCount])) AS [YesCount]FROM @fooGROUP BY [Company] , [Region] , [ServiceType] , [MTDCount] Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |