944,129 Members | Top Members by Rank

Ad:
  • MS SQL Discussion Thread
  • Unsolved
  • Views: 4458
  • MS SQL RSS
May 16th, 2006
0

How can I select records randomly from MS SQL Server Table?

Expand Post »
I have a table in MS SQL Server 7.0 Like this:

Id Cat_Name Definition Image
101 A1 --------------- *************
102 B1 ----------- *************
101 A2 ------------------ *************
103 C1 ----------------- *************
101 A3 --------------- *************
101 A4 ------------------ *************
102 B2 -------------------- *************
101 A5 -------------- *************
101 A6 ----------------- *************


From above table, How can I select 3 – 5 records where iId is 101. Means result should be:
<<101>><<A3>>----------------<<***********>>
<<101>><<A4>>----------------<<***********>>
<<101>><<A5>>----------------<<***********>>
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jas2k is offline Offline
1 posts
since May 2006
May 16th, 2006
0

Re: How can I select records randomly from MS SQL Server Table?

might be able to help you with this but need a few questions answered.
1) I am assuming that ID+Cat_Name is unique, in other words, there cannot be two 101 A1 entries. is this correct?
2) what are specifications for the Cat_Name field? Is it always exactly two characters(one letter and then one number) or can it be one letter followed by any integer, etc.
3) you said 3-5 rows returned. Do you want that number random as well, or can it be the same number of rows returned everytime as long as that number is between 3-5?
Reputation Points: 14
Solved Threads: 19
Posting Pro in Training
campkev is offline Offline
484 posts
since Jul 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MS SQL Forum Timeline: In-line If-Else Block?
Next Thread in MS SQL Forum Timeline: A simple question about hot key





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC