1

我有一个这样的表,我想在 25 个用户中选择 12 个组,但用户不能在任一列中出现多次。这是为了我的研究工作。

userx   usery   final
user1   user9   0
user2   user21  0
user3   user20  1.86603810646243E-02
user4   user14  0
user5   user13  0
user6   user12  0
user7   user11  0
user8   user10  0
user9   user23  5.2301255230118E-03
user10  user12  5.13300861745978E-02
user11  user15  1.6096147655314E-03
user12  user19  2.1337126600292E-03
user12  user22  2.1337126600292E-03
user13  user18  3.3259423503309E-03
user14  user21  7.657805491741E-04
user15  user16  5.4939136055145E-03
user16  user21  5.3359468583246E-03
user17  user18  1.49153302680261E-02
user18  user21  0.004619445666522
user19  user22  0
user20  user24  2.6088701585401E-03
user21  user23  2.01673460630756E-02
user22  user23  0.05878423513694
user23  user24  2.21079691516702E-02
user24  user25  4.57905347028916E-02
4

2 回答 2

0

我认为这就是你想要的:

SELECT top 12 u.userx, u.usery
FROM usergroups u
WHERE u.usery not in (
    select top 12 userx 
    from usergroups x 
    order by x.userx,x.usery)
ORDER BY u.userx, u.usery;

这将选择 userx 列中未包含 usery 的 12 条记录。

于 2012-09-27T11:02:03.633 回答
0
select distinct userx, usery
from your_table
于 2012-09-27T10:32:52.203 回答