How do I select all columns in a table and an aggregate function in a convenient way?
I.e. say that I have a table with 100 columns, and I want to send the following
SELECT Max(Columns 44), ALL OTHER COLUMNS
FROM zz
Group by ALL OTHER COLUMNS
Thanks!
To select all columns from the table is:
select * from zz;
To select a maximum from the table is
select max(column44) from zz;
The two combined:
select zz.*, (select max(column44) from zz) as maxcol44
from zz;
If you want to omit column44 in your result rows and only have maxcol44, then you must list the columns:
select
column1,
column2,
...
column43,
(select max(column44) from zz) as maxcol44,
column45,
...
from zz;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With