前几天去一家公司笔试,其中有两题目如下:
1.请写出在SQL Server中创建交叉表的步骤
2.请写出在Crystal Report中创建交叉表的步骤我不知第2题在这合不合适,如果这题也得到解答那就再另加分
1.请写出在SQL Server中创建交叉表的步骤
2.请写出在Crystal Report中创建交叉表的步骤我不知第2题在这合不合适,如果这题也得到解答那就再另加分
解决方案 »
- select * from table where 条件A and 条件B and 条件C;条件ABC的执行顺序是什么 ?或者说有没有执行顺序?
- 如何测试查询速度?
- 装上sql2005 managerment studio express,但是还是找不到查询分析器呀?如何用呀?
- having count(*)>1
- 大家帮帮忙
- 数据库转移!
- Unable to read local eventlog (reason: 事件日志文件已在读取间更改。).
- SQL多对多的关联
- 怎样把文件夹中hotelmanagement.mdf这样的数据库文件导入到microsoft sql server中?
- 根据周反查日期问题
- 求触发器编写?
- 2005,都用windows身份验证,用127.0.0.1或者local可以登录,但是用自己的IP不可以
IF OBJECT_ID('TEST') IS NOT NULL
DROP TABLE TEST CREATE TABLE [Test] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[name] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[subject] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[Source] [numeric](18, 0) NULL
) ON [PRIMARY]
GOINSERT INTO [test] ([name],[subject],[Source]) values (N'张三',N'语文',60)
INSERT INTO [test] ([name],[subject],[Source]) values (N'李四',N'数学',70)
INSERT INTO [test] ([name],[subject],[Source]) values (N'王五',N'英语',80)
INSERT INTO [test] ([name],[subject],[Source]) values (N'王五',N'数学',75)
INSERT INTO [test] ([name],[subject],[Source]) values (N'王五',N'语文',57)
INSERT INTO [test] ([name],[subject],[Source]) values (N'李四',N'语文',80)
INSERT INTO [test] ([name],[subject],[Source]) values (N'张三',N'英语',100)
Go--交叉表语句的实现:
--用于:交叉表的列数是确定的
select name,sum(case subject when '数学' then source else 0 end) as '数学',
sum(case subject when '英语' then source else 0 end) as '英语',
sum(case subject when '语文' then source else 0 end) as '语文'
from test
group by name