Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Selection problem
Message
 
 
À
29/06/2011 08:48:04
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01516648
Message ID:
01516670
Vues:
31
>>I believe you need to reverse the condition, e.g.
>>
>>;with cte as (select T.*, row_number() over (order by NewID()) as RandomRow 
>>from Test T where not exists (select 1 from Test T2 where T.FamilyID = T2.PartnerID))
>>
>>select * from cte where RandomRow <=4
>>
>>The above is from the top of my head - and may be a bit slow.
>
>
>With such cross data (if you see Nicholas has the same IDs in BOTH fields) you wouldn't get any rows.

Good point.

I will need to think about it more - it's not very trivial.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform