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)
 Query help

Author  Topic 

tneken
Starting Member

4 Posts

Posted - 2009-06-22 : 09:18:02
Hi.
I need help to create a query. I need to get the fastest processingtime for each program on each machine.
The table look like this

machine_id program process_time
A 1 20
A 1 22
B 1 40
B 1 38
A 2 24
A 2 25
A 1 23
B 2 45

The result i need should look like this.
A 1 20
A 2 24
B 1 38
B 2 45

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-06-22 : 09:24:34

select machine_id, program, min(process_time) as process_time from your_table
group by machine_id, program


Madhivanan

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

tneken
Starting Member

4 Posts

Posted - 2009-06-22 : 10:03:19
Thank you. It was just what i needed
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-06-22 : 10:19:56
quote:
Originally posted by tneken

Thank you. It was just what i needed


You are welcome

Madhivanan

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

- Advertisement -