Bharat  Bhushan

Bharat Bhushan

  • NA
  • 176
  • 159.1k

Help in Sql Query

Aug 8 2011 7:46 AM
 hello there, 
  i m attaching the image with data records. Actually , i need the result like
CLICK HERE

  total correct answer and total incorrect answer [your_result)]according date-wise.
  like current date,
  with last two previous date,
  with weekly records
  with monthly records ....
  hope you can understand my requirement
  and following qurey which i was tryin also have a look it at but still not achieved what i need to achieved.

  SELECT  distinct c.date,  c.correct_answer,i.incorrect_answer, ABS(c.correct_answer - i.incorrect_answer) AS result
  FROM  (SELECT  distinct CONVERT(varchar(12), date, 110) AS date, COUNT(your_result) AS correct_answer  
  FROM  tb_mathamatics
  WHERE  (topic = 'addition_1') AND (your_result = 'correct')
  GROUP BY CONVERT(varchar(12), date, 110)
  ) AS c  CROSS JOIN
  (SELECT  distinct CONVERT(varchar(12), date, 110) AS date, COUNT(your_result) AS incorrect_answer
  FROM  tb_mathamatics AS tb_mathamatics_1
  WHERE  (topic = 'addition_1') AND (your_result = 'incorrect')
  GROUP BY CONVERT(varchar(12), date, 110)
  ) AS i


Answers (1)