本文介绍了选择聚合函数和所有其他列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何以方便的方式选择表中的所有列和聚合函数?

How do I select all columns in a table and an aggregate function in a convenient way?

即说我有一个包含100列的表,我想发送以下内容

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

谢谢!

推荐答案

要从表中选择所有列,请执行以下操作:

To select all columns from the table is:

select * from zz;

要从表格中选择最大值,则是

To select a maximum from the table is

select max(column44) from zz;

两者合计:

select zz.*, (select max(column44) from zz) as maxcol44
from zz;

如果要在结果行中省略column44并且仅包含maxcol44,则必须列出这些列:

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;

这篇关于选择聚合函数和所有其他列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 03:21