你用的事一个表,
SELECT * FROM (select * from table) A LEFT JOIN (select * from table where year='2003') B ON A.ID =B.ID 你试试开!
SELECT * FROM (select * from table) A LEFT JOIN (select * from table where year='2003') B ON A.ID =B.ID 你试试开!
解决方案 »
- sql 数据循环好难写,谁来帮忙啊?
- 返回值为表变量的自定义函数怎么写?
- vs 2008连接sql server 2008 r2连不上
- 请教一个count统计函数的细节,Count(*)和Count(1)的问题?这个1具体什么解释!具体内容详述!
- 数据库锁什么时候用
- 一个查询问题
- 如何将SQLSERVER2000中的表结构及数据转到ACCESS数据库中????特急~~~~~谢谢~~~~
- 数据库从一台机子导到另一台上,出现的怪异问题,大家进来看看!
- SOS请高手帮忙,急急急!发布复制中日志读取代理程序出错。请大家帮忙看一看!
- 一个SQL的基础问题
- 如何用BCP命令导出固定长度的TXT文件。
- 大家看看如何实现这样的表格???
from [table]
from [table]
create table [table](id int,name varchar(10),[year] varchar(10))
insert [table] select 1,'a',2003
union all select 2,'b',2004
union all select 3,'c',2003
go--查询
select id,name,[year]=case [year] when '2003' then '2003' else null end
from [table]
go--删除测试
drop table [table]/*--测试结果id name year
----------- ---------- ----
1 a 2003
2 b NULL
3 c 2003(所影响的行数为 3 行)
--*/