Grouping using report query / Case statement in toplink
I have following tables
1. Student with columns id, gender
2. Subject_Score with columns id, student_id, subject_id, score
To get scores grouped by subject, I am doing
ExpressionBuilder subjScoreBuilder = new ExpressionBuilder();
ReportQuery query = new ReportQuery(SubjectScore.class);
query.addAverage("average-score",subjScoreBuilder.get("score"));
query.addGrouping(subjScoreBuilder.get("subjectId"));
Vector responses = (Vector) serverSession.executeQuery(query);
Float score = (Float) queryResult.get("average-score");
This works fine. It gives avg score per each subject
Now i want both in one query
A) avg score per subject
B) avg score per subject per gender
I want to achive this in one query
I am doing like:
ExpressionBuilder subjScoreBuilder =new ExpressionBuilder(SubjectScore.class);
ExpressionBuilder studentExpBuilder = new ExpressionBuilder(Student.class);
Expression expression = subjScoreBuilder.get("studentid").equal(studentExpBuilder.get("id")));
ReportQuery query = new ReportQuery(SubjectScore.class, expression);
query.addAverage("average-score", subjScoreBuilder.get("score"));
query.addGrouping( subjScoreBuilder.get("subjectId"));
query.addGrouping( studentExpBuilder.get("gender"));
This gives me avg scor per each subject per gender. i.e.
it applies grouping on both subjectId & gender.
This is fine.
But I also want avg score per each subject (group on subject only) in same query.
1. How can we achive it?
2. is there something like Case statement in toplink?
Thanks a lot for any help.
I believe in SQL you would need two queries to do this directly, so you will need to issue two queries.
You could select the Count and Avg, this would give you all the data need to compute the Avg yourself.
i.e.
(count(male) * avg(male) + count(female) * avg(female)) / (count(male) + count(female))
Similar Messages
-
SQL Query CASE statement using two fields
Hi,
I have two fields. One is called rescategory1, the other is called rescategory2.
I'm not sure if its a CASE statement I need or some sort of WHERE clause but I want to create a query that does the following or something similar:
CASE rescategory2
WHEN rescategory1 = '44' AND rescategory2 = '1' THEN 'Backup'
WHEN rescategory1 = '44' AND rescategory2 = '2' THEN 'Hardware'
END AS [Resolution Sub Category]
Basically, I'm looking to give rescategory2 a value based on that of rescategory1 and rescategory2 combined.
How do I write this?
Cheers
Pauldo you mean this?
rescategory2 = CASE
WHEN rescategory1 = '44' AND rescategory2 = '1' THEN 'Backup'
WHEN rescategory1 = '44' AND rescategory2 = '2' THEN 'Hardware'
END
ie assigning value for rescategory2
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
HI Friends ,
My Scenario in table data :
EmpId fromdate todate Billtype
2 01-09-2014 09-09-2014 B
3 01-09-2014 NULL B
2 10-09-2014 NULL P
4 01-09-2014 NULL U
5 01-09-2014 15-09-2014 B
5 16-09-2014 30-09-2014 U
OutPut :
EmpId Status
2 P
3 B
4 U
5 P
requirement : Need to develop this Sql Query ..Using the Case statement .
Please Help
thanks
RakeshWonderfull Patrick......
I executed the logic and returning the expected result . Thanks a lot.
But still need some more modification ......
suppose an employee E7 has the following entry :
E7 01-04-2014 20-06-2014 B
E7 21-06-2014 Null P
This means that the Employee E7 has Joined Project P1 in April First on a Billed Project and worked till July 20th and then again Moved to a Partial Billing Project P3 and from that July Till working in that Project
So as per logic , we are suppose to get the Status of the Employees in the previous Month.....logically means October...... so for the same E7 the Status would be "P"...because from July he is working on a Partial Billed Project
..... If suppose E7 worked on an Unbilled Project from July .... then for the month of October ......the Status for the same E7 would be "U"
Soooo ......if Employee E8 made 2 transitions within a month take example of last month October .
E7 01-04-2014 20-06-2014 B
E7 21-06-2014 Null P
E8 01-10-2014 20-10-2014 B
E8 21-10-2014 23-10-2014 P
E8 24-10-2014 Null/Empty U
so for this employee the Result for the November month will be "P" but if i check in month of december ...... for the same the satus should be "U" because from the last October 24th he is working on a "UnBilled Project"
Please Help ......!!!
I think what you need is just a filter like below
declare @FromDate datetime
SET @FromDate ='20141001'
SELECT EmpId,
CASE WHEN MAX(Billtype) = 'B' THEN 'B'
WHEN MIN(Billtype) = 'U' THEN 'U'
ELSE 'P'
END AS Status
FROM table
WHERE fromdate >= @FromDate
OR (fromdate < @Fromdate
AND (todate > @FromDate
OR todate IS NULL))
GROUP BY EmpId
Please Mark This As Answer if it solved your issue
Please Mark This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page -
Hi,
I have query with a case statement as follows:
SELECT * FROM table
WHERE
CASE WHEN :variable like 'A' THEN column END is null
WHEN :variable like 'B' THEN column END is not null;
This works fine when returning "column is null" but not when "column is not null".
Can I use a CASE statement like this?
Thanks
LucyMy data is too complicated to show, but depending on the value of the bind variable in the statement I want to return all the rows in a query where the data in a particular column is either null or not null.For example, looking at the EMP table, if my bind variable is whether I want to show the top manager or not, if set to 'Yes' I would like to return all rows of the EMP table where mgr is null (i.e. the one row where ename is 'KING'), if it were set to 'No' I would like to return all the rows where mgr is not null (i.e. all the other rows). The difference with my query is that the column contains strings, not numerics.
I've used a CASE statement before where I equate the column to a particular value and that works fine, but I'm not sure how they deal with nulls. I've also tried DECODE and didn't get anywhere with that.
Thanks
Lucy -
Use of decode/case statements
I am trying to use a decode or case statement to check for a particular field code of 'SIP' and if that is the value I only want half of the production figure used in the calculations for that field ('SIP').
The following code works well without the items commented out:
SELECT ALL
FINDER_WIS.PRODUCTION_HDR.END_TIME as prod_date,
'SCD' as district,
--decode(FINDER_WIS.FACILITY_FIELD_X.FIELD_CODE,'SIP',FINDER_WIS.PRODUCTION_DATA.VOLUME/2,FINDER_WIS.PRODUCTION_DATA) AS TEST_SIP,
/*case when FINDER_WIS.FACILITY_FIELD_X.FIELD_CODE = 'SIP'
then FINDER_WIS.PRODUCTION_DATA.VOLUME/2
else FINDER_WIS.PRODUCTION_DATA.VOLUME
end as fieldtest,*/
round(SUM(NVL(FINDER_WIS.PRODUCTION_DATA.VOLUME,0))) as total_oil,
ROUND(SUM(NVL(FINDER_WIS.PRODUCTION_DATA.VOLUME,0)) / TO_NUMBER(TO_CHAR(FINDER_WIS.PRODUCTION_HDR.END_TIME,'DD'))) AS BOPD
FROM FINDER_WIS.PRODUCTION_HDR,
FINDER_WIS.PRODUCTION_DATA,
FINDER_WIS.FACILITY,
FINDER_WIS.REPORTING_GROUP,
FINDER_WIS.REPORTING_GROUP_DETAIL,
FINDER_WIS.FACILITY_FIELD_X,
SELECT distinct FINDER_WIS.FACILITY.FACILITY_S
FROM FINDER_WIS.PRODUCTION_HDR,
FINDER_WIS.PRODUCTION_DATA,
FINDER_WIS.FACILITY,
FINDER_WIS.REPORTING_GROUP,
FINDER_WIS.REPORTING_GROUP_DETAIL
WHERE (FINDER_WIS.PRODUCTION_HDR.ACTIVITY_TYPE = 'ALLOCATED'
AND FINDER_WIS.PRODUCTION_HDR.TIME_PERIOD_TYPE = 'MONTH'
AND FINDER_WIS.PRODUCTION_HDR.STATE_TYPE = 'STANDARD'
AND FINDER_WIS.PRODUCTION_HDR.EXISTENCE_TYPE = 'ACTUAL'
AND FINDER_WIS.PRODUCTION_DATA.MATERIAL_TYPE='OIL'
and FINDER_WIS.REPORTING_GROUP.REPORTING_GROUP_TYPE = 'ASSET_TEAM'
AND FINDER_WIS.REPORTING_GROUP.REPORTING_GROUP_ID ='SCD'
and finder_wis.production_HDR.SOURCE = 'NEWWIS'
AND FINDER_WIS.PRODUCTION_HDR.START_TIME BETWEEN :startdate_var AND :enddate_var)
AND ((FINDER_WIS.PRODUCTION_DATA.PRODUCTION_HDR_S=FINDER_WIS.PRODUCTION_HDR.PRODUCTION_HDR_S)
and (FINDER_WIS.PRODUCTION_HDR.FACILITY_S = FINDER_WIS.FACILITY.FACILITY_S)
and (FINDER_WIS.PRODUCTION_HDR.START_TIME between FINDER_WIS.REPORTING_GROUP_DETAIL.start_time and nvl(FINDER_WIS.REPORTING_GROUP_DETAIL.end_time,'01-JAN-2010')
or FINDER_WIS.PRODUCTION_HDR.end_TIME between FINDER_WIS.REPORTING_GROUP_DETAIL.start_time and nvl(FINDER_WIS.REPORTING_GROUP_DETAIL.end_time,'01-JAN-2010'))
AND (FINDER_WIS.REPORTING_GROUP.REPORTING_GROUP_S = FINDER_WIS.REPORTING_GROUP_DETAIL.REPORTING_GROUP_S)
AND (FINDER_WIS.FACILITY.FACILITY_S = FINDER_WIS.REPORTING_GROUP_DETAIL.FACILITY_S)))T
WHERE (FINDER_WIS.PRODUCTION_HDR.ACTIVITY_TYPE = 'ALLOCATED'
AND FINDER_WIS.PRODUCTION_HDR.TIME_PERIOD_TYPE = 'MONTH'
AND FINDER_WIS.PRODUCTION_HDR.STATE_TYPE = 'STANDARD'
AND FINDER_WIS.PRODUCTION_HDR.EXISTENCE_TYPE = 'ACTUAL'
AND FINDER_WIS.PRODUCTION_DATA.MATERIAL_TYPE='OIL'
and FINDER_WIS.REPORTING_GROUP.REPORTING_GROUP_TYPE = 'ASSET_TEAM'
and finder_wis.production_HDR.SOURCE = 'NEWWIS'
AND FINDER_WIS.PRODUCTION_HDR.START_TIME BETWEEN :startdate_var AND :enddate_var)
AND ((FINDER_WIS.FACILITY.FACILITY_S = T.FACILITY_S)
AND (FINDER_WIS.PRODUCTION_DATA.PRODUCTION_HDR_S=FINDER_WIS.PRODUCTION_HDR.PRODUCTION_HDR_S)
AND FINDER_WIS.FACILITY_FIELD_X.UWI = FINDER_WIS.FACILITY.UWI
AND FINDER_WIS.FACILITY_FIELD_X.FIELD_CODE NOT IN ('MW','BRM','PLG','SIP')
and (FINDER_WIS.PRODUCTION_HDR.FACILITY_S = FINDER_WIS.FACILITY.FACILITY_S)
and (FINDER_WIS.PRODUCTION_HDR.START_TIME between FINDER_WIS.REPORTING_GROUP_DETAIL.start_time and nvl(FINDER_WIS.REPORTING_GROUP_DETAIL.end_time,'01-JAN-2010')
or FINDER_WIS.PRODUCTION_HDR.end_TIME between FINDER_WIS.REPORTING_GROUP_DETAIL.start_time and nvl(FINDER_WIS.REPORTING_GROUP_DETAIL.end_time,'01-JAN-2010'))
AND (FINDER_WIS.REPORTING_GROUP.REPORTING_GROUP_S = FINDER_WIS.REPORTING_GROUP_DETAIL.REPORTING_GROUP_S)
AND (FINDER_WIS.FACILITY.FACILITY_S = FINDER_WIS.REPORTING_GROUP_DETAIL.FACILITY_S))
GROUP BY FINDER_WIS.PRODUCTION_HDR.END_TIME
the results look like this but this is without the values for the 'SIP' field:
PROD_DATE DISTRICT TOTAL_OIL BOPD
31/10/2007 SCD 168009 5420
30/11/2007 SCD 167339 5578
31/12/2007 SCD 170277 5493
31/01/2008 SCD 173677 5602
29/02/2008 SCD 168498 5810
31/03/2008 SCD 172689 5571
30/04/2008 SCD 168180 5606
31/05/2008 SCD 165448 5337
30/06/2008 SCD 164631 5488
31/07/2008 SCD 170073 5486
31/08/2008 SCD 166520 5372
30/09/2008 SCD 160321 5344
When I try to add the decode or case statement, I get ORA-00979; not a Group By expression as the error.
Can anyone assist me with this please?
Thanks in advanceHi and welcome to the forum.
Simply put the field names you use in your DECODE also in your GROUP BY and it should work:
simple example:
MHO%xe> with t as (
2 select 1 col1, 1 col2 from dual union all
3 select 1 col1, 1 col2 from dual union all
4 select 2 col1, 2 col2 from dual union all
5 select 3 col1, 3 col2 from dual union all
6 select 4 col1, 4 col2 from dual
7 )
8 select col1
9 , decode(col1, 1, col2*100, col2)
10 , sum(col2)
11 from t
12 group by col1 -->> NO col2 here...
13 order by col1;
, decode(col1, 1, col2*100, col2)
FOUT in regel 9:
.ORA-00979: not a GROUP BY expression
Verstreken: 00:00:05.78
MHO%xe> with t as (
2 select 1 col1, 1 col2 from dual union all
3 select 1 col1, 1 col2 from dual union all
4 select 2 col1, 2 col2 from dual union all
5 select 3 col1, 3 col2 from dual union all
6 select 4 col1, 4 col2 from dual
7 )
8 select col1
9 , decode(col1, 1, col2*100, col2)
10 , sum(col2)
11 from t
12 group by col1, col2
13 order by col1;
COL1 DECODE(COL1,1,COL2*100,COL2) SUM(COL2)
1 100 2
2 2 2
3 3 3
4 4 4 -
ReportViewer using SQL Query error states: Incorrect syntax near ','.
Hello Community
Using Visual Studio 2008 and SQL Server 2008 I created a Windows Application
that uses SQL Server Reporting Services. The application uses ReportViewer and
calls a method written using SQL query.
1-First I created the form.
2-Next I dragged the ReportViewer (Toolbox) and Table (from DataSource) onto the form.
The problem is that when it reaches the last line of the SQL query (ie, da.Fill(ds, "TableOne");)
the code fails stating the error message:
"Incorrect syntax near ','."
The following is the code behind the form containing the query:
private void ReportPgm1_Load(object sender, EventArgs e)
// TODO: This line of code loads data into the 'ReportDBDataSet.TableOne' table. You can move, or remove it, as needed.
this.TableOneTableAdapter.Fill(this.ReportDBDataSet.TableOne);
reportViewer1.ProcessingMode = ProcessingMode.Local;
LocalReport ReportOneLocalReport = reportViewer1.LocalReport;
DataSet ds = new DataSet("ReportDBDataSet.TableOne");
pgmReportOne(FromDate, ToDate, ds);
ReportDataSource ds = new ReportDataSource("ReportDBDataSet.TableOne");
ds.Value = dataset.Tables["TableOne"];
ReportOneLocalReport.DataSources.Clear();
ReportOneLocalReport.DataSources.Add(ds);
this.reportViewer1.RefreshReport();
private void pgmReportOne(DateTime FromDate, DateTime ToDate, DataSet ds)
SqlConnection connection = new SqlConnection("Data Source=ReportDBServer;Initial Catalog=ReportDB;Uid=sa;pwd=Password");
string sqlReportOne = "Select ([InDate], [FirstName], [LastName], [AGe]" +
"from TableOne";
SqlCommand command = new SqlCommand(sqlReportONe, connection);
command.Parameters.Add(new SqlParameter("paramFDate", FromDate));
command.Parameters.Add(new SqlParameter("paramTDate", ToDate));
SqlDataAdapter da = new SqlDataAdapter(command);
da.Fill(ds, "TableOne");
Why does the last line throw an error?
Thank you
Shabeaut--NOTE: The statement below cannot be run on SQL Server 2012
--If you have an earlier version and can set the compatibility
--level to 80, it can be run.
SELECT sso.SpecialOfferID, Description, DiscountPct, ProductID
FROM Sales.SpecialOffer sso,
Sales.SpecialOfferProduct ssop
WHERE sso.SpecialOfferID *= ssop.SpecialOfferID
AND sso.SpecialOfferID != 1
Hi Scott
The *= is old syntax and not compatible with SQL Server 2012 (as stated in the comments).
You could do something like this instead
SELECT sso.SpecialOfferID
,Description
,DiscountPct
,ProductID
FROM Sales.SpecialOffer sso
left outer join Sales.SpecialOfferProduct ssop on sso.SpecialOfferID = ssop.SpecialOfferID
WHERE sso.SpecialOfferID != 1 -
How to use REGEXP for case statement
Hello everyone, I'm very new here and am struggling with a using REGEXP in a case statement, OK I am using the REGEXP to find all strings that match a specific format for a particular brand of product, for example serial numbers, and I need to be able to say something like [case when(xx.brandid) = '123' then if xx.serialnumber REGEXP_LIKE(xx.serialnumber,'[A-za-z][A-za-z][A-za-z]\d{5,}[A-za-z]$') then 'TRUE' else 'FALSE' end "TRUE/FALSE".]
Help would be greatly appreciated with this as I feel like I'm going backwards trying to figure this out
Thanks in advance for any assistance.Like this?
case
when xx.brandid = '123' and
regexp_like(xx.serialnumber,'[A-za-z][A-za-z][A-za-z]\d{5,}[A-za-z]$') then
'TRUE'
else
'FALSE'
end -
Master Detail Report using Report Query
I am using APEX Report Query component to try and create a mater/detail report with BI plug-in. The Report Queries doesn't give you mush flexibility as each query is independent of the other. I'm trying to see if I need to create 2 queries or 1 AND what option would let me create a master detail report like so in BI Desktop:
Employee: Bob ID:100 Dept: HR
Jobs
Job 1
Job 2
Job 3
Employee: Tom ID:200 Dept: ACCt
Jobs
Job 1
Job 2
Job 3
Option1.
I could combine the Employee Job info with the Employee info, but that would report the Employee info for every Employee Job. I didn't think that was good.
<Rowset1_Row>
<EMPID>
<NAME>
<DEPT>
<JOB>
</Rowset1_Row>
Option 2.
I could create 2 queries. The 1st getting all of the Empoyee info. The 2nd getting all of the Employee jobs.
<Rowset1_Row>
<EMPID>
<NAME>
<DEPT>
<JOB>
</Rowset1_Row>
<Rowset2_Row>
<EMPID>
<JOB>
</Rowset2_Row>
<Rowset2_Row>
<EMPID>
<JOB>
</Rowset2_Row>
Any advice?
Edited by: bobmagan on Jun 1, 2009 5:29 AMCan you check for the settings please.
Thanks and Regards
Riyas -
Building in carriage returns using Report Query
I am using Report Querys and Report Layouts. I am trying to build in some carriage returns that will be recognized in my rtf template. I tried using 'chr(10)', br's etc, but it doesn't work. It prints the characters instead of doing the carriage return. Am Imissing something?
<COMMENTS01>MATHEMATICS (FROST, J): Seldom hands homework in on time Seldom comes to class on time. Retention Possible William works well on patterns chr(10)MEDIA (HATTER, M): Does well on tests Shows a desire to learn chr(10)READING (ANDERSON, L): Does well on tests Does well on quizes These are the notes for Fluency These are the notes for comprehension. chr(10)SCIENCE (BLASK, M): Elementary Code 1 Has trouble with Jupiter. chr(10)</COMMENTS01>Bob,
The string literal 'chr(10)' will not help you much.
select 'mystring'||'chr(10)'||'mystring' from dual; -- returns 'mystringchr(10)mystring'
select 'mystring'|| chr(10) ||'mystring' from dual; -- returns 'mystring
mystring'Cheers,
Tyson Jouglet -
Pivoting using Model Clause Vs pivoting using Aggregate Fun(Case) statement
Hi,
I just wanted to know which option is better for pivoting the data if the data is like:
Grp1 Grp2 Day_week Sales
1 1 Sun 200
1 1 Mon 100
1 2 Sun 1000
and so on...
The output should be:
Grp1 Grp2 Sun Mon ......
1 1 200 100.....
1 2 1000 NULL....
I have tested the same using sum(decode...) method and also model clause:
select grp1, grp2, sum(decode(day_week,'SUN',sales)) SUNDAY , sum(decode(day_week,'MON',sales)) MONDAY from pivot
group by grp1, grp2
order by grp1, grp2
select grp1, grp2, sun , mon, tue, wed, thr, fri, sat
from pivot
model -- UNIQUE SINGLE REFERENCE
return updated rows
partition by (grp1, grp2)
dimension by ( day_week)
measures( result, 0 mon, 0 tue, 0 wed, 0 thr,0 fri, 0 sat, 0 sun)
RULES upsert
mon[0]= sales['MON'],
tue[0]= sales['TUE'],
wed[0]= sales['WED'],
thr[0]= sales['THR'],
fri[0]= sales['FRI'],
sat[0]= sales['SAT'],
sun[0]= sales['SUN']
) order by grp1, grp2
There are 4K records in the table. The first query is taking app (.125 seconds) and the second query (.230 seconds).
Pls tell how the model clause can give better performance and I want to use it for pivoting in all my APIs.
Regards
Rajiv> I read somewhere while searching on net.
And now you can't find it anymore? I wouldn't believe anything you read somewhere while searching on net, unless it has some kind of proof attached.
> You pls tell is it so or it depends upon volume of data.
Also i tested on some data and reults were better in
case of using normal startegy rather than model.(case
provided above).
So you have tested it yourself already. The model clause is great in a few cases (string aggregation, calculating values based on calculated values), but this doesn't seem to be one of them. On 11g you might want to consider the PIVOT operator.
Regards,
Rob. -
Using ISNULL in CASE statement
Hi,
I need to write a query that will gimme the resultsets based on a data comparison with some values, Those values that are null in the result set needs to be replaced with an empty string which can be obtained using ISNULL function. My question here is,
how to incorporate this in a SELECT statement that has CASE expression. I coded some thing like this but the result set for the column is returning zero instead of an empty string. The data type for this column ABC is varchar(10)
SELECT top 20
ABC
,CASE
WHEN ABC IN (8,9,10,13,14,15,16,17,19,20,21) THEN 10
WHEN ABC IN (31,32,33) THEN 30
WHEN ABC IN (53,52,54,55) THEN 50
WHEN ABC IN (61,62) THEN 60
WHEN (ABC IS NULL AND DEF IS NOT NULL) THEN 99
else ISNULL(ABC,'')
END
FROM XYZ
Any help is appreciated
Many Thanks,
BhanuSELECT top 20
ABC
,CASE
WHEN ABC IN (8,9,10,13,14,15,16,17,19,20,21) THEN '10'
WHEN ABC IN (31,32,33) THEN '30'
WHEN ABC IN (53,52,54,55) THEN '50'
WHEN ABC IN (61,62) THEN '60'
WHEN (ABC IS NULL AND DEF IS NOT NULL) THEN '99'
else ISNULL(ABC,'')
END
FROM XYZ -
How do I use switch and case statements to fill more than one other field?
Hi all,
I'm new to the community.
I'm trying to make an existing form more user friendly for my coworkers. I want to use a switch and case approach in a drop-down list field so that the selection fills two seperate other fields with different info related to the selection.
I can already do this with one field, but if I add a second target field under an existing case the text doesn't appear there when I make the selection from the dropdown.
Basically, I'm asking if I can do this:
switch
(sNewSel){
case "1": // Selection 1 Row2.Field1
= "text for field 1";
Row1.Field2 = "text for field 2";
break;
etc.
It works if the "row1.field2" option isn't there, but not when it is present.
Any takers?I'm not sure if I will be able to send you the form. There may be too much to redact.
Would this last bit of code in the cell affect anything?
if
(bEnableTextField)
{Row2.Field1.access
= "open"; // enable field
Row2.Field1.caption.font.fill.color.value= "0,0,0"; // set caption to black
That is, do I also need to repeat the same thing for the second target cell (Row1.Field2)?
What would be possible hang ups that would prevent it from working correctly?
Dave
By the way, I'm not sure if my other attachment posted. I am trying again. -
Special Characters not showing using Report Query
I run my BI pub reports from APEX page using apex_util.download_print_document (see below).
It looks like it is stripping out the '+' from the report when displaying. It shows correctly inthe XML file.
I even tried encoding with SELECT max(replace(I1.alpha_grade,'+','%2B')) . This prints the '%2B' instead of the '+'.
Any ideas?
apex_util.download_print_document(
p_file_name => l_form_description,
p_content_disposition => 'attachment',
p_application_id => v('APP_ID'),
p_report_query_name => nvl(l_report_query_name,l_form),
p_report_layout => l_layout,
p_report_layout_type => 'rtf',
p_document_format => v('P507_OUTPUT_FORMAT'));Glad it worked out for you Bob; here is the site I used for HTML to Character conversion chart.
[url http://www.ascii.cl/htmlcodes.htm]HTML Codes - Characters and symbols
Jeff -
Using Decode Or Case Statement / Any Method
Dear All,
In my table Fields are
EmpId
TranYear
TranMonth
ApprovedBy
ApprovedYear
ApprovedMonth
My Input parameters are
1. TranYear
2. TranMonth
3. Tag1
4. Tag2
My requirement is
Tag1 Input are 0,1,2
Tag2 Inputs are 0,1,2
If Tag1 is 0 then checking TranYear/TranMonth And
Tag2 Is 0 Then ApprovedBy Is Not Null only
Tag2 Is 1 Then ApprovedBy Is Null only
Tag2 Is 2 Then both(Approved/unApproved)
If Tag1 is 1 then checking ApprovedYear/ApprovedMonth And Tag2 Passing 0 Default
If Tag1 is 2 then checking TranYear/TranMonth Or ApprovedYear/ApprovedMonth And
Tag2 Is 0 Then ApprovedBy Is Not Null only
Tag2 Is 1 Then ApprovedBy Is Null only
Tag2 Is 2 Then both(Approved/unApproved)
Based upon the input details select detailsdont quite understand your table structure requirement but it sounds like you want a conditional join.
looks like you are always joining on the tran year tran month but according to your 2 flags decides the rest of the join
I started something here where I am joining on the tran year / tran month then setting an indicator based on your flags
then just select the rows where this indicator is true.
anyway you can modify it to your needs
WITH t AS (SELECT 1 EmpId,
EXTRACT (YEAR FROM TO_DATE ('2010', 'YYYY')) TranYear,
EXTRACT (MONTH FROM TO_DATE ('Oct', 'Mon')) TranMon,
10 approved_by,
EXTRACT (YEAR FROM TO_DATE ('2010', 'YYYY')) ApprovedYear,
EXTRACT (MONTH FROM TO_DATE ('Nov', 'Mon')) ApprovedMon
FROM DUAL
UNION ALL
SELECT 2,
EXTRACT (YEAR FROM TO_DATE ('2009', 'YYYY')),
EXTRACT (MONTH FROM TO_DATE ('Jul', 'Mon')),
11,
EXTRACT (YEAR FROM TO_DATE ('2009', 'YYYY')),
EXTRACT (MONTH FROM TO_DATE ('Dec', 'Mon'))
FROM DUAL),
input AS (SELECT EXTRACT (YEAR FROM TO_DATE ('2010', 'YYYY')) TranYear,
EXTRACT (MONTH FROM TO_DATE ('Oct', 'Mon')) TranMon,
0 tag1,
0 tag2
FROM DUAL)
SELECT *
FROM (SELECT t.*,
tag1,
tag2,
CASE tag1 || '.' || tag2
WHEN '0.0'
THEN
CASE WHEN Approved_By IS NOT NULL THEN 1 ELSE 0 END -- if they are both 0 join on Tran Year, Tran Month and Approved by not null
WHEN '0.1'
THEN
CASE WHEN Approved_By IS NULL THEN 1 ELSE 0 END -- if they are 0,1 then Tran Year, Tran Month and Approved by is null
WHEN '0.2'
THEN
0 -- CASE --Then both(Approved/unApproved) i Don't know what this means
/* WHEN '1.0' then whatever
when '1.1' then whatever
when '1.2 then whatever
ELSE
0
END
ind
FROM t, input
WHERE t.TranYear = input.TranYear AND t.TranMon = input.TranMon)
WHERE ind = 1 -
Use of writeChanges() / conformResultsInUnitOfWork in report query
I have a usecase where i am saving data in different tables in same transaction
I want to use ReportQuery so as to use functions likeaddAverage.
ReportQuery query = new ReportQuery(res);
query.setReferenceClass(Subject.class);
query.addAverage("average-score", res.get("score"));
But since data is still not commited, I wanted to use conformResultsInUnitOfWork.
1.But I assume conformResultsInUnitOfWork can't be used with ReportQuery.
Am I correct?
2. According to toplink docs, we can use writeChanges() method on uow.
But after you call the unit of work writeChanges method , we can'r egister objects or execute object-level queries.
But after executing report query, I need to register obj /read objects to perform other use case operation.
So how can we use Report query to perform query on uncommited changes & still be able to other UOW operations or read object queries
Thanks for your help.Hi Jayesh,
Please have a look at the below attachment.
[http://help.sap.com/saphelp_470/helpdata/en/5b/d22e3843c611d182b30000e829fbfe/content.htm]
Warm regards,
Murukan Arunachalam
Maybe you are looking for
-
PO Line Item wise gross value for combination of WBS and Material Group
Hello, Our requirement is to get report for PO Line Item wise gross value for combination of WBS and Material Group. Standard report ME2J gives net price but not gross value for Material Line items. Please let me know if any standard report( or ME2J)
-
How to restrict two items in one sales order.
Hi , My client wants that in one sales order two material say Mat -A and Mat-B should not go together. It should go in seprate sales order due to chemical nature both product should go seprately. Kindly advise me how to configure it. Give full detai
-
Hello Everyone, I need some help tracking down a problem which causes a slow down in the boot up of my system. I believe the problem is linked with Nouveau due to repeated entries in the Xorg.0.log. Using the proprietary Nvidia drivers, I don't get t
-
Hi, As stated, I updated my iPhone 4s to version 6.1 and can't make any calls now. Restoring it to a prior state doesn't rollback the iOS version, so I'm stuck with a brick now. Does anyone have a solution to this? Thank you.
-
I canot delete pics from my photos on ipad. During synching process to my mac the pictures started to suddenly be downloaded back to the ipad. I now have 900 pics in photos and the same in photo stream on the ipad. There is no trash can, only an "