列名寫錯了,應是:
col1 col2 col3
1 2 q
1 8 k
2 7 e
2 9 h
要求返回
col1 col2 col3 col4 col5
1 2 q 8 k
2 7 e 9 h
col1 col2 col3
1 2 q
1 8 k
2 7 e
2 9 h
要求返回
col1 col2 col3 col4 col5
1 2 q 8 k
2 7 e 9 h
解决方案 »
- conn.Execute的问题
- return 是什么作用?
- 如何创建一个不属于dbo的表?
- 求 存储过程写法或 触发器写法。(视图更新或2表更新)
- 想记录一下客户端程序在数据库中执行了那些sql语句,请问如何设置数据库?
- 又要呼唤saucer、TheAres、pengdali了,贴了这么久答案都是错的!!!!
- VS2005 + SQL2000 的数据库程序,写代码的机子可以连数据库,但在客户端机子却连不上
- 用pb自带带的数据库转换成SQL SERVER后,为什么程序出现了好多错误
- 请看看这个sql语句
- ERWin 设置问题
- select "colname"=table.colname from tablename列名设置不明白!
- 求sql语法!
from(
select '1' as col1 , '2' as col2, 'q' as col3
union
select '1' , '8' , 'k'
union
select '2' , '7' , 'e'
union
select '2' , '9' , 'h') ss*/
go
select a.*,b.col2,b.col3 from txt a,txt b where a.col1=b.col1 and a.col2<>b.col2 and a.col3<>b.col3
from
(select col1,col2,col3,' ' as col4,' ' as col5
from tablename
where col1+col2 in
(select col1+col2 from (select col1,min(col2) col2 from tablename group by col1) as b)
union
select col1,'' col2,'' col3,col2 as col4,col3 as col5
from tablename
where col1+col2 in
(select col1+col2 from (select col1,max(col2) col2 from tablename group by col1) as c)
) as a
group by col1