Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL error in ELSE statement?

Author  Topic 

phendyr
Starting Member

2 Posts

Posted - 2014-11-21 : 10:18:52
Hello all,
first time poster here, I am completely new to using let alone writing SQL, and if it is possible to help identify the issue I'm experiencing, I greatly appreciate the forum's time and effort to respond.

I have a case statement that is reading a value from a csv column, and based on where that value falls, calculates a product's a numeric value. It works on one computer, and when copied/pasted to mine, it throws errors.

This is the error:
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 '121.67END' at line 1"

Here is the case statement:

CASE
WHEN [CSV_COL(8)] BETWEEN 0 AND .01 THEN ((([CSV_COL(6)] * .029) + .30) + ((([CSV_COL(6)] * .029) + .30) + [CSV_COL(6)]) / (100 - 7) * 100) + 4.36
WHEN [CSV_COL(8)] BETWEEN .011 AND .05 THEN ((([CSV_COL(6)] * .029) + .30) + ((([CSV_COL(6)] * .029) + .30) + [CSV_COL(6)]) / (100 - 7) * 100) + 5.44
WHEN [CSV_COL(8)] BETWEEN .051 AND 1 THEN ((([CSV_COL(6)] * .029) + .30) + ((([CSV_COL(6)] * .029) + .30) + [CSV_COL(6)]) / (100 - 7) * 100) + 11
WHEN [CSV_COL(8)] BETWEEN 1.00001 AND 2 THEN ((([CSV_COL(6)] * .029) + .30) + ((([CSV_COL(6)] * .029) + .30) + [CSV_COL(6)]) / (100 - 7) * 100) + 12.25
WHEN [CSV_COL(8)] BETWEEN 2.00001 AND 4 THEN ((([CSV_COL(6)] * .029) + .30) + ((([CSV_COL(6)] * .029) + .30) + [CSV_COL(6)]) / (100 - 7) * 100) + 13.21
WHEN [CSV_COL(8)] BETWEEN 4.00001 AND 6 THEN ((([CSV_COL(6)] * .029) + .30) + ((([CSV_COL(6)] * .029) + .30) + [CSV_COL(6)]) / (100 - 7) * 100) + 13.66
WHEN [CSV_COL(8)] BETWEEN 6.00001 AND 8 THEN ((([CSV_COL(6)] * .029) + .30) + ((([CSV_COL(6)] * .029) + .30) + [CSV_COL(6)]) / (100 - 7) * 100) + 14.24
WHEN [CSV_COL(8)] BETWEEN 8.00001 AND 10 THEN ((([CSV_COL(6)] * .029) + .30) + ((([CSV_COL(6)] * .029) + .30) + [CSV_COL(6)]) / (100 - 7) * 100) + 14.88
WHEN [CSV_COL(8)] BETWEEN 10.00001 AND 12 THEN ((([CSV_COL(6)] * .029) + .30) + ((([CSV_COL(6)] * .029) + .30) + [CSV_COL(6)]) / (100 - 7) * 100) + 15.53
WHEN [CSV_COL(8)] BETWEEN 12.00001 AND 15 THEN ((([CSV_COL(6)] * .029) + .30) + ((([CSV_COL(6)] * .029) + .30) + [CSV_COL(6)]) / (100 - 7) * 100) + 17.56
WHEN [CSV_COL(8)] BETWEEN 15.00001 AND 18 THEN ((([CSV_COL(6)] * .029) + .30) + ((([CSV_COL(6)] * .029) + .30) + [CSV_COL(6)]) / (100 - 7) * 100) + 18.84
WHEN [CSV_COL(8)] BETWEEN 18.00001 AND 20 THEN ((([CSV_COL(6)] * .029) + .30) + ((([CSV_COL(6)] * .029) + .30) + [CSV_COL(6)]) / (100 - 7) * 100) + 20.14
WHEN [CSV_COL(8)] BETWEEN 20.00001 AND 25 THEN ((([CSV_COL(6)] * .029) + .30) + ((([CSV_COL(6)] * .029) + .30) + [CSV_COL(6)]) / (100 - 7) * 100) + 24.19
WHEN [CSV_COL(8)] BETWEEN 25.00001 AND 35 THEN ((([CSV_COL(6)] * .029) + .30) + ((([CSV_COL(6)] * .029) + .30) + [CSV_COL(6)]) / (100 - 7) * 100) + 30.66
WHEN [CSV_COL(8)] BETWEEN 35.00001 AND 40 THEN ((([CSV_COL(6)] * .029) + .30) + ((([CSV_COL(6)] * .029) + .30) + [CSV_COL(6)]) / (100 - 7) * 100) + 33.13
ELSE (([CSV_COL(6)] * .029) + .30) + (((([CSV_COL(6)] * .029) + .30) + [CSV_COL(6)]) / (100 - 7) * 100) + 121.67
END


gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-11-21 : 10:20:40
This is a SQL Server forum. Your question indicates that you are running MySQL. Perhaps you will get better answers in the MySQL forum.

However, it appears that MySQL is not recognizing the line end between 121.67 and END. Try adding a space after the value 121.67
Go to Top of Page

phendyr
Starting Member

2 Posts

Posted - 2014-11-21 : 10:55:54
thank you for your time, and apologies for confusion on forums... all the best!
Go to Top of Page
   

- Advertisement -