From e8e24f6139f6f5589217ddf05c4369932df7a51f Mon Sep 17 00:00:00 2001 From: Sven Klemm Date: Tue, 10 Jul 2018 11:32:23 +0200 Subject: [PATCH] add alias when adding group by --- public/app/plugins/datasource/postgres/postgres_query.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/public/app/plugins/datasource/postgres/postgres_query.ts b/public/app/plugins/datasource/postgres/postgres_query.ts index 2c01417ad12..55ef242d1e2 100644 --- a/public/app/plugins/datasource/postgres/postgres_query.ts +++ b/public/app/plugins/datasource/postgres/postgres_query.ts @@ -101,6 +101,9 @@ export default class PostgresQuery { var selectParts = this.target.select[i]; if (!selectParts.some(part => part.type === 'aggregate')) { selectParts.splice(1, 0, { type: 'aggregate', params: ['avg'] }); + if (!selectParts.some(part => part.type === 'alias')) { + selectParts.push({ type: 'alias', params: [selectParts[0].params[0]] }); + } } }