|
@@ -1,23 +1,43 @@
|
|
<?xml version="1.0" encoding="utf-8" ?>
|
|
<?xml version="1.0" encoding="utf-8" ?>
|
|
<select>
|
|
<select>
|
|
<selectstr>
|
|
<selectstr>
|
|
-SELECT ISNULL(u_factory_profitrate.deptid,v_temp.deptid) AS deptid
|
|
|
|
- ,ISNULL(u_factory_profitrate.bednet_or_mattress,@kind) AS bednet_or_mattress
|
|
|
|
- ,ISNULL(u_factory_profitrate.bednettypeid_mattresstypeid,v_temp.bednettypeid) AS bednettypeid_mattresstypeid
|
|
|
|
- ,ISNULL(u_factory_profitrate.profitrate, 0) AS profitrate
|
|
|
|
- ,u_factory_profitrate.createtime
|
|
|
|
- ,u_factory_profitrate.createby
|
|
|
|
- ,v_temp.deptname
|
|
|
|
- ,v_temp.typename
|
|
|
|
-FROM u_factory_profitrate
|
|
|
|
-RIGHT OUTER JOIN (
|
|
|
|
- SELECT u_dept.deptid
|
|
|
|
- ,u_bednet_type.bednettypeid
|
|
|
|
- ,u_dept.deptname
|
|
|
|
- ,u_bednet_type.typename
|
|
|
|
- FROM u_dept CROSS JOIN u_bednet_type
|
|
|
|
- ) v_temp ON u_factory_profitrate.deptid = v_temp.deptid
|
|
|
|
- AND u_factory_profitrate.bednettypeid_mattresstypeid = v_temp.bednettypeid
|
|
|
|
|
|
+SELECT
|
|
|
|
+ ISNULL( u_factory_profitrate.deptid, v_temp_1.deptid ) AS deptid,
|
|
|
|
+ ISNULL( u_factory_profitrate.bednet_or_mattress,@kind ) AS bednet_or_mattress,
|
|
|
|
+ ISNULL( u_factory_profitrate.bednettypeid_mattresstypeid, v_temp_1.bednettypeid ) AS bednettypeid_mattresstypeid,
|
|
|
|
+ ISNULL( u_factory_profitrate.profitrate, 0 ) AS profitrate,
|
|
|
|
+ u_factory_profitrate.createtime,
|
|
|
|
+ u_factory_profitrate.createby,
|
|
|
|
+ v_temp_1.deptname,
|
|
|
|
+ v_temp_1.typename
|
|
|
|
+FROM
|
|
|
|
+ u_factory_profitrate
|
|
|
|
+ INNER JOIN (
|
|
|
|
+ SELECT
|
|
|
|
+ u_dept.deptid,
|
|
|
|
+ v_temp.bednettypeid,
|
|
|
|
+ u_dept.deptname,
|
|
|
|
+ v_temp.typename
|
|
|
|
+ FROM
|
|
|
|
+ u_dept,
|
|
|
|
+ (
|
|
|
|
+ SELECT
|
|
|
|
+ 1 AS kind,
|
|
|
|
+ u_mattress_type.mattresstypeid AS bednettypeid,
|
|
|
|
+ u_mattress_type.typename
|
|
|
|
+ FROM
|
|
|
|
+ u_mattress_type UNION ALL
|
|
|
|
+ SELECT
|
|
|
|
+ 0 AS kind,
|
|
|
|
+ u_bednet_type.bednettypeid,
|
|
|
|
+ u_bednet_type.typename
|
|
|
|
+ FROM
|
|
|
|
+ u_bednet_type
|
|
|
|
+ ) v_temp
|
|
|
|
+ WHERE
|
|
|
|
+ @kind = v_temp.kind
|
|
|
|
+ ) v_temp_1 ON u_factory_profitrate.deptid = v_temp_1.deptid
|
|
|
|
+ AND u_factory_profitrate.bednettypeid_mattresstypeid = v_temp_1.bednettypeid
|
|
</selectstr>
|
|
</selectstr>
|
|
<where>
|
|
<where>
|
|
<when>
|
|
<when>
|