Is it possible to put the grouping field on top of the table in SSRS? - reporting-services

Is it possible to do this kind of layout in SSRS?
2012/11/01
-----------------------------
| Order # | Product | Qty |
-----------------------------
| | Mouse | 3 |
| 1 | Keyboard | 2 |
| | CPU | 5 |
-----------------------------
| | Mouse | 1 |
| 2 | Keyboard | 7 |
| | Lan Cable | 7 |
-----------------------------
2012/11/02
-----------------------------
| Order # | Product | Qty |
-----------------------------
| | Mouse | 2 |
| | Keyboard | 8 |
| 3 | Memory | 4 |
| | CPU | 2 |
| | Battery | 1 |
-----------------------------
I tried finding a property that could do that, tried dragging the field on top too but to no avail :-)

Yes you can do this, it's easiest if you nest two tablixes (a table inside a list). Make a list that groups on the date field. Inside the list place the table that groups rows on the order id. This would look like this:
----
2012/11/01 |
----------------------------- |
| Order # | Product | Qty | |
----------------------------- |
| | Mouse | 3 | |
| 1 | Keyboard | 2 | | --- List item 1
| | CPU | 5 | |
----------------------------- |
| | Mouse | 1 | |
| 2 | Keyboard | 7 | |
| | Lan Cable | 7 | |
----------------------------- |
----
----
2012/11/02 |
----------------------------- |
| Order # | Product | Qty | |
----------------------------- |
| | Mouse | 2 | | --- List item 2
| | Keyboard | 8 | |
| 3 | Memory | 4 | |
| | CPU | 2 | |
| | Battery | 1 | |
----------------------------- |
----
Alternatively you can make one big table:
group rows on the date
below that, group rows on the order id
create a group header for the topmost group, merge the cells in the header, and display the date there
In this approach I'm not 100% sure if you can easily repeat the headers with each item in the date-group.

Related

MySQL Events in information system into programming language

For example I have 3 tables:
Users:
+----+-------------+
| id | nickname |
+----+-------------+
| 1 | Don2Quixote |
| 2 | Pechenye |
| 3 | Maryana |
| 4 | Luman |
| 5 | Tester |
+----+-------------+
Matches:
+----+----------+---------------------+
| id | owner_id | match_end_timestamp |
+----+----------+---------------------+
| 1 | 1 | 1610698498 |
| 2 | 2 | 1610699911 |
| 3 | 3 | 1610701672 |
| 4 | 1 | 1610711211 |
| 5 | 1 | 1610725289 |
+----+----------+---------------------+
matches_players:
+----------+------+-------------+---------+
| match_id | team | slot_number | user_id |
+----------+------+-------------+---------+
| 1 | 1 | 1 | 1 |
| 2 | 1 | 2 | 2 |
...........................................
| 3 | 1 | 1 | 3 |
+----------+------+-------------+---------+
match_end_timestamp is future timestamp. My goal is to get event in programming language on reaching this date and send notification to each player in table matches_players where match_id is id of just ended match. Is it possible? Or the only solution is to store additional timer in my programming language in RAM?

How to query closest date and display the specific data

Hi guys i have a problem displaying a data from my query code.
I want to display a data from the closest date today. Below is my sample data and my output data that i want to display.
Landing Area data
|landing_id| id_number| address |
---------------------------------
| 1 | 00012345 | Ozamiz |
| 2 | 00012346 | Tudela |
| 3 | 00012347 | Nailon |
| 4 | 00012348 | Taboo |
| 5 | 00012349 | Jimenez |
| 6 | 00012350 | Tangub |
---------------------------------
Percentage data
|percent_id| landing_id | percentage | date_added |
-----------------------------------------------------------
| 1 | 1 | 9 |2018-10-08 21:42:22 |
| 2 | 1 | 12 |2018-10-03 20:43:32 |
| 3 | 1 | 43 |2018-10-15 19:43:49 |
| 4 | 3 | 22 |2018-10-10 15:43:56 |
| 5 | 3 | 77 |2018-10-12 18:44:03 |
-----------------------------------------------------------
And this is my query code.
SELECT fish_landing.landing_id,
percentage.landing_id as percentage_landing_id,
percentage.percentage,
percentage.date_added
FROM percentage
RIGHT OUTER JOIN fish_landing ON percentage.landing_id = fish_landing.landing_id
ORDER BY fish_landing.landing_id ASC
The output of my code is this, where the date_added and the percentage is not exact.
|percent_id| percentage | date_added |
----------------------------------------------
| 1 | 9 |2018-10-08 21:42:22 |
| 2 | | |
| 3 | 22 |2018-10-10 15:43:56 |
| 4 | | |
| 5 | | |
| 6 | | |
----------------------------------------------
And the output data that I want to display is the table below, where the percentage that has a latest date_added in every landing_id will be display.
|landing_id| percentage | date_added | address |
--------------------------------------------------------
| 1 | 43 |2018-10-15 19:43:49 | Ozamiz |
| 2 | | | |
| 3 | 77 |2018-10-12 18:44:03 | Nailon |
| 4 | | | |
| 5 | | | |
| 6 | | | |
--------------------------------------------------------
I hope you can help me in my problem.
You can get maximum date_added for a landing_id in a separate derived table and use it for joining.
Try the following:
SELECT fish_landing.landing_id,
percentage.percentage,
percentage.date_added,
fish_landing.address
FROM fish_landing
LEFT JOIN percentage ON percentage.landing_id = fish_landing.landing_id
LEFT JOIN (SELECT landing_id, MAX(date_added) AS max_date_added
FROM percentage
GROUP BY landing_id) AS dt
ON dt.landing_id = percentage.landing_id AND
dt.max_date_added = percentage.date_added
ORDER BY fish_landing.landing_id ASC

