SSRS Report - Get number of rows in a grouped column - reporting-services

Thank you in advance for all of your help!
I am trying to determine how to get a count of the number of values in the first column of a report where I have it grouped on a number. So for example if I had the table below I would want to have an output of 5 at the bottom of the first column. I have tried multiple things but my attempts either fail or I get the number of rows within each group or the total number of rows in the table.
+----------+---------+-------+------+
| Number | Order | Month | Year |
+----------+---------+-------+------+
| 142010 | 1800053 | 1 | 2018 |
+ +---------+-------+------+
| | 1800045 | 4 | 2018 |
+----------+---------+-------+------+
| 1622220 | 1700021 | 10 | 2017 |
+----------+---------+-------+------+
| 20101040 | 1600065 | 4 | 2016 |
+ +---------+-------+------+
| | 1400056 | 8 | 2014 |
+----------+---------+-------+------+
| 21968145 | 1800004 | 4 | 2018 |
+----------+---------+-------+------+
| 4893154 | 1400021 | 4 | 2014 |
+ +---------+-------+------+
| | 1200047 | 6 | 2012 |
+ +---------+-------+------+
| | 1200056 | 1 | 2012 |
+----------+---------+-------+------+
| Total: 5 | | | |
+----------+---------+-------+------+
I apologize if this has been asked before, I tried searching but could not find a similar question. Any advice would be appreciated!
Thank you in advance!

Related

How to update status of current fiscal year and add new fiscal year using MySQL event scheduler?

I have a table name tbl_fy, I want that status should change automatically from Y to N by the given fy_end_date: 6/30/2021 and meanwhile it also add new fiscal year record in new rows from 7/1/2021 to 6/30/2022.Please help me senior developer in this regard and provide me MySQL event scheduler code in MySQL I will be grateful to you.
+===========+===============+=============+=========+===============+=================+=================+
| fy_doc_id | fy_start_date | fy_end_date | fy_year | fy_active_sts | maker_datetime | update_datetime |
+===========+===============+=============+=========+===============+=================+=================+
| 1 | 7/1/2018 | 6/30/2019 | 2018-19 | N | 2/22/2021 11:07 | 6/2/2021 12:02 |
+-----------+---------------+-------------+---------+---------------+-----------------+-----------------+
| 2 | 7/1/2019 | 6/30/2020 | 2019-20 | N | 8/19/2020 4:10 | 6/2/2021 12:02 |
+-----------+---------------+-------------+---------+---------------+-----------------+-----------------+
| 3 | 7/1/2020 | 6/30/2021 | 2020-21 | Y | 8/19/2020 4:10 | |
+-----------+---------------+-------------+---------+---------------+-----------------+-----------------+

How to merge few rows into one row when it has a same value in mysql

I am getting the following table,
+-------------+-----------+------------+--------------------+
| quantity | year | month | category |
+-------------+-----------+------------+--------------------+
| 122 | 2012 | 7 | 15 |
| 100 | 2012 | 7 | 25 |
| 1029| 2012 | 7 | 10 |
| 212 | 2012 | 7 | 0 |
+-------------+-----------+------------+--------------------+
But I want to get it as how we can merge cells in excel
+-------------+-----------+------------+--------------------+
| quantity | year | month | category |
+-------------+-----------+------------+--------------------+
| 122 | | | 15 |
| 100 | 2012 | 7 | 25 |
| 1029| | | 10 |
| 212 | | | 0 |
+-------------+-----------+------------+--------------------+
checking if this is possible in MySQL?
You might find that aggregation is what you really want:
select year, month, group_concat(quantity), group_concat(category)
from t
group by year, month;
This produces one row for each year/month combination with a list of the quantities and categories. You can get fancy and use a newline to separate the values. They would appear on multiple "lines" but still be one "row".
Note that the ordering is not specified in the question. And without an order by in the group_concat() the values for the two columns might not be in the same order as the original data.

How to SUM by each one iteration with if condition - using mysql?

I want to sum each value by iteration and when the condition matches they trigger the date value and total sum.
+------------+----------------------------------+------------+--------+
| id | EMAIL | created | Amt |
+------------+----------------------------------+------------+--------+
| 61 | abc#gmail.com | 1514909390 | 57.00 |
| 25 | xyz#gmail.com | 1515534837 | 360.00 |
| 36 | zccc#abv.com | 1515645391 | 240.00 |
| 22 | vv#aa.com | 1516419622 | 320.40 |
| 48 | aa#xyz.com | 1516706121 | 240.00 |
+------------+----------------------------------+------------+--------+
Expected Output:
if(Amt=>600) then I need the (Created (1515645391)) the third row created date.
Above is sample data of result. Thanks in advance.

Conditionally move MySQL data between rows in same table

