Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sub Query
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00886842
Message ID:
00886844
Views:
15
This message has been marked as the solution to the initial question of the thread.
Try (not tested)
SELECT DISTINCT mt1.name, 
		(SELECT COUNT(*) FROM 
			(SELECT TOP 5 * FROM maytable mt2 WHERE mt2.name = mt1.name) dt2 
				WHERE dt2.status = 'somestatus')
	FROM maytable mt1
>Having a table:
> name, status, date
>
>How can I get the count of a particular status from the most recent 5 entries (date) for each name? This needs to be a single SQL statement that is passed to SQL Server.
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform