| 91 | |
| 92 | |
| 93 | Single diagnosis, count: |
| 94 | |
| 95 | SELECT count(participant.id) as 'Number of Participants' |
| 96 | FROM participant, questionnaire_participant, question_answer, category_answer |
| 97 | WHERE participant.id = questionnaire_participant.participant_id |
| 98 | AND question_answer.questionnaire_participant_id = questionnaire_participant.id |
| 99 | AND ( question_answer.question_name = 'epi_pridiag' OR question_answer.question_name = 'epi_secdiag' ) |
| 100 | AND category_answer.question_answer_id = question_answer.id |
| 101 | AND category_answer.category_name = 'Aortic_Stenosis'; |
| 102 | |
| 103 | |
| 104 | Complex query, using two references to the same tables, to derive those of a certain diagnosis (primary or secondary) where the recruitment context is not 'Study specific': |
| 105 | |
| 106 | SELECT count(participant.id) as 'AS not study recruited' |
| 107 | FROM participant, questionnaire_participant as diag_questionnaire, questionnaire_participant as context_questionnaire, question_answer as diag_question, category_answer as diag_answer, question_answer as context_question, category_answer as context_answer |
| 108 | WHERE participant.id = diag_questionnaire.participant_id |
| 109 | AND participant.id = context_questionnaire.participant_id |
| 110 | AND diag_questionnaire.id = diag_question.questionnaire_participant_id |
| 111 | AND ( diag_question.question_name = 'epi_pridiag' OR diag_question.question_name = 'epi_secdiag' ) |
| 112 | AND diag_answer.question_answer_id = diag_question.id |
| 113 | AND diag_answer.category_name = 'Aortic_Stenosis' |
| 114 | AND context_questionnaire.id = context_question.questionnaire_participant_id |
| 115 | AND context_question.question_name = 'epi_type' |
| 116 | AND context_answer.question_answer_id = context_question.id |
| 117 | AND context_answer.category_name <> 'Study_specific' |
| 118 | ; |
| 119 | |