duplication - Removing duplicate rows from a SQL query -
duplication - Removing duplicate rows from a SQL query -
i have problem writing sql query. have 2 tables: question , candidat_test_answer, formatted follows.
question:
(id_question) (id_catgorie) | 1 |1 | 2 |1 | 4 |1
candidat_test_answer:
id_question || id_answer || id_test || id_candidat || date | 1 || 2 || 17 || 1 ||2014-06-01 | 1 || 3 || 17 || 1 ||2014-06-01 | 2 || 1 || 17 || 1 ||2014-06-01 | 2 || 2 || 17 || 1 ||2014-06-01 | 1 || 2 || 17 || 2 ||2014-06-01
i want display records without duplication in results.
id_question || id_test || id_candidat || date | 1 || 17 || 1 ||2014-06-01 | 2 || 17 || 1 ||2014-06-01
here have tried far:
select * question q , candidat_test_reponse ctr q.id_qt=ctr.id_qt , ctr.id_test=17 , id_cand=1 , date='2014-06-01' , q.id_qt not in (select q.id_qt question q , candidat_test_reponse ctr q.id_qt=ctr.id_qt , ctr.id_test=17 , ctr.id_cand=1 , ctr.date='2014-06-01') order q.id_cat ,ctr.id_test desc
however, returns 0 results. error have made?
try query
select distinct question.id_question, candidat_test_answer.id_test,candidat_test_answer.id_candidat, date question bring together candidat_test_answer on question.id_question = candidat_test_answer.id_question ctr.id_test=17 , id_cand=1 , date='2014-06-01'
sql duplication
Comments
Post a Comment