1
Answer

Help in Sql Query

Bharat  Bhushan

Bharat Bhushan

13y
1.7k
1
 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)