There is my table look like
id | name | deduction | amount |
---|---|---|---|
01 | teat | Home Rent | 1000 |
01 | test | GPF | 500 |
i want show my data in deduction report like below table
id | name | home_rent | gpf |
---|---|---|---|
01 | teat | 1000 | 500 |
mysql code
SELECT a.* , a.amount as home_rent ,b.amount as gpf FROM my_table as a ,my_table as b where a.deduction = Home Rent and b.deduction = GPF
what i have done wrong please let me know ? what can i do for my report to it look like my second table thank you …
2
Answers
We can use conditional aggregation and pivoting here:
use conditional aggregation
Schema (MySQL v5.7)
Query #1
View on DB Fiddle