| 203 | |
| 204 | # To find duplicates enrollment_id entries: |
| 205 | |
| 206 | mysql -h briccsdb -u auditor -pg3s4t6 briccs -e "SELECT * FROM participant ptone WHERE EXISTS (SELECT 1 FROM participant pttwo WHERE pttwo.enrollment_id = ptone.enrollment_id LIMIT 1, 1 );" |
| 207 | |
| 208 | |
| 209 | # So to exclude duplicates and NULL BPt numbers: |
| 210 | |
| 211 | mysql -h briccsdb -u auditor -pg3s4t6 briccs -e "SELECT * FROM participant ptone WHERE NOT EXISTS (SELECT 1 FROM participant pttwo WHERE pttwo.enrollment_id = ptone.enrollment_id LIMIT 1, 1 ) AND barcode is not null order by enrollment_id;" |
| 212 | |
| 213 | # To exclude duplicates, nulls and cancelled interviews and list barcodes (BPt numbers) and enrollment dates: |
| 214 | |
| 215 | mysql -h briccsdb -u auditor -pg3s4t6 briccs -e "SELECT barcode, start_date, status |
| 216 | FROM participant ptone, interview WHERE NOT EXISTS (SELECT 1 FROM participant pttwo WHERE pttwo.enrollment_id = ptone.enrollment_id LIMIT 1, 1 ) AND barcode is not null AND status <> 'CANCELLED' |
| 217 | AND ptone.id = interview.participant_id order by start_date;" > briccs_enrollment_to_date.txt |
| 218 | |
| 219 | # To get a count of the above: |
| 220 | |
| 221 | mysql -h briccsdb -u auditor -pg3s4t6 briccs -e "SELECT count(*) |
| 222 | FROM participant ptone, interview WHERE NOT EXISTS (SELECT 1 FROM participant pttwo WHERE pttwo.enrollment_id = ptone.enrollment_id LIMIT 1, 1 ) AND barcode is not null AND status <> 'CANCELLED' |
| 223 | AND ptone.id = interview.participant_id order by start_date;" |
| 224 | |
| 225 | |