Sql 匹配DATETIME和INT列的表上的自联接

Sql 匹配DATETIME和INT列的表上的自联接,sql,Sql,我有一个名为batch的表。桌子的结构是这样的 我尝试了很多来编写这个查询,但是从来没有得到这个结果。我喜欢树 select distinct a.batchid from(select batchid,bsdate,bstrength from batch)a inner join (select batchid,bsdate,bstrength from batch) b on date(a.bsdate)=date(b.bsdate) and a.bstrength=b.bstre

我有一个名为batch的表。桌子的结构是这样的

我尝试了很多来编写这个查询,但是从来没有得到这个结果。我喜欢树

select distinct a.batchid from(select batchid,bsdate,bstrength from batch)a 
inner join  
(select batchid,bsdate,bstrength from batch) b on date(a.bsdate)=date(b.bsdate) and a.bstrength=b.bstrength;

select a.batchid,a.bsdate,b.bstrength from batch a join batch b on date(a.bsdate)=date(b.bsdate) and a.bstrength=b.bstrength;

请帮助我编写此查询。

基于上述数据的预期结果集是什么?我不知道答案,但它应该显示具有共同开始日期和共同强度的批次id
SELECT a.batchid a, b.batchid b
FROM batch a
JOIN batch b 
    ON CONVERT(DATE,a.bsdate) = CONVERT(DATE,b.bsdate) 
        AND a.bstrength = b.bstrength
        AND CONVERT(INT,SUBSTRING(a.batchid,1)) < CONVERT(INT,SUBSTRING(b.batchid,1))
a    b
b001 b002
b002 b001