sql - SQL:字段的交替值
问题描述
所以,我试图让一件有趣的事情发生,但一直没能真正让它发挥作用。
所以,我的查询:
SELECT a.lead_id
,a.status
,a.[user]
, a.list_id
, a.last_local_call_time
, a.owner
FROM [LEADS].[dbo].[LDS_VICIDIAL_LIST] a
inner join leads.dbo.LDS_CONTACT_STATUS b on a.[status]=b.[status]
where list_id in ('2557','2562','2559') and Dialable='Y' and a.status<>'5NI' and a.called_since_last_reset = 'n'
order by a.last_local_call_time
基本上我想做的是让它显示列表 2557 中的 1 条记录、列表 2562 中的 1 条记录和 2559 中的 1 条记录并如此重复。
解决方案
SELECT a.lead_id
,a.status
,a.[user]
, a.list_id
, a.last_local_call_time
, a.owner
FROM [LEADS].[dbo].[LDS_VICIDIAL_LIST] a
inner join leads.dbo.LDS_CONTACT_STATUS b on a.[status]=b.[status]
where list_id in ('2557','2562','2559') and Dialable='Y' and a.status<>'5NI' and a.called_since_last_reset = 'n'
order by ROW_NUMBER() OVER (PARTITION BY a.list_id order by a.list_id)
得到了我想要的。
推荐阅读
- angular - AG-Grid Angular 6 m 多线接头
- arrays - 随机混合两个 Numpy 数组
- c# - ldap - 未找到网络路径
- tensorflow - 如果输入被tf.data.TFRecordDataset随机打乱,Tensorflow如何获得输入和输出之间的映射关系
- spring - Spring中特定咖啡因缓存的配置
- android - 使用 getter、setter 和适配器从 firebase 中的特定节点/子节点检索数据,详情请参阅
- javascript - Ngrx 存储已更新但未显示
- node.js - GhostScript - 在将 Microsoft Print 转换为 PDF 文件时,ImageMagick 将 pdf 转换为图像到奇数字母
- javascript - 检测浏览器和版本 - 没有 Modernizr
- mysql - 从右表结果中获取多维数组