Hiding a field based on another field's hidden property - rdlc

I'm trying to create a RDLC report. My data look like this:
Room Time Capacity Attendee
101 8:00am 100 Fred
101 8:00am 100 Bob
101 8:00am 100 Jim
101 1:00pm 100 Tom
101 1:00pm 100 Steve
101 1:00pm 100 Mike
etc.
I'd like my report to look like this:
Room Time Capacity Attendee
101 8:00am 100 Fred
Bob
Jim
1:00pm 100 Tom
Steve
Mike
I've turned on Hide Duplicates for the Room and Time columns and that works great:
Room Time Capacity Attendee
101 8:00am 100 Fred
100 Bob
100 Jim
1:00pm 100 Tom
100 Steve
100 Mike
But I don't know how to handle the capacity column. I can't set Hide Duplicates on it, because the AM and PM capacities are the same and it will hide the PM capacity.
I thought maybe I could use the Time text box's hidden property, but there doesn't seem to be a way to access it from another text box.

Ok, I figured it out. On the Capacity field, I set HideDuplicates to the field I was grouping the Time on. So it only suppressed duplicates in that group. Which is what I wanted.

Related

SQL Db2 - How to unify two rows in one using datetime

I've got a table where we have registries of employees and where they have worked. In each row, we have the employee's starting date on that place. It's something like this:
Employee ID
Name
Branch
Start Date
1
John Doe
234
2018-01-20
1
John Doe
300
2019-03-20
1
John Doe
250
2022-01-19
2
Jane Doe
200
2019-02-15
2
Jane Doe
234
2020-05-20
I need a query where the data returned looks for the next value, making the starting date on the next branch as the end of the current. Eg:
Employee ID
Name
Branch
Start Date
End Date
1
John Doe
234
2018-01-20
2019-03-20
1
John Doe
300
2019-03-20
2022-01-19
1
John Doe
250
2022-01-19
---
2
Jane Doe
200
2019-02-15
2020-05-20
2
Jane Doe
234
2020-05-20
---
When there is not another register, we assume that the employee is still working on that branch, so we can leave it blank or put a default "9999-01-01" value.
Is there any way we can achieve a result like this using only SQL?
Another approach to my problem would be a query that returns only the row that is in a range. For example, if I look for what branch John Doe worked in 2020-12-01, the query should return the row that shows the branch 300.
You can use LEAD() to peek at the next row, according to a subgroup and ordering within it.
For example:
select
t.*,
lead(start_date) over(partition by employee_id order by start_date) as end_date
from t

Sum of field in a consecutive period based on a condition

I did this without complicated query and with Python. But I'm looking for a way to do this with Django ORM.
I have a table as follows:
user
date
point
Mary
2022/01/04
13
John
2022/01/04
10
Mary
2022/01/03
0
John
2022/01/03
5
Mary
2022/01/01
1
John
2022/01/01
1
Mary
2021/12/31
5
I want to calculate the Sum of points from now() to the date when the point value is greater than one.
Desired Output:
user
sum
Mary
14
13+1
John
10
10

How to merge multiple entries in a data frame into a single entry, Python

I am trying to add all the balances of a customers accounts but I am having difficulties doing such. There are two columns, the 'Customer' and the 'Balance' column. The data frame looks like this:
Customer Balance
John Doe account1 400
John Doe account2 600
John Doe account3 200
Jane Doe account1 500
Jane Doe account2 100
John Deer account1 800
What I am trying to accomplish is this: summing all the accounts' balances into just one account into another data frame or into the same data frame. Whichever is faster or easier.
Customer Balance
John Doe AccountX 1200
Jane Doe AccountX 600
John Deer AccountX 800
Can I please ask for some help regarding this matter? I can't seem to get around this problem. Sorry, still just a beginner programmer trying to learn. Thank you for your time, any help is greatly appreciated.
Use
In [181]: df.groupby(df.Customer.str[:-1].add('X'), sort=False).sum().reset_index()
Out[181]:
Customer Balance
0 John Doe accountX 1200
1 Jane Doe accountX 600
2 John Deer accountX 800

SQL Query sorted by date

