I want to show my data in this format, data view client, And my Database structure is in this format, Sql View
EDITED I want to show my data in this format,
Name (Father name) Jan (PKR) Feb (PKR) Mar (PKR) Apr (PKR)
castiel(siddiqui) 20110
Gull(yasal) 20010
And my DB structure is
c_id name salary ds_id amount date_time
3 abc 20000 1 20010 2023-01-07
4 abc 20000 2 20010 2023-01-07
5 abc 20000 3 20010 2023-01-07
6 abc 20000 4 20010 2023-01-07
6 abc 20000 5 20011 2023-02-07
I created this sql query without join to just check if I can, but no joy
SELECT courier.name
,MAX(IF(DATE_FORMAT(dis_salary.date_time,'%Y-m')='2023', dis_salary.amount,NULL)) as salary
FROM dis_salary
JOIN courier ON courier.c_id=dis_salary.courier_id
GROUP BY courier.c_id
I don't want to show max or sum, and all the dates are variable, so cant hardcode
I want to show each salary given to courier w.r.t month
Also the project is in PHP CodeIgniter, if that helps
output i want
name | month1 | month2 |
---|---|---|
abc | 20010 | 20011 |