zoukankan      html  css  js  c++  java
  • 复杂的sql语句 + having

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE mapper
    PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
    "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
    <!-- 命名空间的值为dao层接口的权限定名 -->
    <mapper namespace="com.bawei.dao.GdpDao" >

    <select id="findAll" resultMap="maps">
    select g.*,p.name as name,p.pnum as pnum,(g.industryIncome-g.industryInvest) as industryProfits,
    ((g.industryIncome-g.industryInvest)/g.industryIncome*100) as industryProfitsMargin,
    (g.agIncome-g.agInvest) as agProfits,
    ((g.agIncome-g.agInvest)/g.agIncome*100) as agProfitsMargin,
    (g.industryIncome/(g.industryIncome+g.agIncome)*100) as industryBiZhong
    from tb_gdp g LEFT JOIN tb_province p ON g.provinceId=p.id
    <where>
    <if test="provinceId!=null and provinceId!=0 ">
    and provinceId=#{provinceId}
    </if>
    <if test="pnumMin!=null ">
    and pnum &gt;= #{pnumMin}
    </if>
    <if test="pnumMax!=null ">
    and pnum &lt;= #{pnumMax}
    </if>
    <if test="profitsMin!=null ">
    and ((g.agIncome+g.industryIncome-g.agInvest-g.industryInvest)/(g.agIncome+g.industryIncome)*100) &gt;= #{profitsMin}
    </if>
    <if test="profitsMax!=null ">
    and ((g.agIncome+g.industryIncome-g.agInvest-g.industryInvest)/(g.agIncome+g.industryIncome)*100) &gt;= #{profitsMax}
    </if>
    <if test="industryInvestMin!=null ">
    and g.industryInvest &gt;= #{industryInvestMin}
    </if>
    <if test="industryInvestMax!=null ">
    and g.industryInvest &lt;= #{industryInvestMax}
    </if>
    <if test="agIncomeMin!=null ">
    and g.agIncome &gt;= #{agIncomeMin}
    </if>
    <if test="agIncomeMax!=null ">
    and g.agIncome &lt;= #{agIncomeMax}
    </if>
    <if test="monthMin!=null ">
    and g.month &gt;= #{monthMin}
    </if>
    <if test="monthMax!=null ">
    and g.month &lt;= #{monthMax}
    </if>
    </where>
    GROUP BY g.id
    <trim prefix="having" prefixOverrides="and" >
    <if test="yearMin!=null ">
    and SUM(g.agIncome+g.industryIncome) &gt;= #{yearMin}
    </if>
    <if test="yearMax!=null ">
    and SUM(g.agIncome+g.industryIncome) &lt;= #{yearMax}
    </if>
    </trim>
    </select>

    <resultMap type="Gdp" id="maps">
    <id property="id" column="id" />
    <result property="provinceId" column="provinceId" />
    <result property="month" column="month" />
    <result property="industryInvest" column="industryInvest" />
    <result property="industryIncome" column="industryIncome" />
    <result property="eConsumer" column="eConsumer" />
    <result property="agInvest" column="agInvest" />
    <result property="agIncome" column="agIncome" />

    <result property="industryProfits" column="industryProfits" />
    <result property="industryProfitsMargin" column="industryProfitsMargin" />
    <result property="agProfits" column="agProfits" />
    <result property="agProfitsMargin" column="agProfitsMargin" />
    <result property="industryBiZhong" column="industryBiZhong" />

    <!-- <association property="pro" javaType="Province">
    <id property="pid" column="pid" />
    <result property="name" column="name" />
    <result property="pnum" column="pnum" />
    </association> -->
    </resultMap>




    </mapper>

  • 相关阅读:
    【转】Selenium模拟JQuery滑动解锁
    【转】nose-parameterized是Python单元测试框架实现参数化的扩展
    【转】Chrome headless 模式
    RobotFramework:App九宫格滑动解锁
    appium九宫格解锁错误提示:The coordinates provided to an interactions operation are invalid解决办法
    RobotFramework:App滑动屏幕
    robotframework:appium切换webview后,在webview里滑动屏幕
    robotframework:appium切换webview后,在第一个页面操作成功,跳转到第二个页面后,执行命令失败
    robotframework之APP混合H5自动化测试
    Allure生成测试报告
  • 原文地址:https://www.cnblogs.com/liuzhaolong/p/12880517.html
Copyright © 2011-2022 走看看