sql问题,100分的 - MS-SQL Server / 基础类
http://topic.csdn.net/u/20100520/16/1b999f17-1c5a-4901-b264-633436347b5f.html?54908
帮顶给分不?
sybase不支持自定义函数,没办法
你可以参考临时表和游标的方法试试
ddd
--游标
use sybase
create table tb
(
Id int,
value varchar(50),
)
insert into tb values('1','aa')
insert into tb values('1','bb')
insert into tb values('2','aaa')
insert into tb values('2','bbb')
insert into tb values('2','ccc')
go
declare @AA varchar(50)
declare @BB varchar(50)
declare @CC varchar(50)
declare my_cursor cursor for select value from tb
open my_cursor
fetch next from my_cursor into @AA
fetch next from my_cursor into @BB
select Id ,value=(@AA+','+@BB ) from tb where value=@BB
fetch next from my_cursor into @AA
fetch next from my_cursor into @BB
fetch next from my_cursor into @CC
select Id,value=(@AA+','+@BB+','+@CC) from tb where value=@AA
close my_cursor
deallocate my_cursor
drop table tb
已经测试过了,可用,楼主可以试试.
sybase啊,我自建的数据库中测试的,刚学,是不是我搞错了....
相关问答:
可能因为工作的原因 接触数据库这块比较少,之前都是做程序这块,数据库这块都有专门的人来做 分工都很明细 所以对数据库这一块完全不了解。前段时间 去面试了几家公司 几乎都是在数据库这块挂掉的 连个简单的SQ ......
如何在SQL2005中设定定时作业,比如说定时清理某些表的数据,
或者是定时的将某些表的数据导出excel!
在线等待,急急急,最好是详细步骤!
之前我做的作业有点问题!
帮UP
参考:http://hi.baidu.com/toiota ......
tab1 字段:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 字段:goodsid,goodskind(商品类型)
tab3 字段:goodskind(商品类型),kindname
结果:
得到商品类型在一段时间 ......
求个vb中的sql语句的写法,次sql语句的用法是分页程序
我写的如下:其中A是用来接收每页显示的记录的条数,B是用来接收显示的当前的页面.
sqltext="select top A * from log where id not in(select top ( ......
现在有一个部门表dept(部门名称,部门号。。)有一个人员表emp(姓名,人员编号,职位,薪资,部门)
emp表中的内容是这样的:
a 1 工程师 3000 软件部
b 2 普通员工 2000 硬件部
c 3 工程师 4000 硬件部
d ......