sql server - Random Variable Selection in SQL -


i have seen few questions this, nothing has answered i'm looking for.

i have 5,000 rows of data on 3 years. every line has memberid, memberids repeat , unique individual (but repeat in column if individual in system multiple times on 3 years).

how can pull 100 random memberids on course of 3 years? (so theoretically there more 100 lines because memberids can repeat)

edit: should clarify, member id character, not numeric. ex: w4564

note: not looking n rows, rather 100 different ids on course of 3 years, id might associated 3 rows in result. result have differing number of rows each time sql run.

depending on how data indexed, grab rows memberid subquery. example:

select * <yourtable> memberid in (select distinct top 100 memberid <yourtable>) 

that should return random memberids, depending on index. if need force it, can in linked question in comments, , sort randomly:

select * <yourtable> memberid in (select distinct top 100 memberid <yourtable> order newid()) 

Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -