这是我的表格"AuctionDetails"
下面是查询语句:
select string_agg("AuctionNO",',' ) as "AuctionNO"
,sum("QuntityInAuction" ) as "QuntityInAuction"
,"AmmanatPattiID"
,"EntryPassDetailsId"
,"BrokerID"
,"TraderID"
,"IsSold"
,"IsActive"
,"IsExit"
,"IsNew"
,"CreationDate"
from "AuctionDetails"
group by "AmmanatPattiID"
,"EntryPassDetailsId"
,"TraderID"
,"IsSold"
,"IsActive"
,"IsExit"
,"IsNew"
,"BrokerID"
,"CreationDate"
这是我的结果:
但我需要像这样的记录:
AuctionNo QunatityInAuction AmmanatpattiID EntryPassDetailID BrokerID Trader ID IsSold ISActive ISExit IsNew CreationDate
AU8797897,AU8797886,AU596220196F37379 1050 -1 228,229 42 42 f t f t 2013-10-10
最后,我需要一个交易员和经纪人的最新条目,这在我们的情况下是“42”,数量总和和拍卖号的连接。
CreationDate
定义的吗?仍然缺少 pk 定义和 Postgres 版本(运行SELECT version()
)。这两个对查询都很重要。 - Erwin Brandstetter