Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Last time a task happened for a given computer

Author  Topic 

pareshmotiwala
Constraint Violating Yak Guru

323 Posts

Posted - 2009-10-08 : 10:46:03
folks I have a table T1 with 20 fields.
Three of the fields are
COMPUTER_NAME
COMPUTER_TASK
TIMESTAMP_OF_TASK
The dataset can be as follows
Computer_name Computer_task Timestamp_of_task
Paresh_PC reboot time1
Paresh_PC patched time2
Paresh_PC infected time3

Paresh_laptop cured time1
Paresh_laptop reformatted time2

Paresh_server bought time1
Paresh_server installed time2

and so on.
What I have been asked to do is to come back with a query that would say what is the last computer_task that was performed to each of the computers.

Any ideas?
As usual, any help is welcome
Paresh

Regards
Paresh Motiwala
Boston, USA

waterduck
Aged Yak Warrior

982 Posts

Posted - 2009-10-08 : 13:37:09
SELECT Computer_name, Computer_task, MAX(Timestamp_of_task)
FROM <tablename>


Hope can help...but advise to wait pros with confirmation...
Go to Top of Page

pareshmotiwala
Constraint Violating Yak Guru

323 Posts

Posted - 2009-10-08 : 13:49:48
Thanks for the input Waterduck.
When I do this I get almost all the rows back. mainly because each of the computer task is different and in quick succession.


Regards
Paresh Motiwala
Boston, USA
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-10-09 : 02:52:01
What is your expected result?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -