Help with SQL query

Database

Help with SQL query

Col1 Col2

D1 K1
D2 K1
D2 K2
D3 K2
D2 K3
-D1 K2

I have the above data. I want the output as

D1 KI
or
-D1 K2
or
D2 K3

Reason being all of them are linked to one another and hence i need any of the above combination. Any help with SQL would be highly appreciated

Thanks
Rajiv

4 REPLIES
Enthusiast

Re: Help with SQL query

hi

Am not getting what you want

you only one record or what else

can you please clear for your need.

Re: Help with SQL query

Yes I only want one record.
Enthusiast

Re: Help with SQL query

Hi

If you just need one sample ouput for a combination, you can use sample function.

select * from tablename where col=value sample 1;
Enthusiast

Re: Help with SQL query

Hi

Otherwise you can use this

select top 1 * from table_name