如何在组合查询中过滤某个字段的重复值 在线等,解决即给分!!
如题:代码如下:
select a.bit_intent_id,b.bit_intent_id,c.bit_name,c.bit_syscode,c.bit_code from crm_intent a
left join crm_intent_car_model b on a.bit_intent_id=b.bit_intent_id
left join base_modal c on b.bit_intent_car_modal_id=c.bit_id
这样取出来b.bit_intent_id的值是多条的如果只想取默认的第一条如何取?
谢谢了!试了加:
where b.bit_intent_id <> (select top 1 b.bit_intent_id from crm_intent_car_model ) 不能取出值 望高手指教!!
------解决方案--------------------不太明白你的意思,你是只想取出这次查询的第一条b.bit_intent_id的值?
那你看看这样行不行
select top 1 bit_intent_id_2 from
(
select bit_intent_id_1=a.bit_intent_id,bit_intent_id_2=b.bit_intent_id,c.bit_name,c.bit_syscode,c.bit_code from crm_intent a
left join crm_intent_car_model b on a.bit_intent_id=b.bit_intent_id
left join base_modal c on b.bit_intent_car_modal_id=c.bit_id
)