Browse Source

1、优化工厂利润列表查询

MY 1 month ago
parent
commit
c6bc5a7c31
1 changed files with 28 additions and 35 deletions
  1. 28 35
      JLHHJSvr/DataStore/web_factory_profitratelist.xml

+ 28 - 35
JLHHJSvr/DataStore/web_factory_profitratelist.xml

@@ -1,42 +1,35 @@
 <?xml version="1.0" encoding="utf-8" ?>
 <select>
   <selectstr>
-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
+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
 	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 
+		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 ON @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>
   <where>