2
Answers

when i execute the query output i snot coming correctly

narasiman rao

narasiman rao

11y
1.1k
1

 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 fa.facname = 'MADHAVAN'


when i  execute the above query  output as follows;


rate  Batchid Translated_Rate
 0  13         0
3  13       50
4  9       25
1  8     100
4  14     25
1  6    100
2  24     75
2  12    75
4  4     25
1 13    100

but in the above query, when i change the facname (facultyname) and execute the query,same output is coming for all the faculty.


what is the problem in my above sql server query please help me.

Regards,
Narasiman P.

Answers (2)
0
Shankar M

Shankar M

NA 3.6k 1.7m 11y

Hi Narasimhan,

Can you Please Post your table structure. The resultant output depends on the Table Definition and the rows it contain.

And, the DISTINCT Keyword where the other columns of a Table might have unique values.

Thanks, Shanka M
0
Javeed M Shaikh

Javeed M Shaikh

NA 7.8k 69.7k 11y
it is very difficult unless we have visibility to data for all the tables mentioned in the email. you can try removing the facname where condition and see if you receive the same data, or try giving an invalid value in the where condition like fa.facname = 'NAMEDOESNOTEXIST' and see what comes up.