M
myopic_chaos
Guest
I am having a problem with syntax:
the feild is "internal_status" , another feild is "amount", and another is "Level_date"
The possible contents of "internal_status" is "untouched", "Returned", "Pending", and "Waiting John"
$query = "SELECT file_level_history.Level_Date,
SUM(file_level_history.Amount) AS 'Total Of Amount',
SUM(CASE Internal_status WHEN 'Pending' THEN Amount END CASE ) AS'Pending1',
SUM(CASE Internal_status WHEN 'Returned' THEN Amount END CASE )as 'Returned1',
SUM(CASE Internal_status WHEN 'Untouched' THEN Amount END CASE )as 'Untouched1',
SUM(CASE Internal_status WHEN 'Waiting John' THEN Amount END CASE) as 'WJ'
FROM file_level_history
WHERE file_level_history.Level_Date>='$start_date' And file_level_history.Level_Date<='$end_date'
GROUP BY file_level_history.Level_Date";
I want the end result to look like this:
Pending Returned Untouched Waiting John
1/1/08 4 6 8 1
1/2/08 6 10 9 6
There is somethign wrong with my CASE in the SQL.. Any ideas?
returnign this error:
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 'CASE ) AS'Pending1', SUM(CASE Internal_status WHEN 'Returned' THEN Amount END C' at line 1
THAT WAS IT!!!!
I removed the END and it worked... THANKS!!!!.. You get best answer in 3 hours 15 minutes....
ER- I removed "CASE" after END
the feild is "internal_status" , another feild is "amount", and another is "Level_date"
The possible contents of "internal_status" is "untouched", "Returned", "Pending", and "Waiting John"
$query = "SELECT file_level_history.Level_Date,
SUM(file_level_history.Amount) AS 'Total Of Amount',
SUM(CASE Internal_status WHEN 'Pending' THEN Amount END CASE ) AS'Pending1',
SUM(CASE Internal_status WHEN 'Returned' THEN Amount END CASE )as 'Returned1',
SUM(CASE Internal_status WHEN 'Untouched' THEN Amount END CASE )as 'Untouched1',
SUM(CASE Internal_status WHEN 'Waiting John' THEN Amount END CASE) as 'WJ'
FROM file_level_history
WHERE file_level_history.Level_Date>='$start_date' And file_level_history.Level_Date<='$end_date'
GROUP BY file_level_history.Level_Date";
I want the end result to look like this:
Pending Returned Untouched Waiting John
1/1/08 4 6 8 1
1/2/08 6 10 9 6
There is somethign wrong with my CASE in the SQL.. Any ideas?
returnign this error:
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 'CASE ) AS'Pending1', SUM(CASE Internal_status WHEN 'Returned' THEN Amount END C' at line 1
THAT WAS IT!!!!
I removed the END and it worked... THANKS!!!!.. You get best answer in 3 hours 15 minutes....
ER- I removed "CASE" after END