简体   繁体   English

如何找到netezza中不同行中具有相同值的列的最大值

[英]how to finding max of a column which has same values in different rows in netezza

i have a netezza table(transactions table)where there are multiple entries for one account number. 我有一个netezza表(交易表),其中一个帐号有多个条目。 i have to pick the latest entry for that account number based on the latest transaction date.if transaction dates are different for that account number i can pick the record with the max transaction date(ie the latest record). 我必须根据最新交易日期为该帐号选择最新条目。如果该帐号的交易日期不同,则可以选择具有最大交易日期的记录(即最新记录)。

But for some account number in all the entries of that account number the transaction date is also same . 但是对于该帐号的所有条目中的某个帐号,交易日期也相同。 in that case i have to pick the latest entry made in table for that account(say the latest row_number). 在这种情况下,我必须为该帐户选择表中的最新条目(例如最新的row_number)。

I have to write a sql query for netezza for this .how can i do so???.... 我必须为此写一个netezza的sql查询。我该怎么办?

Note:: in all the rows all the columns have same values as the row above them so i cannot do the above by differentiating the different rows on basis of some other column also 注意:在所有行中,所有列的值都与其上方的行相同,因此我无法通过基于其他某些列来区分不同的行来完成上述操作

Here is the general idea. 这是一般的想法。 You should be able to adapt it for your own tables. 您应该能够使其适合您自己的表。

select fred, barney, wilma
from flinstones join (
select max(Wilma) MaxWilma
from flinstones
where whatever) bedrock on Wilma = MaxWilma
where whatever

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何选择第1列中具有相同值但第2列中具有不同值的行? - How to SELECT rows that has same values in column 1 but different values in column 2? 查询以针对一列的每个不同值返回在所有行中具有相同值的行值 - Query to return row values which has same values in all the rows for each different value of one column 选择具有相同ID但另一列中具有不同值的行 - Select rows with same ID but has different values in another column 如何对相邻列中具有不同值的 SQL 中的多行求和 - How to sum multiple rows in SQL which has different values in the adjacent column SQL:如何以两种不同的顺序从同一表列中获取行,并限制获取最大 3 个值和最小 3 个值 - SQL: How to get rows from same table column in two different orders with limit to get max 3 values and min 3 values SQL - 组合两个表时,在另一列中为另一列中的相同值查找具有不同值的所有行 - SQL - Finding all rows with a different values in a column for the same value in another column when combining two tables 在多行中查找同一列中具有相同值的行,而另一列具有不同值 - Find row that has same value in one column over multiple rows while another column has different values Postgres:如何查找特定列具有“空”值的行? - Postgres: How to find rows in which a specific column has 'empty' values? 当另一列在oracle中具有不同的值时,如何选择MAX(列)行? - How can I select rows with MAX(Column) when another column has distinct values in oracle? 使用 SUM 合并多行,这些行共享相同的列值但具有不同的其他列值 - Combine multiple rows using SUM that share a same column value but has different other column values
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM