mardi 26 octobre 2021

My sql query joining multi table and getting the required output

I have column

weight_in_GM

400
335
656
2525

I have to calculate the weight from gram to in kg so I did this

round(Weight_in_gm/1000, 1) as Total_weight_as_per_X_KG

now I need categories the kg weights in 4 parts In a separate column with this condition

  • If the total weight is 950 gram then weight slab should be 1
  • If the total weight is 1 KG then weight slab should be 1
  • If the total weight is 2.2 KG then weight slab should be 2.5

So the output will look like this

Total_weight_as_per_X_KG| weight_slab |
                        |             |
400                     | 0.5         |
335                     | 0.5         |
656                     | 1           |
2525                    | 2.5         |

Aucun commentaire:

Enregistrer un commentaire