Alias "AS" in SQL

4 Posts
4 Users
1 Reactions
1,274 Views
Posts: 5
Topic starter
(@chris_m)
Member
Joined: 4 years ago
[#14]

I would love to have the possibility to set the "AS" statement automatically for aliases in SQL and align them if desired.

Furthermore the option to duplicate the attribute name as alias for all attributes could help reading the SQL code as well.

Example:

select attribute1
, attribute_xy attribute2
, sum(blabla) sum_value
, count(*) as counter
from table1
group by 1,2;

This should be possible to format into:

select 
  attribute1                      as attribute1
, attribute_xy                    as attribute2
, sum(blabla)                     as sum_value
, count(*)                        as counter
from table1    as table1
group by 1,2;

3 Replies
eklein86
Posts: 4
(@eklein86)
Member
Joined: 4 years ago

I would really like to see an option to get AS. Although I'd prefer the option to add the AS to field alias separate from table alias. Oracle does not like AS on table alias.


Reply
Guido
Posts: 295
Admin
(@admin)
Member
Joined: 5 years ago

Hi eklein86,

this option would be cool. But the beautifier will not change the code of the SQL. The parsing of SQL, DDL and Stored procedure is very complicated, a change of the code could have negative impacts.

Regards

Guido


Reply
Posts: 12
(@radler64)
Member
Joined: 4 years ago

Hello,

In regards to the theme "as" I would find it more helpfull in real live, deailing with huge SQLs changed by a lot of developers, when the format

function(column) AS newColumnName
column2 as newColumn2Name

could be translated into

newColumnName = function(column) 
newColumn2Name = column2

That would make my life easier.

Regards Dieter


Reply
Share: