Skip to content

Instantly share code, notes, and snippets.

@dmitrybubyakin
Last active September 8, 2016 06:30
Show Gist options
  • Save dmitrybubyakin/02f0a42ef2335ad7a15ad766fcfd5547 to your computer and use it in GitHub Desktop.
Save dmitrybubyakin/02f0a42ef2335ad7a15ad766fcfd5547 to your computer and use it in GitHub Desktop.
SELECT tmp.* FROM (
select _id as `certificate_id`,RegNumber, `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) as tmp
where (tmp.`Total` = 0 or tmp.RegNumber = 'Empty')
ORDER BY `tmp`.`certificate_id` ASC
SELECT cs.certificate_id AS `CertificateId`,cs.certificateId as `CertificateGuid` , cs._id AS `SupplementId` ,
( SELECT COUNT( * ) FROM `accreditedprogramm` WHERE `certificatesupplement_id` = cs._id ) AS `spCount`
FROM `certificatesupplement` cs
where (cs.certificate_id = 6052 or cs.certificateId = 'guid')
ORDER BY `CertificateId` ASC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment