create table t1
(id int identity(1,1),
name varchar(2))
create table t2
(id int,
num int)
insert into t1(name) values('A')
insert into t1(name) values('B')
insert into t2(id,num) values(1,11)
insert into t2(id,num) values(1,111)
insert into t2(id,num) values(2,22)
insert into t2(id,num) values(1,222)
insert into t2(id,num) values(1,2222)
select from t1
select from t2;
with
p1 as
(select aid,aname,[num] from t1 as a inner join t2 as b on aid=bid),
p2 as
(select row_number() over(partition by id order by [num]) as rownum,id,name,[num] from p1)
SELECT id,name,[1],[2],[3]
FROM p2
PIVOT(SUM([num]) FOR rownum IN ([1],[2],[3])) as pvt
步骤如下:
1、打开Eclipse后,选择Window;
2、在Windwos下选择Open perspective;
3、在右侧显示的菜单中选中database Development,Eclipse自动切换到database Development视图;
4、从左侧的树型菜单中选择Database Connections,右键点击new;
5、在d出new connection profile中选择要连接的数据库类型,这里选择mysql;
6、接下来选择driver,选择对应的数据库的驱动版本,指定jar、properties;
完成连接配置。
注:使用open scrapbook to edit sql statement,执行sql。
以上就是关于SQL 多条记录赋值多个变量全部的内容,包括:SQL 多条记录赋值多个变量、怎样从数据库中选择出现次数最多的变量并作为提示框在eclipse中d出、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)