In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article is to share with you about how ling to sql takes the maximum time of multiple records in C#. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
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, the number of date number warehouse.
2012-05-31 C001 A shop 136.002012-05-30 C001 B store 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) Thank you for reading! This is the end of this article on "how to take the maximum time of multiple records in ling to sql in C#". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
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.