Hi all I'm trying to find a way to select min or max from a range of data based on conditions. If setuptime and processtime cols are all O select MIN(oprNum) (operation hasn't started yet so get first oprnum) if setuptime and process time are not 0, get max oprnum (active operation). based on either of these I want ONE row... please see attached example of data. Thanks! This is part of a much larger query so i need 1 output row per prodid...
+------------+--------+---------+--------------------+--------------------+
| ProdId | OprNum | Company | SetupTime | ProcessTime |
+------------+--------+---------+--------------------+--------------------+
| 12M0003381 | 10 | 12 | 1.3400000000000000 | 1.6100000000000000 |
+------------+--------+---------+--------------------+--------------------+
| 12M0003381 | 10 | 12 | 0.0000000000000000 | 0.0000000000000000 |
+------------+--------+---------+--------------------+--------------------+
| 12M0003381 | 15 | 12 | 1.0000000000000000 | 0.0000000000000000 |
+------------+--------+---------+--------------------+--------------------+
| 12M0003381 | 50 | 12 | 0.0000000000000000 | 0.0000000000000000 |
+------------+--------+---------+--------------------+--------------------+
| 12M0003381 | 60 | 12 | 0.0000000000000000 | 0.0000000000000000 |
+------------+--------+---------+--------------------+--------------------+
| 12M0003381 | 60 | 12 | 0.0000000000000000 | 0.0000000000000000 |
+------------+--------+---------+--------------------+--------------------+
| 12M0003381 | 70 | 12 | 0.0700000000000000 | 0.0400000000000000 |
+------------+--------+---------+--------------------+--------------------+
| 12M0003381 | 70 | 12 | 0.0000000000000000 | 0.0000000000000000 |
+------------+--------+---------+--------------------+--------------------+
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire