您的位置
主页 > 网站技术 > 数据库 > » 正文

sql获取分组排序后数据的脚本

来源: 站长圈 点击:

复制代码 代码如下:

select distinct  

b.OrgID,b.CompanyID,b.AreaID,b.CustChannelID,b.CustID,b.SaleTotalQty,

GETDATE() from KDS400TelSurveyCustAll_Temp  as tmp1 cross apply 

(

select top 10 percent * from KDS400TelSurveyCustAll_Temp tmp2 

where tmp1.OrgID=tmp2.OrgID and tmp1.CompanyID=tmp2.CompanyID 

and tmp1.AreaID=tmp2.AreaID and tmp1.CustChannelID=tmp2.CustChannelID 

and tmp2.CustChannelID in (1027,1028)

order by tmp2.OrgID,tmp2.CompanyID,tmp2.AreaID,tmp2.AreaType,tmp2.CustChannelID

) as b




首页  - 关于站长圈  - 广告服务  - 联系我们  - 关于站长圈  - 网站地图  - 版权声明