根据sortid字段分页排序,相同的数据取第一个
select * from (
select a.*,ROW_NUMBER() OVER(PARTITION BY a.sortid) AS id from (
select com1,com2,sortid from table
where channelStart <= current timeStamp and channelEnd >= current timeStamp
union
select com1,com2,sortid from table
where channelStart is null and CHANNELEND is null
) a
) where id=1