SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Populating a departure date field which is after t
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Yak Posting Veteran

75 Posts

Posted - 02/20/2013 :  09:13:01  Show Profile  Reply with Quote

0down votefavorite

I have just been told I have done it completely wrong by my boss and the query above hasn't randomised anything on our data, I have got 48000 records with a 2 night stay, 48000 records for a 27 night stay etc.

What I need is 30% of the departure dates to be 2 days in length, 10% of the departure dates to be 3 Days in length and the rest to be randomised amongst 1, 4 to 28. I know it involves case statement but I don't know how to do them.

Can anyone help?
Update bookings
Set DepartureDate = DATEADD(day, 1 + RAND(CHECKSUM(NEWID()))*28, ArrivalDate)
SELECT * FROM bookings


  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000