I need to do a report in SSRS that gets a patient by case number or surgery ID name using the same textbox over ODBC.
So my query is SELECT Name, DOB FROM Surgeries Where caseno = ? or sgid = ?.
Since in ODBC, these are 2 separate parameters and I need to search only for one or the other. Is it possible? How my query can be optimized?
Although I think that earlier comments should work fine, here is an alternative approach.
Please note that this is untested.
SELECT Name, DOB FROM Surgeries WHERE ? IN(caseno, sgid)
This also assumes that the parameter is NOT multi-valued.
Related
Good evening all,
for a parameter in a ssrs report I want to specify the values available. Every label will have the same value, apart from one label - this one will have two values. Everything works fine if I just specify one value per label. But if I use two for one label, it will show error "ORA-01722: invalid number".
I assume I am missing some formatting here to make sure I can pass on two values? The sql query is correct I believe, it specifies the bind by doing "...WHERE account_no in (:account)..."
Below an example of what I am trying to do. Numbers are random
Would appreciate any help here. Thanks
As you used IN SSRS will inject the values into your dataset query. If the parameter is text (ignore the fact it's actually numeric), the query will try to process something like SELECT * FROM myTable WHERE account_no IN ('3333,4444') which is obviously wrong.
You'll need to parse the values in your dataset query with something like this
SELECT * FROM myTable
WHERE account_no in (SELECT [value] FROM string_split(#account, ','))
You haven't mentioned what database you are using, the above is based on SQL Server but the same principle applies.
How do you custom name only the last page in a report? in a way where it overrides any page names already generated from any groupings.
There are at least two ways to do this.
The easiest is if you can change the last group name in your dataset to be whatever you want. However, I guess this is might not be suitable.
The second way
There are a few assumptions here as you have given almost no information in your question.
Assumes your group is sorting alphabetically.
Let's assume your groups are department names.
Accounts
Client Service
Sales
Warehouse
Your page name expression would be something like
=IIF(Fields!GroupColumn.Value = MAX(Fields!GroupColumn.Value, "myDataSet"), "The Last Page", Fields!GroupColumn.Value)
Basically we are just checking to see if the group name is the same as the last (Maximum) group name in the entire dataset, if so, use a literal value, if not just use the group name.
I'm trying to built a report in SSRS where I can display all the skus available to one product in different store.
The only problem is when I do so, it generate a new row for the same product for a sku located in another store.
I would like to regroup them on the same row.
Any idea??
You'll need to add a row group to group by whatever other fields you need in the group, and then for your merged SKU field you can do something like:
=JOIN(LOOKUPSET(Fields!CandidateField.Value, Fields!CandidateField.Value, Fields!SKU.Value, 'DataSet1"), ",")
Replace "CandidateField" with the name of a field that can be "joined" back to itself (this is done by the LOOKUPSET() function) to produce the collection of SKUs you need for each row group. Also replace "DataSet1" with the name of your dataset.
And you can replace the comma with whatever delimiter you want.
The JOIN function is what is concatenating the values together; LOOKUPSET() is providing an input array to it.
Note that this only works in SSRS 2008 R2 or newer.
EDIT: Note that this is one means of doing this via SSRS; you could also handle this in your SQL if you'd prefer.
I have a database to calculate my expenses. I record expenses with negative numbers, and salary with positive numbers. When I make the month report, and sum the values, it sums it all including salary. I want to code of Visual Basic to sum negative numbers only. I know about Filter property, but the Filter I put disappears when I close database. Can you help me, please?
You can build your report using a query or use the Where argument of the OpenReport method of the DoCmd object in versions of Access since 2003.
EDIT re comment
The easiest way to create a query is to use the query designer, viewed in SQL View, you should see something on the lines of:
SELECT Amount
FROM MyTable
WHERE Amount <=0
To keep this simple, lets say I have two tables.
The first is called Employees. It contains an id field and an employee_name field.
The second is called Pay. It contains an id field, an employee_id field and an amount field.
Now, I want to run a report on Pay that shows me how much each employee got paid by showing me only the Employee.employee_name and the Pay.amount.
Obviously, I'm going to have to take the employee_id field from the Pay table and match it up with the the id field from Employees, but I have no idea how to do that.
I know a little VBA and am pretty knowledgeable with SQL, but MS Access has me so confused I'm about to kill myself. I hate Access so much, I want to take it outside behind the middle school and get it dead.
This seems like a relatively easy problem, so someone has to know how to do this. Any help would be hugely appreciated.
You are looking for a query like this
SELECT Employees.Id,
Employees.employee_name,
Sum(Pay.amount) AS SumOfamount
FROM Pay INNER JOIN
Employees ON Pay.employee_id = Employees.Id
GROUP BY Employees.Id,
Employees.employee_name;
If you wish to make this as part of a list box, you can either save the sql as a query and set the Listbox property under the Data Tab called RowSource to the Saved Query Name, or you can set the sql string as the RowSource.
Remember to have a look at the Properties called Column Count ( something like 0;3;3 0 being to hide the first column ) and Column Heads (to include column headers, default NO )
If you widh to craete a Report using the data, you can go about this the same way ( Saved Query or Use the Sql String ). The Query/Sql String can be set in the Data Tab in the Record Source property. Now you can add the fields to the report from the Existing Fields window.