Skip to content

Instantly share code, notes, and snippets.

@dmitrybubyakin
Created September 5, 2016 05:26
Show Gist options
  • Save dmitrybubyakin/8f50e8d40c8424cf9ff4ef35cfd01eaf to your computer and use it in GitHub Desktop.
Save dmitrybubyakin/8f50e8d40c8424cf9ff4ef35cfd01eaf to your computer and use it in GitHub Desktop.
1. Выдает список свидетельств и кол-во программ
select
_id,
`Id` as `GUID`,
( select count(*) from `certificatesupplement` cs INNER JOIN `accreditedprogramm` ap on ap.certificatesupplement_id = cs._id WHERE cs.certificate_id = ac._id ) as `Total`
from accreditationcertificate as ac
order by _id
2. Выдает список свидетельств где нет программ
select
_id,
`Id` as `GUID`,
( select count(*) from `certificatesupplement` cs INNER JOIN `accreditedprogramm` ap on ap.certificatesupplement_id = cs._id WHERE cs.certificate_id = ac._id ) as `Total`
from accreditationcertificate as ac
where `Total` = 0
order by _id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment