I'm going to attempt to word this question without being too confusing.
We have a report we want to show each patient and their insurance. Each of the insurance in the patient's record is number by an Order Number. However, we don't only want to show that; I want to put in certain criteria so that if Insurance A has order number 1 under the Patient ID, show all of this patient's insurance. If the patient does not have Insurance A in Order Number 1, do not show this patient nor any of their information on the report.
In the code below, guarantor is referring to insurance. So order number and guarantor name is what we're focusing on. Here's the code I've put into Section Expert for the Suppress option. What I assume is if it meets the criteria, TRUE will suppress the information, else FALSE will allow the information. However, this is not sufficient as it suppresses all of the other information.
if {billing_guar_order_no_ep.guarantor_order_number} = "1" AND
{billing_guar_order_no_ep.guarantor_name} = "Medicare" then
false
else
true
What I'm assuming is it will need to iterate or loop through every patient and if it finds this information, list ALL of the patient's information and move forward, else suppress and move forward. I hope this makes sense.
Example:
|Patient ID|Order Number|Guarantor Name|
| -------- | ---------- | ------------ |
|1 | 1|Medicare |
|1 | 2|Medicaid |
|2 | 1|Medicaid |
|2 | 2|Medicare |
In the above example, what I want is for the report to show everything from Patient #1 (including all order numbers) and to not even show Patient #2 in the report. However, what's happening is Patient #1 does show up, but only Order Number 1; it suppresses all the other information.
What am I missing?
The query that you want will be an adaptation of this:
select *
from data d
where not exists (
select 1
from data
where pat_id=d.pat_id
and order_id=1
and guarantor_name='Medicaid'
)
The 'Linking Expert' doesn't support this syntax, so you'll need to use a Command instead.
Process:
get the current query by selecting Database | Show SQL Query ...
create a new report
select 'add command' from within the database expert
paste the query, then adapt it
Related
It was hard to think of a title for this question, so hopefully that did make sense.
I will explain further. I have a flow of data from an Excel file and each row has one of two words in the last column. It will either contain "Open" or "Current".
So lets say I have an input that looks like this:
NAME | SSN | TYPE
John | 12345| Current
Katy | 99999| Current
Sam | 33333| Current
John | 12345| Open
Cody | 55555| Open
And the goal is grab only a person once. Each person has their unique id as their SSN. I want to grab Open rows if both Open and Current exist for that person. If only Current exists, then grab that.
So the final output should look like this:
NAME | SSN | TYPE
Katy | 99999| Current
Sam | 33333| Current
John | 12345| Open
Cody | 55555| Open
NOTE: As you can see, the first entry for John has been removed since he had an Open row.
I have attempted this already but it is sloppy and I figure there must be a better way. Here is an image of what I have done:
Talend flow
Here's how you can do it:
First sort the data by Name, and Type descending (this is important so that for each person, the Open record is on the top); then in the tMap filter it like this:
Numeric.sequence(row2.name, 1, 1) == 1
Only let the record through if this is the first we're seeing this name.
I am VERY new to Access - I was sort of thrust into designing a database for a research project I'm involved in. So, please bear with me because I know next to nothing :) The problem I am having is thus:
My database is for a medical research project, and is very time and date dependent, by which I mean I need to capture the date and time for each piece of data so that we end up with a sort of timeline of events for each subject.
As is, I have something like the following for each piece of data: (Each in it's own field)
ArrivalDate
ArrivalTime
HeartRateDate
HeartRateTime
HeartRateData
TemperatureDate
TemperatureTime
TemperatureData
BloodPressureDate
BloodPressureTime
BloodPressureData
There are around 200 similar pieces of data that I need to collect for each patient. To avoid having to re-enter the same data over and over, and also to reduce the potential for error, I would like to have all of the date fields in a given patient record default to the first one that is entered, in this case "Arrival Date". However, I also need each date field to be editable without affecting the others. The reason for this is that in the event that a patient's visit occurs over the span of a few days we can accurately record that.
I have tried messing around with the default value setting, as well as setting the control source to reference the "Arrival Date" field, but then of course any changes to one field affect them all. I am not even sure that what I am trying to do is possible but I will appreciate any help and/or suggestions!
Thank you in advance
Having all this data in separate columns of a big table isn't going to work. You don't measure things like temperature or blood pressure only once per patient, do you?
This is a classic one-to-many relation.
You should have a separate Measurements table, looking e.g. like this:
+--------+-----------+---------------+------------------+-----------+
| MeasID | PatientID | MeasType | MeasDateTime | MeasValue |
+--------+-----------+---------------+------------------+-----------+
| 1 | 1 | Temperature | 2017-05-17 14:30 | 38.2 |
| 2 | 1 | BloodPressure | 2017-05-17 14:30 | 130/90 |
| 3 | 1 | Temperature | 2017-05-17 18:00 | 38.5 |
| 4 | 2 | Temperature | etc. | |
+--------+-----------+---------------+------------------+-----------+
As Barmar wrote, there is no reason to have separate columns for date and time.
In the form where measurements are entered, you can use the BeforeInsert event to set MeasDateTime to the current time, with the Now() function.
So the user never has to enter it manually, but they can edit it if the measurement was at a different time than entering the data.
using SSRS 2008 R2 here.
I've been able to get a similar layout to work with a regular tablix, where I get each group header to fall on top of each other in the same column by adding a row within that group, however I need to use a Matrix because of a dynamic column (month below). When I try to add another row, it only adds a row where the monthly data starts, not in the headers. So the headers stay in their each column. In trying to keep the example as easy as possible, I'm trying to do something like this (Store theme).
STORE NAME | MONTHS
STATE | SALES
TOWN(S) | SALES
which woudl look something like this in a Matrix
WALMART JAN FEB MARCH etc....
TEXAS | 3000 2000 6000
HOUSTON | 1000 500 2500
AUSTIN | 2000 1500 3500
I've only been able to produce something like this where each group is a seperate column:
STORE | STATE | CITY | JAN | FEB | MAR |
WALMART | TEXAS | HOUSTON | 1000 | 500 | 2500 |
| AUSTIN | 2000 | 1500 | 3500 |
Again, I've been able to get a regular Tablix formatted like this, but a Matrix I'm struggling with. Can anyone help me on how to do this? Thank you in advance!!
It is possible using a tablix/matrix and adding some special grouping settings.
Add a tablix with the City field in Row Groups pane:
Right click the City group, select Add Group / Parent Group. Choose State and set Add a Group Header
Delete the left most column (State column added in the previous step).
Note the group is still present.
Right click the STATE group and add a Parent Group as step 2. In this case choose STORENAME
Again delete the left most column (Store Name column added in the previous step)
You will get the following tablix.
Delete the first row
Set the Fields using the Row Group hierarchy order. STORENAME/STATE/CITY
Right click the first cell in the next column and add a group / Column Group / Parent Group. Choose MONTH in group by.
Delete the first row.
Set SUM(Fields!Sales.Value) in the next cells in the same column.
After these steps you will get a tablix like this in design window.
It should produce:
Let me know if this helps.
I have a table format that appears in this type of format:
email | interest | major | employed |inserttime
jake#example.com | soccer | | true | 12:00
jake#example.com | | CS | true | 12:01
Essentially, this is a survey application and users sometimes hit the back button to add new fields. I later changed the INSERT logic to UPSERT so it just updated the row where email=currentUsersEmail , however for the data inserted prior to this code change there are many duplicate entries for single users. i have tried some group by's with no luck, as it continually says the
ID column must appear in the GROUP BY clause or be used in an
aggregate function.
Certainly there will be edge cases where there may be clashing data, in this case maybe user entered true for the employed column and then in the second he/she could have enter false. For now I am not going to take this into account yet.
I simply want to merge or flatten these values into a single row, in this case it would look like:
email | interest | major | employed |inserttime
jake#example.com | soccer | CS | true | 12:01
I am guessing I would take the most recent inserttime. I have been writing the web application in scala/play, but for this task i think probably using a language like python might be easier if i cannot do it directly through psql.
You can GROUP BY and flatten using MAX():
SELECT email, MAX(interest) AS interest,
MAX(major) AS major,MAX(employed) AS employed,
MAX(inserttime) AS inserttime
FROM your_table
GROUP BY email
I have a crystal report, it has a group by statement based on two fields
Companyname
Account Type
Now Crystal report work and it does group by "companyname" but it does not group by "account type". I have two types of account, "Regular and Premium". One company has both type of account with us and it pulls on regular and not premium. What do you think is the issue.
I am new to crystal report. I am familiar with SQL Though. The differences that I see is
There is no aggregate function used for any column - in SQL an aggregate field is required to get meaningful result
There are about 10 fields in the report but group by is used only on two fields - in SQL you have to group by all fields if there are more than two fields
The group by fields are in the middle and in end - again in SQL the order of groupby field is important
In this case I am grouping by companyname first and then account status. Any insight will be helpful.
Note that I generated the equivalent SQL statement from Crystal Report. That query was ok except there were not group by statements. I added those and the aggregate column myself and I do get the same result as I am getting in Crystal (but the SQL report is more accurate as it does group by both the fields not just one).
Edit: Example Date. Each company can have multiple account of the same type. I want aggregate on "Company Name" and "AccountType" so that the data is listed as follow.
+----+--------------+-------------+------+
| ID | Company Name | AccountType | Sale |
+----+--------------+-------------+------+
| 1 | ABC | I | 500 |
| 2 | ABC | I | 600 |
| 3 | ABC | O | 1000 |
| 4 | ABC | O | 2000 |
| 5 | ABC | O | 3000 |
| 6 | XYZ | O | 2500 |
| 7 | LMN | O | 3400 |
+----+--------------+-------------+------+
Output I want from the above table is
+--------------+-------------+------+
| Company Name | AccountType | Sale |
+--------------+-------------+------+
| ABC | I | 1100 |
| ABC | O | 6000 |
| XYZ | O | 2500 |
| LMN | O | 3400 |
+--------------+-------------+------+
Update to incorporate comment discussion and revised question:
There are two basic options for resolving this issue:
1) Revise the SQL to perform the desired aggregation.
2) Within Crystal, add two groups, one for the company, then one for the account type.
Before you add groups in crystal, you have several standard sections, including the Report Header, Page Header, Details, Report Footer, and Page Footer.
If you do not perform grouping, each row that is read in the database will be displayed in the details section (technically, the entire details section is repeated for each row).
When you add the first group (Company), Crystal adds a Group Header #1 before the Details section and a Group Header #1 after the Details section.
If you run the report at this point, for each company Crystal will show the Group Header before each group of detail records associated with that company, then will show all of the detail records for that company, and finally, will shown the Group footer for that company.
Typically, the group header is used to display common information for that grouping that does not need to be repeated for each detail record. In this example, we could display the company name and other information related to the company.
Likewise, the group footer is typically used to display summary information for all of detail records displayed within that group.
In this case, we could add an aggregate that would summarize the Sale amount, which would be the total sales for that company, regardless of the account type.
When the second group is added, it will perform sub-grouping on the original group.
When the second group is added, Crystal will place a Group Header #2 below Group Header #1 and above the Details and will place a Group Footer # 2 directly below the details and above the Group Footer #1.
At this point, you have a report format similar to the following:
Group Header #1 (Company)
Group Header #2 (Account Type)
Details (the individual sale records)
Group Footer #2
Group Header #1
In this case, for each company, we want to group the details records by account type. So we can add information that describes the account type, if we want, to the Group Header #2 and we can add aggregates to Group Footer #2 to display totals for each account type within the company.
Now, if all that is desired is to show the totals for each account type within each company, then the only section that we need to show in the report is Group Footer #2. All of the fields (company, account type, sale aggregate) are available in this Footer, so we don't need any of the additional areas.