请教一个复杂的sql问题

修炼成精 2009-05-20 11:23:17
表[news_sort]包含字段[sortid]、[title]、[parentid]等
表[news_QasUnit]包含[QasID]、[ProductID]、[QasUnit]等(其中news_QasUnit.ProductID=news_sort.sortid)
表[news_Price]包含[ID] [int] IDENTITY(1,1) NOT NULL,
[Price] [money] NULL,
[Createdate] [datetime] NULL,
[CenterFlag] [int] NULL CONSTRAINT [DF_news_Price_CenterFlag] DEFAULT ((1)),
[Bak] [nvarchar](1000) NULL,
[QasID] [int] NULL,
[RunCircs] [varchar](50) NULL,
[Count] [int] NULL,
[Repertory] [varchar](50) NULL,
如何得到parentid=4时的所有价格,要求价格按news_sort.title分组
...全文
89 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
-狙击手- 2009-05-20
  • 打赏
  • 举报
回复
select a.title,c.price
from new_sort a
left join new_aqsunit b on b.prodectid = a.sortid
left join news_price c on b.qasid = c.qasid
where a.parentid = 4
order by 1,2
等待戈多12 2009-05-20
  • 打赏
  • 举报
回复

select a.price,b.title from news_price a,news_sort b
where b.parentid=4 and b.sortid=news_qasunit.productID
and a.qasID=new_qasunit.qasID
group by b.title
寻找Python之禅 2009-05-20
  • 打赏
  • 举报
回复

select price
from news_price
where news_price.qasid in (select qasid
from news_qasunit
where productid in (select sortid
from news_sort
where parentid=4))

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