Link to home
Start Free TrialLog in
Avatar of Loganathan Natarajan
Loganathan NatarajanFlag for India

asked on

Random Data Generation

I have a table in the following structure,

<pre lang="sql">CREATE TABLE [dbo].[RateCard](
    [id] [int] IDENTITY(1,1) NOT NULL,
    [name] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [rate] [money] NULL,
 CONSTRAINT [PK_RateCard] PRIMARY KEY CLUSTERED
(
    [id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF</pre>


<pre lang="sql">insert into ratecard(name,rate)values(&#39;A&#39;,10);
insert into ratecard(name,rate)values(&#39;B&#39;,20);
insert into ratecard(name,rate)values(&#39;C&#39;,25);
insert into ratecard(name,rate)values(&#39;D&#39;,30);
insert into ratecard(name,rate)values(&#39;E&#39;,65);
insert into ratecard(name,rate)values(&#39;F&#39;,65);
insert into ratecard(name,rate)values(&#39;G&#39;,10);
insert into ratecard(name,rate)values(&#39;H&#39;,10);
insert into ratecard(name,rate)values(&#39;I&#39;,20);
insert into ratecard(name,rate)values(&#39;J&#39;,10);
insert into ratecard(name,rate)values(&#39;K&#39;,10);
insert into ratecard(name,rate)values(&#39;L&#39;,15);
insert into ratecard(name,rate)values(&#39;M&#39;,10);
insert into ratecard(name,rate)values(&#39;N&#39;,50);</pre>


select *From ratecard where rate=10 order by rate

When I run the above query I get the result as follow as

1      A      10.00
7      G      10.00
8      H      10.00
10      J      10.00
11      K      10.00
13      M      10.00

When I run the query for the second time I need the output as

7      G      10.00
1      A      10.00
8      H      10.00
10      J      10.00
11      K      10.00
13      M      10.00


When I run the query for the Third time I need the output as

7      G      10.00
1      A      10.00
10      J      10.00
8      H      10.00
11      K      10.00
13      M      10.00


Each time I run the query I should get the random result. How to do it in SQL Server Query.
ASKER CERTIFIED SOLUTION
Avatar of Louis01
Louis01
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of EvilPostIt
EvilPostIt
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hhhmmmm... just curious... why was my answer (being exactly the same) (and first) (and better formatted) ...;)... not accepted?
How dare you ;)