mybatisplus SQL一对多】的更多相关文章

#applicaton.yml 配置 mybatis-plus: configuration: # 是否将sql打印到控制面板(该配置会将sql语句和查询的结果都打印到控制台) log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #效果:  …
1. 一对多查询 查询departmentinfo字典下所有部门的人员数量 select * from departmentinfo a left join (select count(*) UserCount,UnitId from ReCharge where ReDate='2017-06-15' group by UnitId) b on (a.DepartMentId=b.UnitId) order by a.sort 2.将查询出来的结果 的 某列 用逗号隔开 作为新字符串 SELE…
有两个数据表City表和Price表,CIty表的结构如下: Price表的结构如下: 查询每个城市最大的销售价格,并以最大价格进行降序排列,选取前5条记录,SQL语句的代码如下: * from (select ROW_NUMBER() over(order by TmpTable.AdultyPrice desc) NID, City.*, TmpTable.AdultyPrice from City,(select MAX(Price.AdultyPrice) as AdultyPrice,…
ROW_NUMBER()OVER() 参数1:分组字段 PARTITION BY   ..,..,....  可选 参数2:排序字段 ORDER BY .. DESC  必须 实例: 根据ConfirmDate 排序,PayApplyId 分组 SELECT * FROM PayApplyConfirmRecord  SELECT ROW_NUMBER()OVER(PARTITION BY PayApplyId ORDER BY ConfirmDate DESC)  rowId,* from d…
scie_apprecord仪器表   和   scie_apporder仪器预约时间表 ,一个仪器可以有多条预约时间. 仪器表: 预约时间表: 需求: 由于一个仪器有好多条预约记录,将预约时间表的最早开始时间(startDate)给仪器表的全局开始时间(globalSdate) -- 更新预约全局开始时间 UPDATE scie_apprecord A INNER JOIN ( SELECT apparId ,basiId , MIN(startDate) AS newdate FROM sc…
SELECT distinct       u.Name as UserName,       a.OrderId,       (       select  d.SignCity from T_OperaterInfo o left join T_DepartmentInfo d on o.DepId=d.DepId where o.OptId=a.CreateUserId       ) jinjianchengshi,       o.Name as lurukefu,       p.…
感谢 http://bbs.csdn.net/topics/391048578?page=1 create table A ( [Id] [uniqueidentifier] NOT NULL, ) NULL, ) NULL ) create table B ( [Id] [uniqueidentifier] NOT NULL, [AId] [uniqueidentifier] NULL, [status] int, ) null ) Declare @Id [uniqueidentifier]…
主表: 辅表: 一个app对应多个apk,现在要取上线(Apk_Status最大的)的应用 select * from [dbo].[tbl_APP] as app join ( * from tbl_Apk as BB where AA.Apk_APPId=BB.Apk_APPId and AA.Apk_Status < BB.Apk_Status)) as apk on app.APP_Id = apk.Apk_APPId 重点是取关联的右表: select * from [dbo].[tb…
部分原始表数据 需求: 按routineId进行group分组 初步想法(错误): select r * from autowork.dbo.PartOnRoutine where routineId='1050' or routineId='1060' group by routineId; 难点:一个routineId对应多个part,需先将part合并,再分组 解决:xml select routineId,(select [partnr]+',' from autowork.dbo.Pa…
package com.osplat.config; import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor; import org.springframework.boot.web.servlet.MultipartConfigFactory; import o…