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.
| Author |
Topic |
|
drew22299
Starting Member
26 Posts |
Posted - 2009-01-23 : 05:35:23
|
| Hi,I'm not sure where to put the convert clause in my SQL code, does it go after the Select statement and before the from clause?Here is my SQL code:Select statementCONVERT(integer,(CONVERT(decimal,Scores.Score) / CONVERT(decimal,Scores.MaximumScore) * 100),0) AS ScorePercentageFromBut I get the following error: Incorrect syntax near the keyword 'CONVERT'Can anyone see why? |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-01-23 : 05:41:02
|
| Try thisSelect CONVERT(integer,(CONVERT(decimal,34) / CONVERT(decimal,200) * 100),0) AS ScorePercentage |
 |
|
|
drew22299
Starting Member
26 Posts |
Posted - 2009-01-23 : 05:45:51
|
| Should convert clause be part of the select statement? I still get the same error. |
 |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-01-23 : 05:45:54
|
quote: Originally posted by drew22299 Hi,I'm not sure where to put the convert clause in my SQL code, does it go after the Select statement and before the from clause?Here is my SQL code:Select statementCONVERT(integer,(CONVERT(decimal,Scores.Score) / CONVERT(decimal,Scores.MaximumScore) * 100),0) AS ScorePercentageFromBut I get the following error: Incorrect syntax near the keyword 'CONVERT'Can anyone see why?
Select statementCONVERT(integer,(CONVERT(decimal,Scores.Score) / CONVERT(decimal,Scores.MaximumScore) * 100),0) AS ScorePercentageFrom |
 |
|
|
drew22299
Starting Member
26 Posts |
Posted - 2009-01-23 : 05:51:32
|
| Thanks, I just realised I missed out a comma, but now I get an error saying the columns Scores.Score and Scores.MaximumScore cannot be boundWhy is this? The table joins are correct and if I comment out the line with the convert clause I can get data from both of the fields? |
 |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-01-23 : 06:05:52
|
| can U post Ur Query and check ur tablename or alias names for table |
 |
|
|
drew22299
Starting Member
26 Posts |
Posted - 2009-01-23 : 06:09:28
|
| I managed to fix it, one of the fields didn't have the correct spelling. |
 |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-01-23 : 06:12:51
|
quote: Originally posted by drew22299 I managed to fix it, one of the field names were spelt incorrectly.
ok |
 |
|
|
|
|
|
|
|