diff options
Diffstat (limited to 'sqlglot/dialects/tsql.py')
-rw-r--r-- | sqlglot/dialects/tsql.py | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/sqlglot/dialects/tsql.py b/sqlglot/dialects/tsql.py index 371e888..7b52047 100644 --- a/sqlglot/dialects/tsql.py +++ b/sqlglot/dialects/tsql.py @@ -117,14 +117,12 @@ def _string_agg_sql(self, e): if distinct: # exp.Distinct can appear below an exp.Order or an exp.GroupConcat expression self.unsupported("T-SQL STRING_AGG doesn't support DISTINCT.") - this = distinct.expressions[0] - distinct.pop() + this = distinct.pop().expressions[0] order = "" if isinstance(e.this, exp.Order): if e.this.this: - this = e.this.this - e.this.this.pop() + this = e.this.this.pop() order = f" WITHIN GROUP ({self.sql(e.this)[1:]})" # Order has a leading space separator = e.args.get("separator") or exp.Literal.string(",") |