CRoshanLG
CRoshanLG

Reputation: 498

SQL query to select an integer randomly from a given list of integers?

I have a list of integers resulting from a SELECT query.

The list of integers is not sequential! For example it might contain values like

 1,2,3,8,12,17,20,23,28,30,...

I want to select one integer randomly from that list! How do I do this?

Upvotes: 0

Views: 124

Answers (1)

John Woo
John Woo

Reputation: 263933

based on your statement: "select one integer randomly from that list", you can use NEWID() on this case.

SELECT TOP 1 colName
FROM tableName
ORDER BY NEWID()

Other Link(s)

Upvotes: 2

Related Questions