I've been tasked to write some SQL queries for some custom reporting out of our Backup Software.
So far I have got everything down but am struggling to design the last one.
Here is the business requirement:
The last successful backup for each client (date).
So output:
table:
In other words there are 1000's of lines of job history with all fields I would need.
I have tried some sort of query with subquery but having trouble conceptially thinking this through.
It needs to kind of have a get list of all clients, per each client find the starttime when status = success.
I will actually once I figure this out combine this with a query which returns:
client, Type, Status
client1, Windows, Success
I want to add the column LastGood. I figured I write that query separate first to 'figure' it out.
So far I have got everything down but am struggling to design the last one.
Here is the business requirement:
The last successful backup for each client (date).
So output:
Code:
client1 4/1/2010
client2 4/2/2010
client3 4/1/2010
table:
Code:
jobid, clientname, starttime, endtime, status
1 , client1 , 3/20/2010, 3/21/2010, Success
2 , client2 , 3/21/2010, 3/22/2010, Fail
3 , client1 , 3/21/2010, 3/22/2010, Success
4 , client2 , 3/20/2010, 3/21/2010, Success
In other words there are 1000's of lines of job history with all fields I would need.
I have tried some sort of query with subquery but having trouble conceptially thinking this through.
It needs to kind of have a get list of all clients, per each client find the starttime when status = success.
I will actually once I figure this out combine this with a query which returns:
client, Type, Status
client1, Windows, Success
I want to add the column LastGood. I figured I write that query separate first to 'figure' it out.