How to: ..WHERE STRTOSET(#p1), STRTOSET(#p2) - reporting-services

I am trying to filter a query by two (multi select) parameters.
It works fine when doing this for the first one, but complains when I add the the second one.
Is my syntax wrong is there a better way to achieve what I want?

MDX WHERE has very little in common with SQL WHERE. MDX WHERE does not effect the number of rows that return, just which cube slice the cells are to be retrieved from.
I would use the FILTER function since a MDX WHERE clause must be a tuple (cell address), no more no less, i.e.,
(Dim1.Member, Dim2.Member, etc.)
Hope this helps.

Tried subqueries?
SELECT
[Measures].[YourMeasure]
ON COLUMNS,
[Dimensions].[YourDimension]
ON ROWS
FROM
(SELECT STRTOSET(#p1) ON COLUMNS FROM
(SELECT STRTOSET(#p2) ON COLUMNS FROM
[YourCube] ) )

Related

SSRS - How to create a sum (total) of an expression column?

After plenty of research, it seemd I can't find a well-explained solution to my problem. I'll join some screenshots of my Tablix, group rows, and group columns to help you to understand.
First of all, here's my tablix. It's linked to a SharePoint List.
The expressions are all like this :
=Count(Fields!ID.Value, "NameOfTheGroup")
It counts the number of elements that are filtered by one of the group chosen in the expression, and it works perfectly fine at this point.
Now, here's my groups :
They all contains filters tomanage the count precisely to the need.
What I want to do : In the last row, I want to display the sum of each column that is in a group row. But theses rows aren't datasets fields, they are just only expressions, and I can't find a way to create a proper total of each column. I heard of Running Value but the few solutions I found about it didn't work.
Thanks for the future help.
EDIT: Actually, the problem seems to be much more complex: any rows I create under my group rows are invisible : if I create a new row under the "Classification", outside the "Classification" row group, the expression I insert in the "CDI", "CDD", etc... columns stay blank. I tried with various expression or just values like "Hello World".

Taking and filtering MYSQL results on another params table

Please help me with the query.
I want to get all projects_ids, that contain params and values of params.
When i use one criteria (not three, as an image) - it works and gaing results!
When use all, I think the CPU is trying to get a record when sometimes 3 criterion are passed. Need to get all projects_ids that contains criterion.
My solution at this time is SELF-JOIN.
For each param i create "JOIN" to table ON "projects_id", and add more WHERE statements with new tables.
10 params = 10 joins.

Is it possible to use IFNULL() with a * in a SELECT statement with MySQL? If not, what is my alternative?

Here is what I have that currently works in a SELECT statement:
SELECT
movieitemdetails.barcode,
IFNULL(movieitemdetails_custom.title, movieitemdetails.title) AS title
FROM
...
The problem is that I need to have my SQL be more dynamic when it comes to column names and the amount of columns I have. I need to use * to dynamically pull back all rows. Here is some example pseudocode to show you what I need:
IFNULL(movieitemdetails_custom.*, movieitemdetails.*) AS *
I need it to bring back all of the columns with the same name on each table and do the IFNULL comparison. Obviously the code above is not correct.
Does anyone have any ideas on how to make what I have more dynamic involving *?
Note to certain people: Please don't give me flak about how I shouldn't use *. I know in general use it's not recommended, but in this specific project it is what we're going with.
No, the IFNULL() function accepts only two scalar expressions, not wildcard expressions like *.
To make this query more dynamic, your options are:
Build the query with application code, appending an IFNULL() expression for each such pair of columns. Then submit the query.
Or:
Fetch all the columns independently with SELECT * ... and then sort out which ones to use in application code.
You would have to do each column individually, like so:
SELECT
movieitemdetails.barcode,
IFNULL(movieitemdetails_custom.title, movieitemdetails.title) AS title
IFNULL(movieitemdetails_custom.col2, movieitemdetails.col2) AS col2
IFNULL(movieitemdetails_custom.col3, movieitemdetails.col3) AS col3
FROM
...
Not sure exactly what you mean by having it be more dynamic regarding the amount of columns though.. a SELECT statement cannot have a variable number of columns, so if you want that behavior you would need to use a stored procedure or build your SQL dynamically.

Mysql sum as last row

Is it possible to have the SUM of all numaric fields in the last of a set of rows?
As of now, I'm using a very simple query such as:
SELECT
*,
SUM((UNIX_TIMESTAMP(end) - UNIX_TIMESTAMP(start))/3600)
FROM
times
in SQL you cant have a column that appears in only one row, likewise, you also cant have a row that doenst contain all the columns from the other rows.. So having a row that contains something unique is not possible. You can, however, add the calculated column to all rows in the dataset or do the calculation in the calling code after the data is returned.
I think what you are looking for is GROUP BY WITH ROLLUP you will find details on that in the MySQL manual.

Linq-to-Sql Count

I need to do a count on the items in a joined result set where a condition is true. I thus have a "from join where where" type of expression. This expression must end with a select or groupby. I do not need the column data actually and figure it is thus faster not to select it:
count = (from e in dc.entries select new {}).Count();
I have 2 questions:
Is there a faster way to do this in terms of the db load?
I have to duplicate my entire copy of the query. Is there a way to structure my query where I can have it one place for both counts and for getting say a list with all fields?
Thanks.
Please pay especial attention:
The query is a join and not a simple table thus I must use a select statement.
I will need 2 different query bodies because I do not need to load all the actual fields for the count but will for the list.
I assume when I use the select query it is filling up with data when I use query.Count vs Table.Count. Look forward to those who understand what I'm asking for possible better ways to do this and some detailed knowledge of what actually happens. I need to pull out the logging to look into this deeper.
Queryable.Count
The query behavior that occurs as a
result of executing an expression tree
that represents calling
Count(IQueryable)
depends on the implementation of the
type of the source parameter. The
expected behavior is that it counts
the number of items in source.
In fact, if you use LinqToSql or LinqToEntities, Queryable.Count() is sent into the database. No columns are loaded to memory. Check the generated sql to confirm.
I assume when I use the select query it is filling up with data when I use query.Count vs Table.Count
This is not true. Check the generated sql to confirm.
I have to duplicate my entire copy of the query. Is there a way to structure my query where I can have it one place for both counts and for getting say a list with all fields
If you need both the count and the list, get the list and count it.
If you need the count sometimes and other times you need the list... write a method that returns the complex IQueryable, and sometimes call .Count() and other times call .ToList();
I do not need the column data actually and figure it is thus faster not to select it.
This is basically false in your scenario. It can be true in a scenario where an index covers the result columns, but you don't have any result columns.
In your scenario, whatever index is chosen by the query optimizer, that index can be used to make the count.
Sum up: Query optimizer will perform the optimization you desire.
//you can put a where condition here
var queryEntries = from e in dc.entries select e;
//Get count
queryEntries.Count();
//Loop through Entries, so you basically returned all entries
foreach(entry en in queryEntries)
{}