Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Need Help with SELECT

Author  Topic 

sanlen
Starting Member

29 Posts

Posted - 2008-11-20 : 23:16:28
Hi All,

i have the value as below:

1 A
2 B
3 C
3 D
3 E
1 F
2 G
1 H

I want to disply just only as below:

1 A
1 F
1 H

or

2 B
2 G

Could you please advise?

Thanks you very much for your time.




Best Regard,
SANLEN

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2008-11-20 : 23:46:43
SELECT * FROM yourtable WHERE SrNo = 1 ORDER BY description;

Note:
SrNo = 1,2,3,1,5,6,7
Description = a,b,c,d,e,f
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-21 : 01:43:16
Make a procedure as below

CREATE PROC GetData
@ID int
AS
SELECT *
FROM YourTable
WHERE ID=@ID
ORDER BY CharField
GO

then call it with your reqd id to get only values you need like

EXEC GetData 1

gives you

1 A
1 F
1 H

EXEC GetData 2
gives you

2 B
2 G
...
Go to Top of Page
   

- Advertisement -