搜狐畅游的一道SQL笔试题
表名为table的表内容如下
Year month value
2009 1 1.1
2009 2 1.2
2009 3 1.3
2009 4 1.4
2010 1 2.1
2010 2 2.2
2010 3 2.3
2010 4 2.4
要求查询结果为
year m1 m2 m3 m4
2009 1.1 1.2 1.3 1.4
2010 2.1 2.2 2.3 2.4
SQL code:
select year,sum(case when month=1 then value) as m1
,sum(case when month=2 then value) as m2
,sum(case when month=3 then value) as m3
,sum(case when month=4 then value) as m4
from tb
group by year
select year,[m1]=max(case when year=[year] and month='1' then value end),
[m2]=max(case when year=[year] and month='2' then value end),
[m3]=max(case when year=[year] and month='3' then value end),
[m4]=max(case when year=[year] and month='4' then value end)
from tb
group by year
SQL code:
declare @table table ([Year] int,[month] int,[value] numeric(2,1))
in
相关问答:
with adod_dict do
begin
close;
commandtext:='select bgqxcode,count(*) wjsl from wscl_wsda_file where wjnd=:tnd group by bgqxcode'; ......
大家帮忙看看这2个sql语句哪个查询的速度更快点。谢谢帮忙。比较着急。在做性能测试。
select * from
表A LEFT OUTER JOIN 表B ON (表A.id || ' ' =表B.id) ,表C , 表D, 表E
Where其他条件
select * ......
环境:1.win2003server+oracle9i
2.oracle9i字符集为AMERICAN_AMERICA.WE8ISO8859P1
3.oracle sql developer版本 1.5.5
现象描述: 1.在sql developer 中查询oracle中的某个表,中文全部显示为乱码。
......
sql可以有两个以上的触发器吗??我指的是for触发器,那其他的呢??
什么意思?
可以的
10个都没问题
可是我写了两个for insert 触发器,造成进程阻塞了呢?怎么办呢?请高人指点
......
在sql中使用output和不使用的区别?
例如:
ALTER PROCEDURE [dbo].[sp_1]
@SYS_LNNO varchar(20),
@SYS_CALLER varchar(20),
@SYS_ORGANIZE varchar(10), ......