关于我们

质量为本、客户为根、勇于拼搏、务实创新

< 返回新闻公共列表

sql 超级大招 知识点:row_number百万级高效分页,组合查询,判断,金额格式化,日期格式化

发布时间:2019-11-02 12:32:20

--知识点:row_number百万级高效分页,组合查询,判断,金额格式化,日期格式化 

Select * FROM (--分页

SELECT ROW_NUMBER()Over(order by m.KeyId desc) as rowId,--分页函数row_number()

s=case --case判断

when edNumber like 'IN%' then '收入'

when edNumber like 'OUT%' then '支出'

end,--下面是组合查询超级大招

m.KeyId,m.edNumber,CONVERT(decimal(18, 2), m.total) total,CONVERT(decimal(18, 2), m.payment) payment,  CONVERT(varchar(100), m.add_time, 23) add_time,CONVERT(varchar(100), m.up_time, 23) up_time,m.note,a.accountName,a.KeyId aid ,c.KeyId cid,c.company,d.KeyId did,d.depName from NetWingCRM_FinanceMain m,NetWingCRM_BankAccount a,NetWingCRM_Company c,NetWingCRM_Dep d where m.account=a.KeyId and m.unit=c.KeyId and m.dep=d.KeyId 

) as mytable --分页

WHERE rowId between 1 and 10 --分页条件

12-300x176.jpg


/template/Home/Zkeys/PC/Static