How to add Group Count on Reporting Pages (rdl) - rdl

Here is my question...I have a RDL report that has four groupings. I am using Count to show how many records are within each group. I am wanting to display one of the Grouping Counts above so you don't have to drill down to the next level.
So let me see if I can explain.
On Group 1 Row 1, I have a column with "Count (5)"
On Group 2 Row 1, I have a column with "Count (3)"
On Group 2 Row 2, I have a column with "Count (2)"
So Group 2 Row 1 and 2 add up to Group 1 Row 1. I am wanting to break out Group 1 Row 1 with the information shown in Group 2.

Related

How do I aggregate data in sql for multiple rows of data by column name?

hi im new to sql and trying to understand how to work with data structures. I have a table
fact.userinteraction
interactionuserkey visitdatecode
0 20220404
1 20220404
5 20220402
5 20220128
If the interaction userkey number repeats then, i want a column called number of visits. in this case, for interactionuserkey 5, there are 2 total visits since its repeated twice. for interactionuserkey 0, number of visits =1 and so on. Basically, sum duplicates in column 1 and give total count AS number of visits. How do i do this?
In sql, it's resolved using basic aggregation
select interactionuserkey, count(*)
from your_table
group by interactionuserkey

Query for SUM of grouped COUNT in SQL Query table

Please take this as an example where my primary table is
ID Name
-- -------
1 Alpha
2 Beta
3 Beta
4 Beta
5 Charlie
6 Charlie
as there is duplication in Name column. Resultant Table after grouping them by name, with count column is -
Name Count
------- -----
Alpha 1
Beta 3
Charlie 2
SUM 6
Here SUM is taken out as separate row of all the resultant COUNT column, I am trying to get SUM of all the rows from the resultant Count function from primary table but as separate query for SUM unlike separate row
My table has 2 fields Roles and User_Id.
I have already tried Below query
select orl.role ,
SUM (orl.role) as "No of Users"
from org_user_roles orl
group by orl.role
i think this is a string column with numerical values. So need to cast it to int before performing the sum() operation
select orl.role,
sum(orl.user_id::int) as "No of Users"
from org_user_roles orl
group by orl.role
If you want to count rows (users) for each role, use the COUNT aggregate function - not SUM:
select "role", count(*) as "No of Users" from org_user_roles group by "role";
To get the sum of these grouped counts - which is just the overall row count - use:
select count(*) as "Sum" from org_user_roles;

In SSRS, tablix not picking up the text generated in a dynamic SQL for grouping

In SSRS, I have written a dynamic sql in which a column is populated from a case statement. The sql query is correctly populating the column in sql result but when I use it in a tablix for creating a group and summing it by 'X' column as shown below. It does not populate at all. Rest of tablix is populating fine. Can somebody please help.
eg: The columns generated by SQL has below result. Bucket is generated by case statement. In tablix I want the first row to be grouped by Bucket and in next row sum by the x column
> **X** **Bucket**
> 0 NULL
> 1 Today
> 1 1-10
> 1 11-20
> 0 NULL
> 1 1-10
> 1 Today
> 1 20-30
Expected Result
> Today 1-10 11-20 20-30
> 2 2 1 1
Set your column grouping expression to Bucket and the detail row will simply have an expression like =SUM(Fields!X.Value).
You don't need any row grouping

SQL query for aggregate on multiple rows

I have data in a table like following
Name indicator
A 1
A 2
A 3
B 1
B 2
C 3
I want to get count of Names, for which both indicator 1,2 exists. In the preeceding example, this number is 2 (A & B both have indicator as 1, and 2).
The data I am dealing with is moderately large, and i need to get the similar information of some other permutations of (pre defined ) indicators (which i can change, once i get base query).
Try this:
SELECT Name
FROM Tablename
WHERE indicator IN(1, 2)
GROUP BY Name
HAVING COUNT(DISTINCT indicator) = 2;
See it in action here:
SQL Fiddle Demo

sequential numbering of rows

I have to customize a SQL view to be able to perform a system integration test. One table keeps track of the transactions and the LINE ITEMS per transactions (for example, transaction 2 has three items, so there are three consecutive rows corresponding to the same transaction number) What I need to accomplish is to get a column where I keep track of the number of items for THAT transaction, always starting from 1 for each transaction.
For example, the first column is TransactionNumber and the second is DesiredOutput:
1 1
1 2
2 1
2 2
2 3
3 1
4 1
4 2
ETC...
I know how to number consecutive rows on the WHOLE table, but I cannot find any reference to this numbering that depends on a value on another row.
For SQL Server 2005+ and Oracle you can use the following:
SELECT TransNumber, ROW_NUMBER() OVER(PARTITION BY Transnumber ORDER BY Something) [DESIRED COLUMN OUTPUT]
FROM YourTable