Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Select Same row X number of times Expand / Collapse
Author
Message
Posted Friday, December 10, 2010 3:59 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, December 6, 2012 7:26 AM
Points: 6, Visits: 60
I am trying to do a monte carlo simulation within SQL

I have a table containing unique product numbers, and what I want to do, is return each product 10'000 times with a random number next to it;

I can return one row for each product with

SELECT
prodmo,
rnd=(SELECT RAND((convert(varbinary, newid()))))
FROM
PriceMoveDemo


Post #1032921
Posted Friday, December 10, 2010 4:08 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: 2 days ago @ 1:33 AM
Points: 1,949, Visits: 8,310
Something like this ? ...


with cteRand
as
(
Select top(1000) abs(checksum(newid())) as Rand
from sys.columns a cross join sys.columns b cross join sys.columns b
)
Select *
from <yourtable> cross join cteRand





Clear Sky SQL
My Blog
Kent user group
Post #1032928
Posted Monday, December 13, 2010 3:48 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, December 6, 2012 7:26 AM
Points: 6, Visits: 60
Cheers that has seemed to do the trick
Post #1033677
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse