oracle多表联合查询怎样去重复

2025-02-28 04:47:02
推荐回答(2个)
回答1:

重复是指你所查询的所有列值都一样,那你可以很容易地使用 DISTINCT 关键字去排重。
看了你的图片,猜测你的意思是想把部份重复的列只显示一次。

如果那样的话,你需要分组和归类。一般用在生成报表的时候。
但是从你的问题中也不知道你想得到什么样的格式和数据,所以,暂时帮不了你。

建议你去看一下 Rollup 和 CUBE 的使用。也许看完你自己就知道怎么做了

回答2:

前面加个distinct 试试

select distinct c.customerid,c.shopname,c.score,bs.tcbtime,bs.tcetime,
bs.orderprice,m.telephone,bs.gmsgs
from bas_customer c,bas_custbusiness bs,msg_control m where bs.customerid=c.customerid
and bs.customerid=c.customerid and m.customerid = bs.customerid and c.customerid in('webeg')