简体   繁体   中英

Sql Query in C# Distinct Value and Max Date Join Two Tables

I am currently trying to get account number from one table, accountinfo, and find a max date for that account from another table, fup.

I'm new at both sql and c# so any help would be awesome!

So far I have

Select max(FUP.FA_TDATE), accountinfo.account 
from accountinfo 
inner join fup on accountinfo.account = fa_classaccount

I need this to return the max date and then the account.

You need a Group By when using an aggregate function like MAX()

Select max(FUP.FA_TDATE), accountinfo.account 
from accountinfo 
inner join fup on accountinfo.account = fup.fa_classaccount
GROUP BY accountinfo.account 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM