From Table
Name GroupID
a Null
b 1
c 1
d 2
e Null
f Null
g 3
Result expected from random top 4 selection
Name GruopID
a Null
b 1
e Null
g 3
Resuming I want to get random names but only 1 kind of groupid if groupid is <> null
The select Newid() type returns
“Select Top(4) * FROM Table Order By NEWID()”
Name GruopID
a Null
b 1
e Null
c 1
I don´t want that. Hope i made my self clear!
Thanks in advance
You can try this (on SQL Server 2005+).