简体   繁体   English

SSRS Visual Studio 2008-如何将名称与管道分隔的名称列表进行比较?

[英]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

Here is SQLFiddle 这是SQLFiddle

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Visual Studio for SSRS 2008 - 如何在解决方案资源管理器中将报表组织到子文件夹中? - Visual Studio for SSRS 2008 - How to organize reports into subfolders in Solution Explorer? 使用visual studio 2008中的设计器将逗号分隔列表作为参数传递给db2查询的IN子句 - Passing comma delimited list as parameter to IN clause for db2 query using designer in visual studio 2008 如何在Visual Studio SSRS 2008中使用SQL将平均值函数与多个条件语句一起使用 - How to use the average function with multiple conditional statements using SQL in Visual Studio SSRS 2008 如何在Visual Studio SSRS 2008中使用SQL使用多个条件语句 - How to use multiple conditional statements using SQL in Visual Studio SSRS 2008 SQL 2008-管道分隔的字符串拆分 - SQL 2008 - pipe delimited string split 匹配具有不同表的列名的 Pipe 分隔字符串,一旦列名匹配,将其更新为“GOOD” - Match a Pipe delimited string having column names of different table, once column name match update it as 'GOOD' 在teradata中写管道分隔的列名 - Write pipe delimited column names in teradata 在组中使用表达式时,Visual Studio 2008中的SSRS 2008预览缓慢 - SSRS 2008 slow preview in Visual Studio 2008 when using expressions in groups 如何将管道作为管道分隔文件中的数据处理 - How to deal with pipe as data in pipe delimited file Visual Studio 2012架构比较:列顺序和约束名称 - Visual Studio 2012 Schema Compare: Column Order and Constraint Names
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM