Link to home
Start Free TrialLog in
Avatar of Morpheus7
Morpheus7

asked on

Select random percentage

Hi,

Consider the following table structure:
Group_Code (INT) Prod_Code(INT) TestPoint(SMALLINT)Test_Date(DATETIME) ExportID(INT)

Group_Code,Prod_Code, TestPoint and Test_Date are the primary key.

The exportID could be entered multiple times. For example:

Group_Code  Prod_Code TestPoint Test_Date  ExportID
23456                78654           1            15 Jun 14    12345
23456                78654           2            15 Jun 14    12345
23456                78654           3            15 Jun 14    12345
23456                78654           4            15 Jun 14    12345
23456                78654           1            17 Jul 14     23456
23456                78654           2            17 Jul 14     23456
23456                78654           3           17 Jul 14      23456
Same Group_Code same Prod_Code but different Test_Date generates a different ExportID.
Is there a way that I can select a random 10percent of the export ids together with the other columns in the table. There could be in excess of 100 rows containing the same ExportID and I would need to gather all of the 10percent. So if one of the random percent was 12345, I would neeed to be able to select all 4 rows with that ExportID.

Any guidance would be appreciated.
Thanks
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Morpheus7
Morpheus7

ASKER

Hi Guy,

Many thanks for your reply, that's great. Just one thing, what is the significance of sq just before the order by.

Thanks
the "sq" is the alias to the subquery