我想集团通过的ContactID,只有重组具有自动编号> 1的重复计数使用熊猫集团,我会做这样的事情:SQL服务器:斯普利特,筛选和重组
refinance_data = refinance_data.groupby('ContactID').filter(lambda x: x.AutoNumber.nunique() > 1)
我的SQL查询......
SELECT Ge.LoanAgreementID, Ge.Amount, Ge.ContactID, Ge.TransactionDate, Lo.AutoNumber, Ge.GeneralLedgerType FROM GeneralLedger as Ge
JOIN LoanAgreements Lo ON Ge.LoanAgreementID = Lo.LoanAgreementID
GROUP BY Ge.ContactID HAVING COUNT(DISTINCT Lo.AutoNumber) >1;
正在产生以下错误:
Msg 8120, Level 16, State 1, Line 1
Column 'GeneralLedger.LoanAgreementID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
请提供创建脚本,并插入一些样品数据,我们将竭诚为您服务! –