0
我的數據: -需要從排有同樣的數據消除空
UserId |ShopId |PlanName
------------------------
241 | 17679 |NULL
241 | 20037 |NULL
241 | 20037 |440
我需要的數據: -
UserId |ShopId |PlanName
------------------------
241 | 17679 |NULL
241 | 20037 |440
這是我的查詢
select distinct so.UserId,so.ShopId, (select sa1.beatplanid from beatplansetting bps1
inner join shopassign sa1 on bps1.beatplanid = sa1.beatplanid
where
so.shopid = bps1.shopid
and
sa.userid = sa1.userid
) as PlanName from
shopinandoutlog so
left join beatplansetting bps on so.shopid = bps.shopid
left join shopassign sa on so.userid = sa.userid and bps.beatplanid = sa.beatplanid
where so.userid=241
and
convert(varchar,mobiletransactiondate,106)='01 oct 2016'
and
so.shopid in (20037,17679)