select f.course_node_info_id as nodeid, c.course_node_name as nodename,c.course_node_type as nodelevel,c.course_code,
case when (select course_node_info_id from t_eql_course_frame where f.parent_node_id = course_frame_id) is null then '-1' else (select course_node_info_id from t_eql_course_frame where f.parent_node_id = course_frame_id) end as parentnodeid
from t_eql_course_frame f,t_eql_course_node_info c
where f.course_node_info_id = c.course_node_info_id and c.delete_flag = 0
connect by prior f.course_frame_id = f.parent_node_id start with f.course_frame_id =(select course_frame_id from t_eql_course_frame where course_node_info_id = 'b7dd0eb6-4d96-4d9e-b56c-5045d249049c' )
order by nodelevel, to_number(replace(c.course_code,'.',''))
寫了乙個稍微複雜點的sql心得
select pcode from select h.k,h.d,h.m,h.u,l.areacode,l.areacode substr h.u,4,length h.u h.k pcode from select j.k,j.d,j.m,j.u from select lpad f,3,0 as...
乙個略微複雜的Sql行轉列例項
表結構如上,roomid為房間號,ispresent為1表示該房間有人,ispresent為0表示該房間沒人。現在需要統計每個房間以1開始 以0結束的時間,如果有連續的1則取第乙個1建立時間為開始時間,如果有連續的0則取最後乙個0建立時間為結束時間。先根據roomid和createtime排序,使每...
乙個sql的例子
select dbo.userinfo.username,dbo.userinfo.usertruename,dbo.userinfo.useremail,dbo.userinfo.usermobile,dbo.userinfo.usertelephone,dbo.userinfo.usercar,...