Working in Redmine, I need to copy(not move) data from certain rows to other rows based on matching project id numbers with time entries.
I have included a diagram of the table "custom_values" and my understanding of the design below(CURRENT DATA):
+----+-----------------+---------------+-----------------+-------+
| id | customized_type | customized_id | custom_field_id | value |
+----+-----------------+---------------+-----------------+-------+
| 1 | Project | 1 | 1 | 01 |
| 2 | TimeEntry | 1 | 4 | 01 |
| 3 | Project | 2 | 1 | 02 |
| 4 | TimeEntry | 2 | 4 | 02 |
| 5 | Project | 3 | 1 | 03 |
| 6 | TimeEntry | 3 | 4 | |
| 7 | Project | 4 | 1 | 04 |
| 8 | TimeEntry | 4 | 4 | |
+----+-----------------+---------------+-----------------+-------+
At the risk of oversimplifying,
"id" = The primary key for each entry in custom_values
"customized_type" = Specifies which db table the row is referring to.
"customized_id" = Specifies the primary key for the db table entry previously specified in "customized_type".
"custom_field_id" = Specifies which custom field the row is referring to. Redmine admins can arbitrarily add and remove custom fields.
"value" = The data contained within the custom field specified by
"custom_field_id"
In my situation, the values listed in "value" are representing unique customer id numbers. The customer id numbers did not always get entered with each time entry. I need to copy the customer numbers from the project rows to the matching time entry rows. Each time entry has a project_id field.
So far, here is my mangled SQL query:
SELECT
custom_field_id,
custom_values.value AS 'CUSTOMER_NUMBER',
custom_values.customized_id AS 'PROJECT_ID_NUMBER',
custom_values.customized_type,
time_entries.comments AS 'TIME_ENTRY_COMMENTS'
FROM
redmine_tweaking.custom_values
LEFT JOIN
redmine_tweaking.time_entries ON custom_values.customized_id = time_entries.project_id
WHERE
custom_values.customized_type='Project' AND custom_values.custom_field_id=1;
The query I have so far allows me to see that I have the time entries connected properly to their matching projects, but that is all I have been able to figure out. So in other words, this SQL statement does not exactly solve my problem.
Plus, even if it did work, I think the way I laid it out looks like 200 lbs of bird poop. There must be a better/more optimized way to do this.
Any help would be greatly appreciated. I am relatively new and I have been pouring hours into solving this problem.
UPDATE:
Ok, here is the time_entries table:
+----+------------+---------+----------+-------+----------+-------------+------------+-------+--------+-------+---------------------+---------------------+
| id | project_id | user_id | issue_id | hours | comments | activity_id | spent_on | tyear | tmonth | tweek | created_on | updated_on |
+----+------------+---------+----------+-------+----------+-------------+------------+-------+--------+-------+---------------------+---------------------+
| 1 | 1 | 1 | 1 | .25 | test | 9 | 2015-11-04 | 2015 | 11 | 45 | 2015-11-04 08:18:12 | 2015-11-04 10:18:12 |
| 2 | 2 | 1 | 1 | .25 | test2 | 9 | 2015-11-04 | 2015 | 11 | 45 | 2015-11-04 09:18:12 | 2015-11-04 12:18:12 |
+----+------------+---------+----------+-------+----------+-------------+------------+-------+--------+-------+---------------------+---------------------+
As opposed to the original table that I first posted, the expected output would show this:
+----+-----------------+---------------+-----------------+-------+
| id | customized_type | customized_id | custom_field_id | value |
+----+-----------------+---------------+-----------------+-------+
| 1 | Project | 1 | 1 | 01 |
| 2 | TimeEntry | 1 | 4 | 01 |
| 3 | Project | 2 | 1 | 02 |
| 4 | TimeEntry | 2 | 4 | 02 |
| 5 | Project | 3 | 1 | 03 |
| 6 | TimeEntry | 3 | 4 | 03 |
| 7 | Project | 4 | 1 | 04 |
| 8 | TimeEntry | 4 | 4 | 04 |
+----+-----------------+---------------+-----------------+-------+

How to get sum for different entry in mysql

I have table in mysql like
| service_code | charges | caller_number | duration | minutes |
+--------------+---------+---------------+----------+---------+
| 10 | 15 | 8281490235 | 00:00:00 | 1.0000 |
| 11 | 12 | 9961621709 | 00:00:00 | 0.0000 |
| 10 | 15 | 8281490235 | 01:00:44 | 60.7333 |
| 11 | 2 | 9744944316 | 01:00:44 | 60.7333 |
+--------------+---------+---------------+----------+---------+
from this table I want to get charges*minutes for each separate caller_number.
I have done like this
SELECT sum(charges*minutes) as cost from t8_m4_bill groupby caller_number
but I am not getting expected output. Please help?
SELECT caller_number,sum(charges*minutes) as cost
from t8_m4_bill
group by caller_number
order by caller_number