Basically I have a MySql table
-------- ----------- --------
cv_id all_stages amount
-------- ----------- --------
12 S1 5
13 S4 2
13 S2 1
14 S1 3
14 S3 2
I have to write a query so that, based oncv_id
, I need to have a single entry. And I need to generate few more columns.
What I want is
-------- --------- -------- -------- -------- -------
cv_id stage1 stage2 stage3 stage4 total
-------- --------- -------- -------- -------- -------
12 S1 5
-------------------------------------------------------------
13 S2 S4 3
-------------------------------------------------------------
14 S1 S3 5
-------------------------------------------------------------
How should I arrange all stages to the respective stage
columns based on cv_id and totaling the amount
column?
P.S - I need to execute query to generate new columns