Click here to Skip to main content
15,922,315 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
SQL
SELECT distinct r.rate as Rate,
f.bfid as Batchid,b.bthno,
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 fa.facid=f.facid and b.class = 'PST' and fa.facname = 'MADHAVAN';

when i run the above query shows error as follows;

Error converting data type varchar to bigint.

The above error showing because as follows,

FAculty table design structure as follows

Facid bigint (data type)


Bthfac table design structure as follows

Facid varchar (data type)


thats why error shows, for that how can i resolve and get the output.

how can i do? please help me.

Regards,
Narasiman P.
Posted
Updated 24-May-13 3:36am
v2
Comments
Richard MacCutchan 24-May-13 9:37am    
You cannot compare a character type to an integer type, you will need some conversion code. Alternatively, you should make the fields in the different tables to be the same type.

1 solution

you can use

CAST(fa.facid as varchar(50))=f.facid

-NP
 
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