Skip to content
Advertisement

SQL Function inside of where clause to see if field is in concatenated list (from parameter)

I have these two lines

The first line counts the number of orders that are One Day Not shipped. The second line uses a Group_Concat function (found here: https://archive.codeplex.com/?p=groupconcat) to return a list of the order numbers of those late orders.

Here is a sample result: 91149220,91155318,91155319, etc

Now what I want to do is take that result/field and then pass it to another report through SSRS. I can pass this parameter to the other report easily, I just need some help making it actually work. I want the second report to take those order numbers and show me all those orders.

So for my second report, I set up the parameter and this is what I tried to do for my where clause

Z_N_CSVToList is a simpe function that breaks apart a string into a list. This is it:

How do I make this work? Running it as it is right now gives me the error “Incorrect syntax near ‘dbo’.”

Do I have to add quotes around the order numbers in the group concat line?

EDIT: I figured it out. If I change my where clause to this, it works.

But now my report only returns the first order from the list, not all of them. Any idea why?

Advertisement

Answer

should be something like this using exists

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement