[英]SSRS Visual Studio 2008 - How to compare name to pipe delimited list of names?
I am fairly new to sql. 我对sql相当陌生。 I am trying to get a count of activities done by specified people in a persons table. 我试图在人员表中统计指定人员完成的活动。
Pseudo sql query: 伪SQL查询:
select count
from activities table a
left outer join persons table p
where p.lastName + ', ' + p.firstName like 'LastName1, FirstName1 | LastName2, FirstName2 |..."
What is a good way to compare the names in the persons table to a pipe delimited list of names passed as a parameter in an SSRS report? 将人员表中的名称与SSRS报告中作为参数传递的管道分隔名称列表进行比较的一种好方法是什么?
Probably you are looking for something like this: 可能您正在寻找这样的东西:
Total of activities for persons of interest 感兴趣的人的活动总计
SELECT COUNT(*) activities_count
FROM activites a LEFT JOIN
persons p ON a.person_id = p.id
WHERE 'Lee, Mark | Doe, Jhon' LIKE '%' + p.lastName + ', ' + p.firstName + '%'
Number of activities per person 每人的活动数量
SELECT p.id, COUNT(*) activities_count
FROM activites a LEFT JOIN
persons p ON a.person_id = p.id
WHERE 'Lee, Mark | Doe, Jhon' LIKE '%' + p.lastName + ', ' + p.firstName + '%'
GROUP BY p.id
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.