Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Select help
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
00153136
Message ID:
00153250
Vues:
24
Hi Virusim,
This should work for you I think, just so long as the time_in date is always the same as the time_out date like you showed in your example table data. It wasn't really a SELECT-UNION but rather a tricky inner join. I set up a table with the same structure you posted called TimeTest and the following queries got me the right result. Perhaps somebody else here might have a suggestion how to combine some of these steps or make this shorter.
SELECT emp_id, DTOC(time_in) as The_Date, ;
  TTOC(time_in,2) as Time_In, latness ;
	FROM timetest a WHERE TTOC(time_in,2) IN( ;
		SELECT MIN(TTOC(time_in,2)) ;
			FROM timetest b WHERE a.emp_id=b.emp_id ;
			AND DTOC(time_in)=DTOC(b.time_in) ;
			) ;
  INTO CURSOR MinValues

SELECT emp_id, DTOC(time_in) as The_Date, ;
  TTOC(time_out,2) as Time_Out, overtime ;
	FROM timetest a WHERE TTOC(time_out,2) IN( ;
		SELECT MAX(TTOC(time_out,2)) ;
			FROM timetest b WHERE a.emp_id=b.emp_id ;
			AND DTOC(time_in)=DTOC(b.time_in) ;
			) ;
  INTO CURSOR MaxValues

SELECT a.emp_id, a.the_date, a.time_in, b.time_out, a.latness, b.overtime ;
	FROM MinValues a, MaxValues b ;
	WHERE a.emp_id=b.emp_id AND a.the_date=b.the_date ;
	INTO CURSOR SomeResult
HTH
Roxanne M. Seibert
Independent Consultant, VFP MCP

Code Monkey Like Fritos
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform