I Have sql table like this:
Table A
NIP BIDANG MAYOR MINOR
1 A ZZ YY
2 A ZZ XX
2 A YY
and i have another table :
Table B
NIP Keahlian Nilai
1 XX 2
1 YY 0
1 ZZ 3
2 XX 4
2 YY 2
2 ZZ 3
Table C
NIP Score Limit
1 10 15
2 20 15
Based on that table, i want to create a table with conditional statement like this : if socre <= limit, than saran = xxx else saran = group concat from mayor minor but sorted by the high value in coloumn Nilai in Table B. So, the output like this :
NIP Saran
1 XXX
2 XX, ZZ, YY
How to make it, please help me.