Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL question
Message
 
 
À
06/08/2009 08:59:24
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Database:
Visual FoxPro
Divers
Thread ID:
01416401
Message ID:
01416664
Vues:
64
This message has been marked as a message which has helped to the initial question of the thread.
Hi Agnes & Gregory,

With some external help I was able to solve this problem. I used SQL Server (don't have VFP at home).
DECLARE @Schnaps TABLE 
    (   c1  CHAR(1), 
        c2  CHAR(1), 
        c3  CHAR(1) 
    )
    
    INSERT INTO @Schnaps VALUES ('A', 'a', '1')
    INSERT INTO @Schnaps VALUES ('A', 'b', '2')
    INSERT INTO @Schnaps VALUES ('A', 'b', '3')
    INSERT INTO @Schnaps VALUES ('B', 'c', '4')
    INSERT INTO @Schnaps VALUES ('B', 'c', '4')
    INSERT INTO @Schnaps VALUES ('B', 'd', '4')
    INSERT INTO @Schnaps VALUES ('B', 'e', '4') 
    INSERT INTO @Schnaps VALUES ('B', 'e', '4') 
    INSERT INTO @Schnaps VALUES ('B', 'f', '4') 
    INSERT INTO @Schnaps VALUES ('A', 'b', '3')
    /*
    SELECT T.* FROM @Schnaps T INNER JOIN 
    (SELECT c3, MIN(c1) AS c1_min,MAX(c1) AS c1_max, 
    MIN(c2) AS c2_min, MAX(c2) AS c2_max FROM @Schnaps X GROUP BY c3
    HAVING COUNT(DISTINCT(c1+c2)) > 1) X ON T.c3= X.c3
    */
    SELECT t1.*
   FROM @Schnaps t1 join(
    SELECT c1,c2,c3 FROM @Schnaps T
    GROUP BY c1,c2,c3 HAVING COUNT(*) =1) t2 ON t1.c3 =t2.c3 and t1.c2 =t2.c2
    and t1.c1 =t2.c1 WHERE t1.c3 in (SELECT c3 FROM @Schnaps X GROUP BY c3
    HAVING COUNT(DISTINCT(c1+c2)) > 1)
If it's not broken, fix it until it is.


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

Click here to load this message in the networking platform