In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The specific code is as follows:
Var _ setList = (from f in _ postgreDbContext.settlements group f by (new {f.settlement_code}) into g select new {deal_time = g.Max (m = > m.deal_time), g.Key.settlement_code}) .AsNoTracking () .ToList ()
Knowledge point expansion: sql query has the largest date in the same record.
Date number warehouse quantity
2012-05-31 C001 A shop 136.002012-05-29 C001 A shop 139.002012-05-29 C001 B shop 5.002012-05-30 C001 B shop 6.00
I only show the record of the maximum date. How to write this SQL?
That is,
Date number warehouse quantity
2012-05-31 C001 A shop 136.00
2012-05-30 C001 B 6.00
SQL code
Select * from tb t where not exists (select 1 from tb where number = t. Serial number and warehouse = t. Warehouse and date > t. Date)
Method 2:
Create table cangku (F_RQ datetime, F_BH VARCHAR (20), F_SL FLOAT) INSERT INTO cangku VALUES ('2012-05-31) INSERT INTO cangku VALUES (' 2012-05-30) INSERT INTO cangku VALUES ('2012-05-30) INSERT INTO cangku VALUES (' 2012-05-26) SELECT * FROM cangku T, (SELECT F_BH MAX (F_RQ) rq FROM cangku GROUP BY F_BH) T2 where t.F_BH=t2.F_BH and t.F_RQ > = t2.rq
Method 3: better understanding:
Select * from table a where a.date in (select max (b.date) from table b where b.id=a.id)
Summary
The above is the editor introduced to you the C# ling to sql to take a number of records of the maximum time, I hope to help you, if you have any questions welcome to leave a message for me, the editor will reply to you in time!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.