June 3, 2011 at 7:46 am
idCODE
1 ABC11
1 ABC12
2 ABC11
2ABC12
3ABC11
3 ABC12
4 ABC11
5ABC11
6ABC11
6ABC12
7ABC12
AND i NEDD A OUTPUT LIKE
idCODE
1 ABC11
2 ABC11
3ABC11
4 ABC11
5ABC11
6ABC11
7ABC12
I want a output based on ID..... i have no problem with code is selectd..
Please help me
Thanks
L
June 3, 2011 at 8:04 am
You have to group your data on one or more columns:
;WITH SampleData
AS (
SELECT *
FROM (VALUES
(1, 'ABC11'),
(1, 'ABC12'),
(2, 'ABC11'),
(2, 'ABC12'),
(3, 'ABC11'),
(3, 'ABC12'),
(4, 'ABC11'),
(5, 'ABC11'),
(6, 'ABC11'),
(6, 'ABC12'),
(7, 'ABC12')
) AS InputData (Id, Code)
)
SELECT Id, MIN(Code) AS Code
FROM SampleData
GROUP BY Id
ORDER BY Id
Hope this helps
Gianluca
-- Gianluca Sartori
June 3, 2011 at 8:11 am
Thanks:-)
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply