multiple Filters in Jasper Report - sql

I have Created a Student Information Report using Jasper report (SQL database). I need to filter the report using different parameters. e.g
Branch Wise
Gender Wise
Class Wise
Section Wise and some more
I'm using Java Swing as a front end application.
My question is for each filter i have to write separate query?? or is there a way in jasper to manage different filter for example.

You can manage your query based on the parameter you got using a different expression which is $P!{}.
Follow below steps to achieve your needs,
Create a parameter, say $P{BranchWise}.
In the expression of that parameter, write something like
$P{Branch} != null ? "and branch = '"+$P{Branch}+"'" : ""
Likewise create parameter for different filters.
Now use these parameters in your query as below
select * from table1 where 1=1 $P!{BranchWise} $P!{GenderWise} $P!{ClassWise} ....
Hope this should solve your problem.

Related

How to write query for optional parameters in SSRS

I have six parameters in Report Builder. They are the following:
ProjectName
ConstructionYear
Engineer
Contractor
EPANumber
ID
#ProjectName, #ConstructionYear, and #EPANumber do not have any null values in the dataset while the rest do have null values for some records.
For the report I need to be able to pull records using any of the above combinations. Including only using one parameter, two parameters, three parameters, etc.
For example using #ProjectName and #EPANumber to pull results or using #ProjectName, #EPANumer, and #ID to pull results. Another example would be using #ConstructionYear and #Engineer or using just #Contractor.
What does my query need to look like to be able to support all of the possible combinations? Do the parameters in Report Builder need to be set up in a certain way?

Need to Display records Group By in SSRS

In SSRS 2008, I am developing the report that should display the records based on condition: It should give me the amt_total based on gift_type (Here, amt_total and gift_type are columns of the table).
This is the query I am using.
SELECT o110113.gift_batch_no,
o110113.gift_type,
(o110113.gift_date),
o110113.feed_doc_code,
SUM (o110113.amt_total)
FROM GIFT_CARD o110113
WHERE (o110113.gift_type IN
('RR', 'RB', 'CR', 'RM', 'RW', 'CW', 'RJ', 'RO', 'RK', 'CI')
)
GROUP BY o110113.gift_batch_no,
o110113.gift_type,
(o110113.gift_date),
o110113.feed_doc_code
ORDER BY o110113.gift_batch_no ASC, o110113.gift_type ASC
And the report I am trying to generate in SSRS 2008 should look like this.
Clikck this to see the Image of the Report that I am trying to develop
I am trying to use the SSRS expression
=Sum(Fields!SUM_O110113_AMT_TOTAL_.Value,"GIFT_TYPE")
It is throwing me the error saying:
Please click this to see an Error I am getting in SSRS
Kindly provide the Solution
This the report design I have developed
[click to see the Image of report]
Thanks
Arun
Here you need to do group by of your Tablix.
First you need to add Row group on gift_batch_no so that will dispaly based on gift batches.
Another row group your have to create on Gift type and in that second group type you need to set SUM of total amount it will work.
Let me know if you have any other query
That error has to do with the scope of your sum. without seeing the data sets and assuming it is not a nested aggregate operation based on the image. you are trying to reference the column name "GIFT_TYPE" when it should actually be the name of the record set, or the appropriate scope(data region/group).
here is how scope works from the provided link below
The value of scope must be a string constant andcannot be an
expression. For outer aggregates or aggregates that do not specify
other aggregates, scope must refer to the current scope or a
containing scope. For aggregates of aggregates, nested aggregates can
specify a child scope.
you will want to see this link for more information

Quickbooks DB Microsoft Query SQL string edit to render all data from a table

I have a SQL string that is from a report in Quickbooks that I am running through MS Query over an ODBC connection. I have successfully made a few minor edits to it. This report is a Profit and Loss statement showing general ledger accounts with dollar values for each class (identifier for those dollar amounts, basically a company code) where the accounts are the rows and the classes are the columns. I would like to pull ALL data for the class table, however I only have the SQL language screen. So my question is either:
What do I add to this SQL language to force the query to show all classes (categories) from the table regardless of whether there is account data (dollars) within them?
OR Is there some way to show the tables so that I can edit them in this report where I only have the SQL string? Then what kind of function would I need to use to set this parameter.
This is the SQL text:
sp_report ProfitAndLossByClass show Amount_Title, Text, Label, Amount parameters DateMacro = 'LastMonth', SummarizeColumnsBy = 'Class'
Any thoughts on how to either open the tables from this report or how I can add to my SQL string to allow the report to show all classes names from the table would be greatly appreciated.
Thanks,
Amy
This query is calling a Stored Procedure called sp_report and passing some parameters to it. I don't have QuickBooks, so there is no way I can tell you what sp_report does - maybe you can find out?
I'd check your Quickbook licence, though. Software suppliers often have clauses forbidding reverse engineering, which is what you're doing.

Few questions about Grails' createCriteria

I read about createCriteria, and kind of interested on how these works, and its usability in providing values for dropdown box.
So say, i have a table in the database, Resource table, where i have defined the table in the domain class called Resource.groovy. Resource table has a total of 10 columns, where 5 of it are
Material Id
Material description
Resource
Resource Id
Product Code
So using the createCriteria, and i can use just like a query to return the items that i want to
def resList = Resource.createCriteria().list {
and {
eq('resource', resourceInstance)
ne('materialId', '-')
}
}
Where in the above, i want to get the data that matches the resource = resourceInstance, and none of the materialId is equal to '-'.
I want to use the returned data from createCriteria above on my form, where i want to use some of the column on my select dropdown. Below is the code i used for my select dropdown.
<g:select id="resourceId" name="resourceId"
from="${resList}"
disabled="${actionName != 'show' ? false : true}" />
How do i make it so that in a dropdown, it only shows the values taken from column Product Code? I believe the list created using createCriteria returns all 10 columns based on the createCriteria's specification. But i only want to use the Product Column values on my dropdown.
How do i customize the data if in one of the select dropdown in my form, i wanted to show the values as "Resource Id - Resource Description"? The values are combination of more than 1 columns for one select dropdown but i don't know how to combine both in a single select dropdown.
I read that hql and GORM query are better ways of fetching data from table than using createCriteria. Is this true?
Thanks
First of all refer to the document for using select in Grails. To answer all questions:
Yes, the list to select from in the dropdown can be customized. In this case it should be something like from="${resList*.productCode}"
Yes, this can be customized as well with something like
from="${resList.collect { \"${it.resourceId} - ${it.resourceDesc}\" } }"
It depends. If there are associations involved in a domain then using Criteria will lead to eager fetches which might not be required. But with HQL one gets the flexibility of tailoring the query as needed. With latest version of Grails those boundries are minimized a lot. Usage of DetachedCriteria, where queries etc are recommended whereever possible. So it is kind of mixing and matching to the scenario under consideration.

SQL Query in DotNetNuke

I am using a Form & List module in DotNetNuke and would like to set up a query that filters the result set and returns the records submitted only by the user(without displaying everyone else)
I am not all familiar with the DNN tables and I think it would be something like below but I am not sure what goes into the WHERE clause...
I think it'd be
SELECT * FROM ---tablename--- WHERE ...
Thanks in advance.
EDIT:
Solution: insert a filter statement into the List Settings of the module:
[Created by_UDT_Original] = ‘[User:UserName]’
The FNL module uses it's own table structure, so querying against it will be fairly complex, and will vary based on the columns and types you created when configuring the module.
That being said, it is possible to have the module only display an individual user's data, that is either configured through the Module Settings, or within the FnL configuration itself.