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)