Alias "AS" in SQL

4 Posts
4 Users
1 Reactions
408 Views
(@chris_m)
Member
Joined: 3 years ago
Posts: 5
Topic starter  

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;

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

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.


   
ReplyQuote
Guido
(@admin)
Member Admin
Joined: 3 years ago
Posts: 216
 

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


   
ReplyQuote
(@radler64)
Member
Joined: 2 years ago
Posts: 12
 

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


   
ReplyQuote
Share: