在oracle sql 查询语句里如何表示,只显示表中有重复出现的数据在只果集里?
selectsd.distro_nbr,im.size_desc,im.sku_desc,sd.store_nbr,sm.name,trunc(sd.in_store_d...
select sd.distro_nbr ,im.size_desc ,im.sku_desc ,
sd.store_nbr ,sm.name ,trunc(sd.in_store_date) ,COUNT(*) as count
from
store_distro sd,item_master im,store_master sm
where
sd.sku_id=im.sku_id
and sd.store_nbr=sm.store_nbr
and im.size_desc in
('31020661'
,'30020501'
,'45020026'
,'45020027'
,'45020028'
,'45020029'
,'45020030'
,'45020031')
and to_char(in_store_date,'yyyy-mm-DD')='2013-10-21'
GROUP BY sd.distro_nbr,im.size_desc,im.sku_desc,
sd.store_nbr,sm.name,sd.in_store_date 展开
sd.store_nbr ,sm.name ,trunc(sd.in_store_date) ,COUNT(*) as count
from
store_distro sd,item_master im,store_master sm
where
sd.sku_id=im.sku_id
and sd.store_nbr=sm.store_nbr
and im.size_desc in
('31020661'
,'30020501'
,'45020026'
,'45020027'
,'45020028'
,'45020029'
,'45020030'
,'45020031')
and to_char(in_store_date,'yyyy-mm-DD')='2013-10-21'
GROUP BY sd.distro_nbr,im.size_desc,im.sku_desc,
sd.store_nbr,sm.name,sd.in_store_date 展开
1个回答
展开全部
你是只想显示查询结果中重复的条目吗?
如果是的话,应该用having 子句,这个应该在学group by 的时候都有介绍
select sd.distro_nbr ,
im.size_desc ,
im.sku_desc ,
sd.store_nbr ,
sm.name ,
trunc(sd.in_store_date) ,
COUNT(*) as count
from store_distro sd,item_master im,store_master sm
where sd.sku_id=im.sku_id
and sd.store_nbr=sm.store_nbr
and im.size_desc in
('31020661','30020501','45020026','45020027','45020028','45020029','45020030','45020031')
and to_char(in_store_date,'yyyy-mm-DD')='2013-10-21'
GROUP BY sd.distro_nbr,im.size_desc,im.sku_desc,sd.store_nbr,sm.name,sd.in_store_date
having count(*)>1
另外:你好多逗号都用的中文写法,我在上边给你改过来了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询