Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL question
Message
 
 
À
06/08/2009 11:38:14
Walter Meester
HoogkarspelPays-Bas
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:
01416519
Vues:
38
If you mean this message, then it doesn't solve the problem either.
	create cursor Schnaps ;
	(	c1	c(1), ;
		c2	c(1),; 
		c3	c(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') && added
	insert into Schnaps values ('B', 'e', '4') && added
	insert into Schnaps values ('B', 'f', '4') && added
	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 1 ;
*!*		HAVING COUNT(distinct(c1+c2)) > 1) X ON T.c3= X.c3 
	
	select S.* ;
		from Schnaps S, ;
			( ;
				select c3 ;
					from Schnaps ;
					group by  1 ;
					having ( count( distinct c1 + c2 ) > 1) ;
			) AA ;
			where	( S.c3 == AA.c3 )
			
SELECT * FROM Schnaps WHERE C3 IN (SELECT C3 FROM (SELECT DISTINCT C1, C2, C3 FROM Schnaps)  X GROUP BY C3 HAVING COUNT(*) > 1)			
>Hi Agness,
>
>How about
>
SELECT C3 FROM (SELECT DISTINCT C1, C2, C3 FROM Schnaps)  X GROUP BY C3 HAVING COUNT(*) > 1
>
>and
>
>
SELECT * FROM Schnaps WHERE C3 IN (SELECT C3 FROM (SELECT DISTINCT C1, C2, C3 FROM Schnaps)  X GROUP BY C3 HAVING COUNT(*) > 1)
>
>Walter,
>
>>Hi All,
>>
>>I have a SQL problem I have no idea if I can solve it with one select (I can do with two, but this is not what i like to have)
>>
>>The problems comes from an import scenario.
>>
>>I have a table like
>>
>>c1   c2  c3 ...
>>A    a    1
>>A    b    2
>>A    b    3
>>B    c    4
>>B    d    4
>>A    b    3
>>
>>
>>For a given c3 the combination of c1 and c2 should be the same. We can see that for c3=4 this is not true.
>>
>>How do I code a single SELECT SQL that returns just
>>
>>
>>c1   c2  c3
>>B    c    4
>>B    d    4
>>
>>
>>and
>>
>>
>>c3
>>4
>>
>>
>>
>>TIA
>>
>>Agnes
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