MySQL中的group_concat函数怎么在sybase中实现?

装逼侠 2015-07-30 02:30:10
select distinct a.computername,a.mac , GROUP_CONCAT(distinct a.username) as usernames,GROUP_CONCAT(distinct a.userid) as userids from (select distinct nons.* , users.username,client.computername from noncontrol_softwares nons left join users on nons.userid=users.userid left join client on nons.mac=client.mac) as a group by a.mac
怎么将这段MySQL语句转换成sybase的?
...全文
768 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
装逼侠 2015-07-31
  • 打赏
  • 举报
回复
引用 5 楼 andkylee 的回复:
[quote=引用 4 楼 WWWWA 的回复:] 示例: select A,B,step=convert(int,null),C= convert(varchar(255),null) into #t from OrgTable order by A,B go declare @a varchar(10),@c varchar(255),@step set @step = 0 set @c= '' update #t set C = case when A=@a then @c+''+B else B end, @c = case when A=@a then @c+''+B else B end, @a = A, @step=@step+1, step= @step go select A,C into #t1 from #t group by A having step = max(step) go --result /* select * from #t1 go
你这段代码是在sqlserver中测试的吧? sybase中SQL语句中变量不能迭代。 也就说update #t 。。。 @step=@step+1, 变量@step始终等于1.[/quote]
引用 5 楼 andkylee 的回复:
[quote=引用 4 楼 WWWWA 的回复:] 示例: select A,B,step=convert(int,null),C= convert(varchar(255),null) into #t from OrgTable order by A,B go declare @a varchar(10),@c varchar(255),@step set @step = 0 set @c= '' update #t set C = case when A=@a then @c+''+B else B end, @c = case when A=@a then @c+''+B else B end, @a = A, @step=@step+1, step= @step go select A,C into #t1 from #t group by A having step = max(step) go --result /* select * from #t1 go
你这段代码是在sqlserver中测试的吧? sybase中SQL语句中变量不能迭代。 也就说update #t 。。。 @step=@step+1, 变量@step始终等于1.[/quote] 请问能说得详细点吗?我的这个需求具体要怎么实现?
WWWWA 2015-07-31
  • 打赏
  • 举报
回复
class,name a,a1 a,a2 a,a3 a,a4 a,a5 b,b1 b,b2 b,b3 ALTER PROCEDURE "zz"."blljtest"() BEGIN declare @ee varchar(500); declare @ee1 varchar(500); declare @num int; set @ee=''; set @ee1=''; set @num=1; select *,space(500) as gd,0000 as gdnum into #tt from blljtest; update #tt set gd=(case when @ee1=class then @ee || ',' || name else name end) , @ee=(case when @ee1=class then @ee || ',' || name else name end), gdnum=(case when @ee1=class then @num+1 else 1 end), @num=(case when @ee1=class then @num+1 else 1 end),@ee1=class; select a.* from #tt a inner join (select class,max(gdnum) as ma from #tt group by class) b on a.class=b.class and a.gdnum=ma; end
  • 打赏
  • 举报
回复
不太好实现, 用存储过程写吧。
  • 打赏
  • 举报
回复
引用 4 楼 WWWWA 的回复:
示例: select A,B,step=convert(int,null),C= convert(varchar(255),null) into #t from OrgTable order by A,B go declare @a varchar(10),@c varchar(255),@step set @step = 0 set @c= '' update #t set C = case when A=@a then @c+''+B else B end, @c = case when A=@a then @c+''+B else B end, @a = A, @step=@step+1, step= @step go select A,C into #t1 from #t group by A having step = max(step) go --result /* select * from #t1 go
你这段代码是在sqlserver中测试的吧? sybase中SQL语句中变量不能迭代。 也就说update #t 。。。 @step=@step+1, 变量@step始终等于1.
WWWWA 2015-07-30
  • 打赏
  • 举报
回复
示例: select A,B,step=convert(int,null),C= convert(varchar(255),null) into #t from OrgTable order by A,B go declare @a varchar(10),@c varchar(255),@step set @step = 0 set @c= '' update #t set C = case when A=@a then @c+''+B else B end, @c = case when A=@a then @c+''+B else B end, @a = A, @step=@step+1, step= @step go select A,C into #t1 from #t group by A having step = max(step) go --result /* select * from #t1 go
装逼侠 2015-07-30
  • 打赏
  • 举报
回复
引用 2 楼 WWWWA 的回复:
没有现成的函数,只有用变量累加的方法来实现
怎么个变量累加法呢?刚开始搞SQL,请大神不吝赐教
WWWWA 2015-07-30
  • 打赏
  • 举报
回复
没有现成的函数,只有用变量累加的方法来实现
装逼侠 2015-07-30
  • 打赏
  • 举报
回复
求助sybase大神...

2,596

社区成员

发帖
与我相关
我的任务
社区描述
Sybase相关技术讨论区
社区管理员
  • Sybase社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