access数据库,内容如下 表名fac
年 月 工厂
2009 1 a
2009 1 b
2009 1 c
2010 2 a
2010 3 b
现在想查询工厂a,b,c都有的年份是那一年,怎样写查询语句,谢谢大家了!
年 月 工厂
2009 1 a
2009 1 b
2009 1 c
2010 2 a
2010 3 b
现在想查询工厂a,b,c都有的年份是那一年,怎样写查询语句,谢谢大家了!
解决方案 »
- 一个三层数据库开发问题
- 希望就一个算法讨论一下!估计最好的结果是没有结果,但是有一些好的想法提出来
- try .. 为什么不能 blockread 起作用?
- 那为高手可以把Delphi中实现MD5算法源代码给我好吗?高手酬谢,不够再给~!
- 吸附窗口
- 任务栏右键菜单的简单问题!
- 用showmodal,窗口上的gifimage的动画能正常显示, 但用show时,窗口的gifimage动画就停止变成了静止图了. 怎么办?
- 把timer事件顺序激活两次(执行时间不能重叠)的如何解决???
- 我是初学者,我到底该看那些书了,那些书比较好了,各位大侠请推荐几本吧
- 数据库问题,如果你能救救我本人感激不尽!!就差以身相许了
- 解释代码 关于TStream
- 这种运算要用什么类型?
select * from fac where 工厂='a' or 工厂='b'or 工厂='c'
而我要求的是
select * from fac where 工厂='a' and 工厂='b'and 工厂='c'我估计要用连接查询,但是不会写
如果是sql server就好办多了
就是不好实现才在csdn提问,希望大家多帮忙
from fac
where 工厂='a' and 工厂='b' and 工厂='c'
select y,sum(c)
from(
select y,m,decode(f,'a',1,'b',1,'c',1,0) c from fac a)
group by y
having sum(c)=3
--SQL
select y,sum(c)
from
(
select y,
case f when 'a' then 1
when 'b' then 1
when 'c' then 1
else 0 end c
from fac) b
group by y
having sum(c)=3
select y,sum(c)
from
(
select y,
case f when 'a' then 1
when 'b' then 1
when 'c' then 1
else 0 end c
from (select distinct y,f from fac) a) b
group by y
having sum(c)=3
在accsee中新建了一个查询
生成了一个如下所示的表
年 a厂 b厂 c厂
2009 1 1 1
2010 1 1 0
然后就比较简单了,只要把把三个厂全部是1的年选出来就可以了