TABLE FIELD1, FIELD2 (字段类型为BOOL)
0 1
1 1
有没办法求这两条记录的或结果?
加的话可以用SUM().有没求或的函数呢?
0 1
1 1
有没办法求这两条记录的或结果?
加的话可以用SUM().有没求或的函数呢?
解决方案 »
- 如何将数据库中一个表(完整的表)从一个数据库导到另一台数据库呢?不是联网的环境,如果联网,导入导出就行了。另外,不用备份还原的方法
- A、B两个表的模式完全相同,如何知道小表A的所有记录都包含在大表B中,请写出其SQL语句
- sql语句读取列名
- 帮忙看一下哪里错了
- 求一个sql语句,两个关联表,主表中包含子表行数
- 一个奇怪的现像
- 百分救助,store procedure里的error handling!!!在线等!!!!!
- 急问一个问题,谢谢啊关于删除记录
- 偶的菜问题:SELECT语句怎么写,可以做到搜索每次1~20条记录,第二次搜索21~40条记录
- microsoft 的sql server中的视图(view)是不是实体视图?
- 创建当前活动事务日志的备份用什么命令?
- 会议室的申请功能:要求当输入某时间段时,就能检测那段时间是否已给别人占有了。请看例子
insert into @t select 0,1
insert into @t select 1,1
insert into @t select 0,0select a,b,a|b from @t
--这样?
insert into m values(1,0)
insert into m values(0,1)
insert into m values(1,1)
insert into m values(0,0)select a,b, a^b
from m
结果:
a b
---- ---- ----
1 0 1
0 1 1
1 1 0
0 0 0(所影响的行数为 4 行)
insert into m values(1,0)
insert into m values(0,1)
insert into m values(1,1)
insert into m values(0,0) select a,b, a|b
from m
insert into @t select 0,1
insert into @t select 1,1
insert into @t select 0,0
insert into @t select 1,0select a,b,a|b from @t
--弄个完整的
insert into @t select 0,1
insert into @t select 1,1
insert into @t select 0,0select a,b,a|b from @t
--这样?
错错错!!!!不是列之间的或运算.
是记录集结构某一个列的或运算
insert #t1
select 0,1
union
select 1,0
union
select 0,0
union
select 1,1
select result=case when (col1<>0 or col2<>0) then 1 else 0 end from #t1
insert #t1
select 0,1
union
select 1,0
union
select 0,0
union
select 1,1
select result=case when (col1<>0 or col2<>0) then 1 else 0 end from #t1
这位你好像也把两个列拿来或运算了.跟第一个一样.不是我要的
我是说我想把select出来的两条记录的相同一个字段进行或运算.不知你们还懂我的意义了么?
SUM(某列)你们知道是怎么加的么?就像SUM一样的意思.