請用關系代數表示下列查詢語句F(drinker,bar)S(bar,beer)L(drinker,beer
1select *,*r,* from f as a,s as b,l as c where *=* and *r=*r group by *,*r,* having max(count(*))[原理,將三個關系表聯系起來,分組統計出酒吧,人,啤酒的統計信息,在找出最大行數的列]2select bar from s where not beer='青島啤酒'3select drinker from f where drinker not in (select *r from f as a,s as b where *=* and *='雪花啤酒')[原理:查詢出去了提供雪花啤酒的酒家的人,再not in排除掉]4select *r,* from f as a,s as b where *=* where *='青島啤酒' group by *r,* having Count(*)>1。
一條查詢語句
select partName ,isnull(sum((case when blankNum=1 then 1 end)),0) as 'count(blankNum=1)', isnull(sum((case when blankNum=2 then 1 end)),0) as 'count(blankNum=2)',isnull(sum((case when blankNum=3 then 1 end)),0) as 'count(blankNum=3)' from partList a , blankList b where *=* and *ID=4 and *pe=4 and group by partName測試下吧,應該是能滿足你的需求的。