摘要: --场景1: A B a 1 a 2 a 3 b 4 b 5 希望实现如下效果: a 1,2,3 b 4,5 create table tmp as select 'a' A, 1 B from dual union all select 'a' A, 2 B from dual union all select 'a' A, 3 B from dual union all ... 阅读全文
posted @ 2017-11-06 22:02 碧水幽幽泉 阅读(1919) 评论(0) 推荐(0) 编辑
摘要: 在使用数据库使用报表时,往往会遇到矩阵转置。这个需求在Excel中,很容易实现的,但很多人都不知道怎么用Oracle数据库实现。 下面给大家展示几种使用SQL实现的方法。 需求1:表1转置成表2 需求2:表2转置成表1 阅读全文
posted @ 2017-11-06 21:56 碧水幽幽泉 阅读(2799) 评论(0) 推荐(0) 编辑
摘要: >>> str = [5,2,3,7,8,6,4,5] #定义一个列表 >>> str.sort() #调用sort方法,正序排序 >>> str [2, 3, 4, 5, 5, 6, 7, 8] >>> str1= str >>> str1.sort(reverse=True) #倒序排序方法1 >>> str1 [8, 7, 6, 5, 5, 4, 3,... 阅读全文
posted @ 2017-11-06 21:25 碧水幽幽泉 阅读(13263) 评论(0) 推荐(0) 编辑
摘要: >>> str = [1,2,3,4,5] #定义一个列表 >>> str *= 3 #列表*3 >>> str [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5] >>> str.count(1) ... 阅读全文
posted @ 2017-11-06 21:21 碧水幽幽泉 阅读(6385) 评论(0) 推荐(0) 编辑
摘要: 1.赋值: 只是复制了新对象的引用,不会开辟新的内存空间。 2.浅拷贝: 创建新对象,其内容是原对象的引用。 浅拷贝有三种形式:切片操作,工厂函数,copy模块中的copy函数。 如: lst = [1,2,3,[4,5]] 切片操作:lst1 = lst[:] 或者 lst1 = [each fo 阅读全文
posted @ 2017-11-06 21:02 碧水幽幽泉 阅读(5449) 评论(0) 推荐(1) 编辑
摘要: nvl(exp1,exp2): 如果exp1为空,则返回exp2;否则返回exp1nvl2(exp1,exp2,exp3): 如果exp1为空,则返回exp3;否则返回exp2nullif(exp1,exp2): 如果exp1等于exp2,则返回空;否则返回exp1coalesce(exp1,exp 阅读全文
posted @ 2017-11-06 21:00 碧水幽幽泉 阅读(4423) 评论(0) 推荐(0) 编辑
摘要: #方法1: >>> str = ['A1','B1','C1','D1'] #原列表 >>> tmp = str[1] #定义一个中间变量tmp,并赋值str[1] >>> str[1] = str[0] >>> str[0] = tmp >>> str ['B1', 'A1', 'C1', 'D1'] #新列... 阅读全文
posted @ 2017-11-06 20:51 碧水幽幽泉 阅读(731) 评论(0) 推荐(0) 编辑