1
I have the table:
| cod | hora | produto | Amostra | Min | Max |
|-----|-------|---------|---------|-----|-----|
| 1 | 08:00 | 96722 | 1 | 100 | 200 |
| 2 | 08:23 | 96721 | 1 | 90 | 90 |
| 3 | 08:50 | 96722 | 2 | 100 | 100 |
| 4 | 09:50 | 96722 | 2 | 100 | 200 |
| 5 | 08:30 | 96721 | 2 | 90 | 90 |
| 6 | 08:28 | 96721 | 1 | 12 | 25 |
I want you to list me like this:
| cod | hora | produto | Amostra | Min | Max |
|-----|-------|---------|---------|-----|-----|
| 2 | 08:23 | 96721 | 1 | 90 | 90 |
| 5 | 08:30 | 96721 | 2 | 90 | 90 |
| 6 | 08:28 | 96721 | 1 | 12 | 25 |
| 1 | 08:00 | 96722 | 1 | 100 | 200 |
| 4 | 09:50 | 96722 | 2 | 100 | 200 |
| 3 | 08:50 | 96722 | 2 | 100 | 100 |
I’m trying to do it that way:
select * from tb_tabela
order by
tb_tabela.produto,
tb_tabela.amostra,
tb_tabela.hora
He’s returning me wrong, as per the bass:
| cod | hora | produto | Amostra | Min | Max |
|-----|-------|---------|---------|-----|-----|
| 2 | 08:23 | 96721 | 1 | 90 | 90 |
| 6 | 08:28 | 96721 | 1 | 12 | 25 | //errado
| 5 | 08:30 | 96721 | 2 | 90 | 90 |
| 1 | 08:00 | 96722 | 1 | 100 | 200 |
| 3 | 08:50 | 96722 | 2 | 100 | 100 | //errado
| 4 | 09:50 | 96722 | 2 | 100 | 200 |
Hi Tiago, I’m not an expert in SQL or anything but the way you want I think there is no way to do... How to run an order by to come 1, 2 ,1 in the Sample column? No other column to sort? Type using Min/Max?
– Raimundo Norberto
Can’t use Min/Max because they can vary.
– Tiago Casanova
What sense would it have in ordering this way? in your example none of the fields has a valid order set to be made.
– Marco Souza