sqlserver
SELECT T1.* FROM (SELECT 未来之窗.*, ROW_NUMBER() OVER ( ORDER BY rand()) AS ROW_NUMBER FROM (SELECT count(Name) order_count,sum(NowPrice) yye,sum(EmpAchieve) yj FROM emp_performance WHERE ( (CreateDate BETWEEN '2024-09-04 00:00:00' AND '2024-11-04 23:59:59' ) ) AND ( EmployeePost = '0001' ) AND ( EmpCode = '006' ) AND ( ItemClass = '00000001' ) AND ( Specify = 0 )) AS 未来之窗) AS T1 WHERE (T1.ROW_NUMBER BETWEEN 1 AND 1)
1> SELECT T1.* FROM (SELECT thinkphp.*, ROW_NUMBER() OVER ( ORDER BY rand()) AS ROW_NUMBER FROM (SELECT EmpCode,EmpName,count(Name) order_count,sum(NowPrice) yye,sum(EmpAchieve) yj FROM emp_performance WHERE ( (CreateDate BETWEEN '2024-09-04 00:00:00' AND '2024-11-04 23:59:59' ) ) AND ( EmployeePost = '0001' ) AND ( MemCode = 'notnull' ) GROUP BY EmpCode) AS thinkphp) AS T1
2> go
42000 - [SQL Server]选择列表中的列 'emp_performance.EmpName' 无效,因为该列没有包含在聚合函数或 GROUP BY 子句中。
1> SELECT T1.* FROM (SELECT thinkphp.*, ROW_NUMBER() OVER ( ORDER BY rand()) AS ROW_NUMBER FROM (SELECT EmpCode,EmpName,count(Name) order_count,sum(NowPrice) yye,sum(EmpAchieve) yj FROM emp_performance WHERE ( (CreateDate BETWEEN '2024-09-04 00:00:00' AND '2024-11-04 23:59:59' ) ) AND ( EmployeePost = '0001' ) AND ( GuestSex = '女客' ) GROUP BY EmpCode,EmpName) AS thinkphp) AS T1
2> go
+---------+----------+-------------+--------+----------+------------+
| EmpCode | EmpName | order_count | yye | yj | ROW_NUMBER |
+---------+----------+-------------+--------+----------+------------+
| 01 | 吕柯 | 55 | 14083 | 11229.85 | 1 |
| 03 | 力波 | 11 | 1292 | 1069.15 | 2 |
| 05 | 小峰 | 30 | 5140.8 | 4351.86 | 3 |
| 06 | 六小龄童 | 11 | 744 | 653.6 | 4 |
| 201 | 另一 | 37 | 4778 | 4076.55 | 5 |
+---------+----------+-------------+--------+----------+------------+
(5 rows affected)