lokesha.b (10/16/2012)
Hi,Please suggest me to get the distinct values from below query
declare @T as table(id int identity, code varchar(10))
insert into @T(code) values('111')
insert into @T(code) values('111')
insert into @T(code) values('222')
insert into @T(code) values('222')
insert into @T(code) values('333')
select * from @T
I want the result as
------------------
111
222
333
For what you're showing, the others are correct. DISTINCT will do it.
The real question is, what are you actually doing? I ask because the use of DISTINCT is a usual indication that a joined query was written incorrectly or the underlying database design really needs some work.
--Jeff Moden
Change is inevitable... Change for the better is not.