zoukankan      html  css  js  c++  java
  • 通过sql语句支持查询出TreeGrid需要的数据结构

      之前在项目中都是通过查询出基础数据,然后再业务层组装出TreeGrid对应的数据结构。但是个人感觉如果在提供树状结构展示的同时提供excel导出的共就比较麻烦,所以自己就写了一个。

      

    ----树形结构orgcode不能重复,所以用orgCode+subejctstages组装
            select m.orgCode || n.subejctstages orgCode,
                    orgName,
                    orglevel,
                    case
                      when length(m.orgCode) = 6 and n.subejctstages is not null then
                       orgCode
                      else
                       pcode
                    end pcode,
                    subejctstages
              from (select distinct a.code     orgCode,
                                     a.name     orgName,
                                     a.orglevel,
                                     a.pcode
                       from org a
                       left join (select a.testid, a.testcampuscode
                                   from subjectregister a
                                  where a.testid = :testID
                                    and a.testcampuscode like :orgCode
                                  group by a.testid, a.testcampuscode
                                 having count(1) > 0) c
                         on a.testid = c.testid
                           --and a.code = c.testcampuscode
                        and (a.code = c.testcampuscode or
                            a.code = substr(c.testcampuscode, 0, 5) or
                            a.code = substr(c.testcampuscode, 0, 2))
                      where a.testid = :testID1
                        and a.code like :orgCode1
                        and a.enable = :enable
                        and c.testcampuscode is not null) m
              left join (
    ---如果要在查询结果中增加一列,并且这列的值为指定的几个值时,可以组装一个临时表
    select '' subejctstages
                           from dual
                         union
                         select '1' subejctstages
                           from dual
                         union
                         select '2' subejctstages
                           from dual) n
                on length(m.orgCode) = 6
    

      

  • 相关阅读:
    Java8简明教程第二章
    Java8简明教程-2
    Java8简明教程第一章
    Java8简明教程-1
    redis的初级使用
    hdu--4681--dp
    hdu--5091--线段树
    hdu--1542&&1255&1828--线段树<扫描线>
    hdu--5139--bc
    hdu--5128--计算几何<算不上.暴力模拟> && hdu--5131--初级cmp
  • 原文地址:https://www.cnblogs.com/hobby0524/p/11989908.html
Copyright © 2011-2022 走看看