想实现如下效果,就是分组后时间最大的那一条数据: 1.SQL SELECT * FROM ( SELECT * , ROW_NUMBER() OVER ( PARTITION BY RIP_GUID ORDER BY RU_CreatedTime DESC ) rn FROM RIP_FlowInfo ) t WHERE t.rn <= 1; 2.LINQ var groupQuery = from t in query group t by t.RIP_Guid into g select n
方法:mysql取分组后最新的一条记录,下面两种方法.一种是先筛选 出最大和最新的时间,在连表查询.一种是先排序,然后在次分组查询(默认第一条),就是最新的一条数据了 #select * from t_assistant_article as a, (select max(base_id) as base_id, max(create_time) as create_time from t_assistant_article as b group by base_id ) as b where
// ConsoleApplication3.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include<iostream> #include<vector> #include<deque> #include<iomanip> #include<algorithm> using namespace std; int main() { int n; long int l; while