SQL Templates

From IMSMA Wiki
Revision as of 11:33, 12 February 2014 by Alnaucler (talk | contribs)
Jump to navigation Jump to search

This query checks which templates that have been used for data entry

SELECT
fieldreportname,
orgname,
publisheddate,
`version`,
Count(fieldreport_guid)
FROM
fieldreport
INNER JOIN fieldreportdesc ON fieldreport.fieldreportdesc_guid = fieldreportdesc.fieldreportdesc_guid
INNER JOIN organisation ON fieldreportdesc.org_guid = organisation.org_guid
GROUP BY
fieldreportdesc.fieldreportname,
organisation.orgname,
publisheddate,
`version`
ORDER BY
fieldreportname ASC,
orgname ASC,
publisheddate ASC,
`version` ASC

This query counts all existing templates by Active

SELECT
fieldreportdesc.isactive,
Count(fieldreportdesc.fieldreportdesc_guid)
FROM
fieldreportdesc
GROUP BY
fieldreportdesc.isactive
ORDER BY
fieldreportdesc.isactive ASC