Skip to content

Commit 70366c6

Browse files
committed
feat: enhance MySQL connector median query and add new aggregate API endpoints for car statistics
1 parent a1f7db1 commit 70366c6

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

adminforth/dataConnectors/mysql.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,16 +403,16 @@ class MysqlConnector extends AdminForthBaseConnector implements IAdminForthDataS
403403
let medianQuery: string;
404404
if (groupExpr) {
405405
medianQuery = `
406-
SELECT ${groupExpr} AS \`group\`, AVG(${f}) AS \`${alias}\`
406+
SELECT \`group\`, AVG(${f}) AS \`${alias}\`
407407
FROM (
408-
SELECT ${groupExpr}, ${f},
408+
SELECT ${groupExpr} AS \`group\`, ${f},
409409
ROW_NUMBER() OVER (PARTITION BY ${groupExpr} ORDER BY ${f}) AS rn,
410410
COUNT(*) OVER (PARTITION BY ${groupExpr}) AS cnt
411411
FROM \`${tableName}\` ${nullGuard}
412412
) t
413413
WHERE rn IN (FLOOR((cnt + 1) / 2.0), CEIL((cnt + 1) / 2.0))
414-
GROUP BY ${groupExpr}
415-
ORDER BY ${groupExpr} ASC
414+
GROUP BY \`group\`
415+
ORDER BY \`group\` ASC
416416
`;
417417
} else {
418418
medianQuery = `

0 commit comments

Comments
 (0)