looking for query help on this. what would be the query for the below results.
List of all apartments that were occupied on March 1, 2015 sorted by complex and apartment number.
ComplexName ApartmentNumber
-----------------------------
Fox Run 101
Fox Run 102
Fox Run 204
Oak Meadows 103
Villa Maria 11
Villa Maria 12
List of all tenants that had a current lease on March 1, 2015 sorted by property and apartment number
Example results:
ComplexName ApartmentNumber GivenName FamilyName
----------------------------------------------------------
Fox Run 101 Shannon McCoy
Fox Run 102 Larry Thomas
Fox Run 204 Mark Patterson
Oak Meadows 103 Jose Ortiz
Villa Maria 11 Cassie Lee
Villa Maria 12 Robert Woodward
Sum of all rent paid in 2015 grouped by property and month
Example results:
ComplexName Month Rent Revenue
--------------------------------------
Fox Run March 1250.00
Oak Meadows March 1500.00
Oak Meadows April 700.00
Villa Maria March 1200.00
Villa Maria April 600.00
What are you table names and column names, it is difficult to give advice without these: For example if your table was called apartments and had a column occupieddate and appartment number
SELECT *
FROM Apartments
WHERE
occupieddate ='03/01/2015'
ORDER BY
Appartment number;
Could be an answer to your first question

VBA/SQL recordsets

The project I'm asking about is for sending an email to teachers asking what books they're using for the classes they're teaching next semester, so that the books can be ordered. I have a query that compares the course number of this upcoming semester's classes to the course numbers of historical textbook orders, pulling out only those classes that are being taught this semester. That's where I get lost.
I have a table that contains the following:
Professor
Course Number
Year
Book Title
The data looks like this:
professor year course number title
--------- ---- ------------- -------------------
smith 13 1111 Pride and Prejudice
smith 13 1111 The Fountainhead
smith 13 1222 The Alchemist
smith 12 1111 Pride and Prejudice
smith 11 1222 Infinite Jest
smith 10 1333 The Bible
smith 13 1333 The Bible
smith 12 1222 The Alchemist
smith 10 1111 Moby Dick
johnson 12 1222 The Tipping Point
johnson 11 1333 Anna Kerenina
johnson 10 1333 Everything is Illuminated
johnson 12 1222 The Savage Detectives
johnson 11 1333 In Search of Lost Time
johnson 10 1333 Great Expectations
johnson 9 1222 Proust on the Shore
Here's what I need the code to do "on paper":
Group the records by professor. Determine every unique course number in that group, and group records by course number. For each unique course number, determine the highest year associated. Then spit out every record with that professor+course number+year combination.
With the sample data, the results would be:
professor year course number title
--------- ---- ------------- -------------------
smith 13 1111 Pride and Prejudice
smith 13 1111 The Fountainhead
smith 13 1222 The Alchemist
smith 13 1333 The Bible
johnson 12 1222 The Tipping Point
johnson 11 1333 Anna Kerenina
johnson 12 1222 The Savage Detectives
johnson 11 1333 In Search of Lost Time
I'm thinking I should make a record set for each teacher, and within that, another record set for each course number. Within the course number record set, I need the system to determine what the highest year number is - maybe store that in a variable? Then pull out every associated record so that if the teacher ordered 3 books the last time they taught that class (whether it was in 2013 or 2012 and so on) all three books display. I'm not sure I'm thinking of record sets in the right way, though.
My SQL so far is basic and clearly doesn't work:
SELECT [All].Professor, [All].Course, Max([All].Year)
FROM [All]
GROUP BY [All].Professor, [All].Course;
Use your query as a subquery and INNER JOIN it back to the [ALL] table to filter the rows.
SELECT
a.Professor,
a.Year,
a.Course,
a.title
FROM
[ALL] AS a
INNER JOIN
(
SELECT [All].Professor, [All].Course, Max([All].Year) AS MaxOfYear
FROM [All]
GROUP BY [All].Professor, [All].Course
) AS sub
ON
a.Professor = sub.Professor
AND a.Course = sub.Course
AND a.Year = sub.MaxOfYear;