SQLExplorer save query, aggregate functions
Posted: Tue Nov 06, 2012 2:42 pm
I'm using SQLE to generate queries for FMP12 Advanced. There are two issues I've run into. First, when I modify a query to include calculations via SELECT and GROUP BY criteria, the query performs correctly. When I choose Save and Finish, SQLE does not save those commands. This is the code before save (modified commands underlined):
SELECT a."Species", a."Mortality", Avg(a."Height_m")
FROM "Monitoring" a
WHERE a."Species" NOT LIKE ? AND a."Height_m" > ? AND a."Mortality" = ?
GROUP BY a."Species", a."Mortality"
ORDER BY a."Species" ASC
This is the code after "save and finish:"
SELECT a."Species", a."Mortality", a."Height_m"
FROM "Monitoring" a
WHERE a."Species" NOT LIKE ? AND a."Height_m" > ? AND a."Mortality" = ?
ORDER BY a."Species" ASC
Of course, I can copy the code to clipboard or as calculation and it retains the needed text, but it would obviously be more convenient to store queries properly in SQLE.
Second, some aggregate functions are supported but others return a query error (?). For example, in SELECT from the first code example, I have Avg(a."Height_m") to return the average of all height measurements by each group ("Species") measured. This works. Replacing "Avg" with "Count" or "Sum" works. Standard deviation ("Stdev" or "StDev") does not, and this is an important function for my queries. I've also tried it in ExecuteSQL directly in FMP, that did not work either. There are no zero, blank or one value groups in my data, so that shouldn't be the problem.
Ideas?
FMP Advanced 12.0v2
Mac OS X 10.7.5
SELECT a."Species", a."Mortality", Avg(a."Height_m")
FROM "Monitoring" a
WHERE a."Species" NOT LIKE ? AND a."Height_m" > ? AND a."Mortality" = ?
GROUP BY a."Species", a."Mortality"
ORDER BY a."Species" ASC
This is the code after "save and finish:"
SELECT a."Species", a."Mortality", a."Height_m"
FROM "Monitoring" a
WHERE a."Species" NOT LIKE ? AND a."Height_m" > ? AND a."Mortality" = ?
ORDER BY a."Species" ASC
Of course, I can copy the code to clipboard or as calculation and it retains the needed text, but it would obviously be more convenient to store queries properly in SQLE.
Second, some aggregate functions are supported but others return a query error (?). For example, in SELECT from the first code example, I have Avg(a."Height_m") to return the average of all height measurements by each group ("Species") measured. This works. Replacing "Avg" with "Count" or "Sum" works. Standard deviation ("Stdev" or "StDev") does not, and this is an important function for my queries. I've also tried it in ExecuteSQL directly in FMP, that did not work either. There are no zero, blank or one value groups in my data, so that shouldn't be the problem.
Ideas?
FMP Advanced 12.0v2
Mac OS X 10.7.5