Hi..
could somebody hep me about my query ?..
I want to display and count some values from the 2 tables.But I do not know how to count the records and display the result in different column of the output.
I have try to execute the query and i got an error message as below:-
Code:
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 34
Execution Time : 00:00:00:000
Transfer Time : 00:00:00:000
Total Time : 00:00:00:000
Below is my query:-
Code:
SELECT
cs.request_id AS "JOB REQUEST NO",
cs.target_sla_sdate AS "TARIKH",
cs.target_sla_stime AS "MASA",
pt.FieldID2 AS "NAMA FAIL",
MIN(TRIM(pt.FieldID6)) AS "AKAUN MULA",
MAX(TRIM(pt.FieldID6)) AS "AKAUN AKHIR",
COUNT(pt.JobTIcketID) AS "JUMLAH AKAUN",
(SELECT (SELECT COUNT(1) FROM packextra_trans pt, customerjobrequest cs
WHERE cs.JobTicketID = pt.FieldID1
AND pt.FieldID3 BETWEEN "94" AND "195") AS "TOTAL RM2.00",
(SELECT (SELECT COUNT(1) FROM packextra_trans pt, customerjobrequest cs
WHERE cs.JobTicketID = pt.FieldID1
AND pt.FieldID3 BETWEEN "34" AND "93") AS "TOTAL RM1.00",
(SELECT COUNT(1) FROM packextra_trans pt, customerjobrequest cs
WHERE cs.JobTicketID = pt.FieldID1
AND pt.FieldID3 BETWEEN "94" AND "195") AS "TOTAL RM0.75",
(SELECT COUNT(1) FROM packextra_trans pt, customerjobrequest cs
WHERE cs.JobTicketID = pt.FieldID1 AND (SUBSTR(TRIM(pt.FieldID2),20,2) = "PC"
OR SUBSTR(TRIM(pt.FieldID2),20,2) = "PB")) AS "TOTAL RM 0.40",
(SELECT COUNT(1) FROM packextra_trans pt, customerjobrequest cs
WHERE cs.JobTicketID = pt.FieldID1
AND (SUBSTR(TRIM(pt.FieldID2),20,2) = "PA")) AS "TOTAL RM0.30",
(SELECT COUNT(1) FROM packextra_trans pt, customerjobrequest cs
WHERE cs.JobTicketID = pt.FieldID1) AS "TOTAL POSLAJU"
FROM packextra_trans pt, customerjobrequest cs
WHERE cs.JobTicketID = pt.FieldID1
AND cs.request_id = "201001-011"
GROUP BY pt.JobTicketID
;
Otherwise, is it a good way to do the calculation or do you a better solution.
Please help me.
Thank you,
Baharin