Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Query as follows

SQL
SELECT distinct r.rate as Rate,
f.bthid as Batchid,
CASE  WHEN r.rate = '1' THEN '100' 
      WHEN r.rate = '2' THEN '75' 
      WHEN r.rate = '3' THEN '50' 
      WHEN r.rate = '4' THEN '25' 
      ELSE '0' 
END AS Translated_Rate 
FROM bthfac AS f,batch AS b, faculty AS fa,facfeedback AS r 
WHERE month(b.examdate)= '9' and year(b.examdate)= '2011' and b.bthid=f.bthid 
      and r.bfid = f.bfid  and f.facid = fa.facid and fa.facname = 'C';


when i execute the above query shows error as follows.

Error converting data type varchar to bigint.


from the above query how to convert varchar to bigint.

how can i do .

please help me.

Regards,
narasiman P
Posted
Updated 14-May-13 23:45pm
v3
Comments
[no name] 15-May-13 5:42am    
Please share your table structure...
gvprabu 15-May-13 5:47am    
Give some sample data from ur table

1 solution

You need to remove ', if a field stores numeric data or function (month, year) returns numeric values.

Plase, have a look at this:
SQL
SELECT distinct r.rate as Rate,
f.bthid as Batchid,
CASE  WHEN r.rate = 1 THEN 100 
      WHEN r.rate = 2 THEN 75 
      WHEN r.rate = 3 THEN 50 
      WHEN r.rate = 4 THEN 25 
      ELSE 0 
END AS Translated_Rate 
FROM bthfac AS f,batch AS b, faculty AS fa,facfeedback AS r 
WHERE month(b.examdate)= 9 and year(b.examdate)= 2011 and b.bthid=f.bthid 
      and r.bfid = f.bfid  and f.facid = fa.facid and fa.facname = 'C';
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900