[英]Getting extra count in SQL query?
I am facing issue getting extra records due to some data can any body guide me how can we avoid this.由于某些数据可以指导我如何避免这种情况,因此我面临获取额外记录的问题。
Below is the code of my data :以下是我的数据代码:
SELECT
employecode, COUNT(*) AS empName, Empcharges AS 'damageproperties'
INTO
#empdetails
FROM
[EMp_table]
WHERE
emp_status = 'new' AND currecntlyworking = '1'
AND CAST(joindate AS date) = @date
GROUP BY
empcharges, employeecode
Due to different amount of empcharges I'm getting two count per code.由于附加费的数量不同,每个代码获得两个计数。
But want to fetch data like this:但是要获取这样的数据:
Please suggest some idea to handle this as in my stored procedure, we have used 9 select statements as mentioned above and doing join and selecting the columns.. so need the solution for whole scenario.请提出一些想法来解决这个问题,例如在我的存储过程中,如上所述,我们使用了9条select语句并进行联接和选择列..因此需要针对整个场景的解决方案。
I am facing issue getting extra records due to some data can any body guide me how can we avoid this.由于某些数据可以指导我如何避免这种情况,因此我面临获取额外记录的问题。
Below is the code of my data :以下是我的数据代码:
SELECT
employecode, COUNT(*) AS empName, Empcharges AS 'damageproperties'
INTO
#empdetails
FROM
[EMp_table]
WHERE
emp_status = 'new' AND currecntlyworking = '1'
AND CAST(joindate AS date) = @date
GROUP BY
empcharges, employeecode
Due to different amount of empcharges I'm getting two count per code.由于附加费的数量不同,每个代码获得两个计数。
But want to fetch data like this:但是要获取这样的数据:
Please suggest some idea to handle this as in my stored procedure, we have used 9 select statements as mentioned above and doing join and selecting the columns.. so need the solution for whole scenario.请提出一些想法来解决这个问题,例如在我的存储过程中,如上所述,我们使用了9条select语句并进行联接和选择列..因此需要针对整个场景的解决方案。
I am facing issue getting extra records due to some data can any body guide me how can we avoid this.由于某些数据可以指导我如何避免这种情况,因此我面临获取额外记录的问题。
Below is the code of my data :以下是我的数据代码:
SELECT
employecode, COUNT(*) AS empName, Empcharges AS 'damageproperties'
INTO
#empdetails
FROM
[EMp_table]
WHERE
emp_status = 'new' AND currecntlyworking = '1'
AND CAST(joindate AS date) = @date
GROUP BY
empcharges, employeecode
Due to different amount of empcharges I'm getting two count per code.由于附加费的数量不同,每个代码获得两个计数。
But want to fetch data like this:但是要获取这样的数据:
Please suggest some idea to handle this as in my stored procedure, we have used 9 select statements as mentioned above and doing join and selecting the columns.. so need the solution for whole scenario.请提出一些想法来解决这个问题,例如在我的存储过程中,如上所述,我们使用了9条select语句并进行联接和选择列..因此需要针对整个场景的解决方案。
I am facing issue getting extra records due to some data can any body guide me how can we avoid this.由于某些数据可以指导我如何避免这种情况,因此我面临获取额外记录的问题。
Below is the code of my data :以下是我的数据代码:
SELECT
employecode, COUNT(*) AS empName, Empcharges AS 'damageproperties'
INTO
#empdetails
FROM
[EMp_table]
WHERE
emp_status = 'new' AND currecntlyworking = '1'
AND CAST(joindate AS date) = @date
GROUP BY
empcharges, employeecode
Due to different amount of empcharges I'm getting two count per code.由于附加费的数量不同,每个代码获得两个计数。
But want to fetch data like this:但是要获取这样的数据:
Please suggest some idea to handle this as in my stored procedure, we have used 9 select statements as mentioned above and doing join and selecting the columns.. so need the solution for whole scenario.请提出一些想法来解决这个问题,例如在我的存储过程中,如上所述,我们使用了9条select语句并进行联接和选择列..因此需要针对整个场景的解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.