Skip to content
Advertisement

How to use CASE statement to update data (as fractions) in the table?

Query Table:

Different Fruits Total Fruits Fruits Fraction
3 5
2 6
2 2
4 6
1 1
6 6
6 16
4 20

Updated Table:

Different Fruits Total Fruits Fruits Fraction
3 5 3/5
2 6 2/6
2 2 2/2
4 6 4/6
1 1 1/1
6 6 6/6
6 16 6/6
4 20 4/6

There is a total of 6 different fruits. However, the total fruits per record can be greater than 6.

I want to use a case statement such that:

I do not want to simplify the fraction, probably I think it would use character datatype.

Advertisement

Answer

You could try this:

db<>fiddle link here

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement