Skip to primary content
Skip to secondary content

Aspirant Coder

Nothing to see here, move along, this is just a coding playground…

Main menu

  • Home
  • About

Tag Archives: random

Sybase : How to select random number within a specific range?

Posted on December 24, 2012 by admin
Reply

Let’s say, I need a random number within a specific range, how do I do that?

Here’s the code that will do it:

1> DECLARE @i_min int
2> DECLARE @i_max int
3> SELECT  @i_min = 0
4> SELECT  @i_max = 10
5> SELECT MY_RANDOM_NUMBER = ROUND(((@i_max - @i_min) * RAND() + @i_min), 0)
6> go
 MY_RANDOM_NUMBER
 --------------------
             7.000000
Posted in Sybase | Tagged random, SQL, Sybase | Leave a reply

Recent Posts

  • Sybase : How to check programmatically if index contains particular column?
  • Sybase : How to disable return status when executing stored procedure?
  • Sybase : How to select random number within a specific range?
  • Sybase : How to count number of rows in a table – demystified
  • How to trace user activity to a file in SAP Sybase ASE

Categories

  • APT (1)
  • shell (1)
  • Sybase (6)
  • Uncategorized (1)

Archives

  • May 2013 (1)
  • January 2013 (1)
  • December 2012 (5)
  • November 2012 (2)

Blogroll

  • Sybase Performance & Relational Database
  • Sybase ASE Performance and Tuning

Recommended

  • Sybase Infocenter
  • SybaseTeam
  • Sypron

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
Proudly powered by WordPress