DIV as Table - Showing multiple tables on a page. Stacked below and left-right

I need to create a few tables to hold data. This is how the structure looks the diagram below. Table 1 and Table 2 will be in the first row and there must be a gap in between the tables. Table 3,4,5 will be in the next row and again, there should be some gap in between the tables.
-------------- -------------------
| | | |
| | | |
| | | |
| | | |
| Table 1 | | Table 2 |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
--------------- -------------------
--------------- --------------- ---------------
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| Table 3 | | Table 4 | | Table 5 |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
--------------- --------------- ---------------
This is what I have attempted to do so far, but it isn't perfect. Any help would be appreciated. https://jsfiddle.net/Leyzejfs/
This is a bit of a strange question (because it's not clear what it is exactly what you want), but nevertheless: Just add some margin to the CSS rule for .table
https://jsfiddle.net/1qyyeja5/1/
(you only have four tables in your jsfiddle as opposed to the five your were drawing in your question, but the principle is the same)
However, if your tables should be arranged in some kind of grid, you can place them into another "wrapper table" to have them aligned both ways - horizontally and vertically , like in - yes: a table...

Enumerate rows in mysql based on groups with dates in different columns

I have a question very similar to this one, but different (aka, I couldn't extend the answer to that one to fit my purposes. Due to the second WHERE condition, specifically).
I have a table which tracks the visit number for customers. There are two types of visits:
| ID | InStoreVisit | InStoreDate | OnlineVisit | OnlineDate |
|----|--------------|-------------|-------------|------------|
| 1 | 1 | 1/1/11 | | |
| 1 | 2 | 1/2/11 | | |
| 1 | | | 1 | 1/3/11 |
| 1 | 3 | 1/4/11 | | |
| 2 | | | 1 | 2/2/12 |
| 2 | 1 | 2/3/12 | | |
| 2 | | | 2 | 2/4/12 |
I need to create a new column which has a sort of 'global visit number' as such:
| ID | InStoreVisit | InStoreDate | OnlineVisit | OnlineDate | GobalVisit |
|----|--------------|-------------|-------------|------------|------------|
| 1 | 1 | 1/1/11 | | | 1 |
| 1 | 2 | 1/2/11 | | | 2 |
| 1 | | | 1 | 1/3/11 | 3 |
| 1 | 3 | 1/4/11 | | | 4 |
| 2 | | | 1 | 2/2/12 | 1 |
| 2 | 1 | 2/3/12 | | | 2 |
| 2 | | | 2 | 2/4/12 | 3 |
I'm getting mixed up on the WHERE condition with which I can do the self-join. Any advice greatly appreciated.

Selected Child Categories based on parent categories from another table

I have two tables
rules
With three step hierarchy
|id | name | parent |
|---|-------|--------|
| 1 | A | 0 |
| 2 | B | 0 |
| 3 | A(1) | 1 |
| 4 | A(2) | 1 |
| 5 | B(1) | 2 |
| 6 | A(1.1)| 3 |
| 7 | A(1.2)| 3 |
| 8 | A(2.1)| 4 |
| 9 | B(1.1)| 5 |
| 10| A(3) | 1 |
Subject
|id | date | rules | group |
|---|---------------------|-------|-------|
| 1 | 2016-05-20 18:24:20 | 2 | AQR48 |
| 2 | 2016-05-20 19:31:17 | 5 | AQR52 |
| 3 | 2016-05-21 18:11:37 | 6,7,4 | AQR48 |
I need to get second step rules based on group and ruleid(first step) of subject table data
When group = 'AQR48' and rules.parent=1 result should be
|id | name | parent |
|---|-------|--------|
| 3 | A(1) | 1 |
| 4 | A(2) | 1 |
I tried it like this but with out success.
select rules.id,rules.name,rules.parent from rules left join subject on find_in_set(rules.id,subject.rules) where rules.parent=1 AND subject.group='AQR48'
With this I get output as
|id | name | parent |
|---|-------|--------|
| 4 | A(2) | 1 |
Anyone could help me with this