Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SPT Statement For a Particular Record from a Set
Message
De
14/10/2016 16:39:59
 
 
À
14/10/2016 15:38:30
Steven Dyke
Safran Seats USA
Texas, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2008 R2
Network:
Windows Server 2008 R2
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01641968
Message ID:
01641970
Vues:
62
This message has been marked as the solution to the initial question of the thread.
>I have a table where a job number field can have multiple records. It has a field also that holds an archive flag.
>
>I need a SQL statement that will only result in a list of job numbers that when grouped together not one of them has an archive flag value of 0.
>
>The following will give me job numbers that I do not desire. Because for instance job number MES4000 is listed 3 times with two records with archive flag set to 1 an one record set to 0.
>So I would not want this in my result.
>
>
>
>testconnString = "Select Distinct jobno, archivef From webprddt1.resmngta0" +;
>				" Where posstr(jobno,'MES') > 0 And archivef = 1"
>
>
CREATE CURSOR Jobs (JobNo c(10), archiveF N(1))

INSERT INTO Jobs VALUES ('MES0', 1)
INSERT INTO Jobs VALUES ('MES1', 0)
INSERT INTO Jobs VALUES ('MES1', 1)
INSERT INTO Jobs VALUES ('MES2', 1)
INSERT INTO Jobs VALUES ('MES2', 1)
INSERT INTO Jobs VALUES ('MES3', 1)

SELECT DISTINCT JobNo, archiveF FROM Jobs WHERE PosStr(JobNo, 'MES') > 0 AND JobNo NOT in (SELECT JobNo FROM Jobs WHERE archiveF = 0)

FUNCTION PosStr (source AS String, locate AS String) AS Integer

	RETURN VAL(SUBSTR(m.source, AT(m.locate, m.source) + LEN(m.locate)))
	
ENDFUNC
----------------------------------
António Tavares Lopes
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform