Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
MIN - DateTime issue
Message
 
 
À
25/04/2005 15:11:06
Alvin Lourdes
Children and Youth Services Cluster
Toronto, Ontario, Canada
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01008193
Message ID:
01008276
Vues:
15
This message has been marked as the solution to the initial question of the thread.
Try
SELECT * FROM mytable mt1
	WHERE mt1.DaysOff = 2 
		AND NOT EXISTS ( SELECT * FROM mytable mt2
				WHERE mt2.DaysOff = 2 
					AND mt2.CustomerID <> mt1.CustomerID
					AND mt2.DateRegistered < mt1.DateRegistered)
-- or

SELECT TOP 1 * FROM mytable mt1
	WHERE mt1.DaysOff = 2 
	ORDER BY DateRegistered
>
>TABLEA
>-------
>CustomerID -unique identifier
>Name - varchar
>DateRegistered - datetime
>#ofDaysOff - int
>#FreeDaysOff - int
>
>My problem is that I need to get to get the employeeid of most senior employee with a criteria of 2 days off.
>
>I have tried this query but I dont get the correct date
>
>DECLARE @customerid as varchar(100)
>SELECT @customerid = customerid, MIN(DateRegistered) FROM
>TABLEA WHERE #ofDaysOff = 2
>GROUP BY customerid
>
>
>Thanks for your help.
>
>A
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform