SQL query examples

From TempusServa wiki
Revision as of 09:03, 17 September 2018 by old>Admin (Created page with " === Lookup related data === SELECT l.`Value`, COUNT(k.DataID) FROM data_kuglespil as k JOIN formfieldlookup as l ON k.STRRELSE = l.LookupID; === Grouped variables ==...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Lookup related data

 SELECT l.`Value`, COUNT(k.DataID)
 FROM data_kuglespil as k
 JOIN formfieldlookup as l ON k.STRRELSE = l.LookupID;


Grouped variables

 SELECT 'Under 5' as Text, COUNT(k.DataID)
 FROM data_kuglespil as k
 WHERE k.RESULTAT <= 5
 
 UNION
 
 SELECT 'Middel (6-16)' as Text, COUNT(k.DataID)
 FROM data_kuglespil as k 
 WHERE k.RESULTAT <= 5 AND k.RESULTAT < 17
 
 UNION
 
 SELECT 'Top performer (17)' as Text, COUNT(k.DataID)
 FROM data_kuglespil as k
 WHERE k.RESULTAT = 17;