How would you write this query

I am querying a table which contains information on volumes of computers and want to get back the latest records for a given computername (pwlComputername). Each record is timestamped (pwlDate) and the table contains multiple records for every timestamp and computer.

Here is what i came up with:

​

SELECT * FROM [Paul].[dbo].[logicaldisk] WHERE pwlComputername = ‘WSUS’

AND pwlDate = (SELECT max(pwlDate) as latest FROM [Paul].[dbo].[logicaldisk] WHERE pwlComputername = ‘WSUS’)

​

It works but I am new to SQL and unsure if this is the right/best way to do this.

Happy about any feedback πŸ™‚

submitted by /u/kortex81
[link] [comments]


Go to Source of this post
Author Of this post: /u/kortex81
Title Of post: How would you write this query
Author Link: {authorlink}