SUM(CASE WHEN statement is not returning proper result.
Hi Folks,
I'm an end-user on OBIEE 11g creating a custom analysis. I'm trying to SUM a particular case statement: SUM(CASE WHEN "MyMeasureColumn.Here" LIKE '%~25~%' OR "MyMeasureColumn.Here" LIKE '%~26~%' OR "MyMeasureColumn.Here" LIKE '%~27~%' OR "MyMeasureColumn.Here" LIKE '%~28~%' THEN 1 ELSE 0 END)
The result should be about 6,700 however I am getting only 1,900. Any ideas?
>
Ive done a manual validation of the statement (in excel) and know its near 6700. I think it has something to do with the type of data it is?
>
Well there are only three possibilities that I can think of.
1. The data in Excel is different than the data in Oracle
2. The 'manual validation' is different than what the query that you are using does
3. Both #1 and #2
You are the only one with access to the data.
You are the only one that has any idea what your 'manual validation' was.
If necessary you will need to use the brute force 'divide and conquer' method.
Use a small amount of data and compare your 'manual validation to your query results. If they are not the same figure out why.
If they are the same then repeat the process with another set of the data.
Similar Messages
-
Avoid JDBC sender error: Execute statement did not return a result set
Hi!
My JDBC sender adapter towards MS SQL server works fine, with an Execute statement calling a stored procedure that returns the source data needed. The stored procedure itself updates the status of database table records, so that only the unread records are returned each time the stored procedure is called.
However, the communication channel monitoring sets a red flag for the JDBC sender adapter, when there are no values to fetch from the database table (using the stored procedure). Message says: "Database-level error reported by JDBC driver while executing statement 'EXECUTE FetchMessage 1, 9000'. The JDBC driver returned the following error message: 'com.microsoft.sqlserver.jdbc.SQLServerException: The statement did not return a result set.'. For details, contact your database server vendor."
This is not an error situation, as I do not expect there to be any values to fetch from the database at all times.
I do not see how to change the stored procedure to avoid this error.
Is there a parameter to be set on the JDBC adapter that I can use, so the red flag is avoided?
Thanks for any input!
Regards,
Oeystein EmhjellenHi Oeystein Emhjellen.
The problem is Store Procedure that has to generate always a ResultSet (or cursor). If it doesn't have a output, you have to generate an Empty ResultSet.
Like a SELECT Statement:
If there are data, SELECT get an output result but if it get nothing the SELECT Statement get a empty ResultSet.
Ask to your database team.
I hope it helps you.
Bruno. -
The statement did not return a result set in ireport
Hi,
I am Building a Report in iReport(Jasper Reports). I called a stored procedure from iReport by passing a parameter in Query Editor. I am getting an exception saying "The statement did not return a result set". When
i use Temp Tables in stored procedure i am getting the exception.
If there is no temptable in Stored procedure there wont be any exception.
This is my Stored procedure
Create PROCEDURE [XUSP_REPORT_SOPRINT] @BNUM VARCHAR(20) AS
BEGIN
DECLARE @FQTY BIGINT
DECLARE @ITNAME VARCHAR(100)
DECLARE @COUNT INT=0
DECLARE @COUNT1 INT=0
CREATE TABLE #BILL_PRINT(
[BNUM] [varchar](20) NOT NULL,
[CNAME] [varchar](30) NOT NULL,
[CNUM] [int] NOT NULL,
[ITNAME] [varchar](100) NOT NULL,
[ITEM#] [int] NOT NULL,
[QTY] [int] NOT NULL DEFAULT 0,
[UNIT] [varchar](5) NOT NULL,
[PRICE] [float] NOT NULL DEFAULT 0,
[BASIC] [float] NOT NULL DEFAULT 0,
[DISCOUNT] [float] NOT NULL DEFAULT 0,
[FRQTY] [int] NOT NULL DEFAULT 0,
[BADDR] [varchar](300) NULL,
[CADDR] [varchar](300) NOT NULL,
[BDATE] [datetime] NULL DEFAULT (sysdatetime()),
[BILLBY] [varchar](50) NOT NULL,
[ROUTE] [varchar](200) NULL,
[AMT] [float] NOT NULL DEFAULT 0,
[VAT] [float] NOT NULL DEFAULT 0,
[VAT AMT] [float] NOT NULL DEFAULT 0,
[AMT_AF_DISC] [float] NOT NULL DEFAULT 0,
[AMT_AF_VAT] [float] NOT NULL DEFAULT 0,
[TOT_DISC] [float] NOT NULL DEFAULT 0,
[ROUND_OFF] [float] NOT NULL DEFAULT 0,
[TOT_VAT] [float] NOT NULL DEFAULT 0,
[AMT_UNDER_VAT] [float] NOT NULL DEFAULT 0,
[NETT] [float] NOT NULL DEFAULT 0,
[TOS] [varchar](30) NULL DEFAULT 0,
[CDISC] [float] NOT NULL DEFAULT 0,
[SDISC] [float] NOT NULL DEFAULT 0
insert into #BILL_PRINT SELECT [BNUM]
,[CNAME]
,[CNUM]
,[ITNAME]
,[ITEM#]
,[QTY]
,[UNIT]
,[PRICE]
,[BASIC]
,[DISCOUNT]
,[FRQTY]
,[BADDR]
,[CADDR]
,[BDATE]
,[BILLBY]
,[ROUTE]
,[AMT]
,[VAT]
,[VAT AMT]
,[AMT_AF_DISC]
,[AMT_AF_VAT]
,[TOT_DISC]
,[ROUND_OFF]
,[TOT_VAT]
,[AMT_UNDER_VAT]
,[NETT]
,[TOS]
,[CDISC]
,[SDISC]
FROM [SALES_DETAILS] WHERE BNUM=@BNUM
CREATE TABLE #ITNAME_0
ITEM VARCHAR(100) NOT NULL,
FREE BIGINT NOT NULL
INSERT INTO #ITNAME_0 SELECT ITNAME,FRQTY FROM SALES_DETAILS WHERE FRQTY<>0 AND BNUM=@BNUM
--SELECT * FROM #ITNAME_0
SET @COUNT=(SELECT COUNT(*) FROM #ITNAME_0)
WHILE @COUNT!=0
BEGIN
SET @FQTY=(SELECT TOP(1) FREE FROM #ITNAME_0)
SET @ITNAME=(SELECT TOP(1) ITEM FROM #ITNAME_0)
SET @COUNT1=(SELECT COUNT(*) FROM #BILL_PRINT WHERE ITNAME=@ITNAME AND BNUM=@BNUM)
IF @COUNT1=2
BEGIN
UPDATE #BILL_PRINT
SET FRQTY+=@FQTY
WHERE ITNAME=@ITNAME AND QTY<>0
DELETE FROM #ITNAME_0 WHERE ITEM=@ITNAME AND FREE=@FQTY
DELETE FROM #BILL_PRINT WHERE ITNAME=@ITNAME AND QTY=0
END
SET @COUNT=@COUNT-1
END
--SELECT *FROM sales_details
SELECT *FROM #BILL_PRINT where bnum=@bnum
DROP TABLE #BILL_PRINT
DROP TABLE #ITNAME_0
END
Please help me out in this.
Thanks,
Shreyas MThis is a forum for Reporting Services (SSRS). If you're using Jasper reports then you should be posting in relevenat forums. I'm not sure there would be enough people with Jasper report experience here to help you out!
Anyways in SSRS when we use Temp tables in procedure it will throw exception in editor but when you save and run it will still work fine. Did you try saving it and executing report? Did the error still persisted?
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page -
JDBC not returning proper result
Hi
I am trying to extract some information from data base
and i am writting this query
java.sql.Statement s = dbCon.createStatement();
ResultSet r = null;
r = s.executeQuery("select * from emp where description="+courseName);
If the course have value
description="Fundamental of Science"
then it says "syntax error at or near of"
and if description="SAD"
then it said error "column "sad" does not exist
means its converting to lower case
where, i am accepting the string value for description from a JSP page,
i am returning the value in the bean by using get set method
and i am writing the query in bean
i have checked that its returning the value properly for the parameter "description"
Please helpThe SQL you need is
select * from some_table where some_column = 'abc def'Note the single quotes around the string literal "abc def". If you don't have the quotes, then abc is taken as a column name or alias, and the def part is just wrong syntax at that point.
The way to do this is with PreparedStatement.
PreparedStatement ps = conn.prepareStatement("select * from some_table where some_column = ?");
String colValue = "abc def";
ps.setString(1, colValue);
ResultSet rs = ps.executeQuery();The driver puts the quotes in for you, and handles any escaping that's necessary.
Edited by: jverd on Dec 1, 2010 3:51 PM -
Summary: API: JR_CHECK_REF.CHECK_FOL_REFS does not return proper results
Description:
For User Extensions, the API is returning unexpected/unexplained results for Association types identified as not in the repository.
Scenario 1) EL_TYPE and REF_TYPE return properties that are not aligned with either the EL_IRID/EL_IVID, EL_PAR_IVID, or REF_PAR_IRID.
However, REF_IRID (pointing to the missing object) is correct.
Scenario 2) EL_TYPE and REF_TYPE return properties that are not aligned with either the EL_IRID/EL_IVID, EL_PAR_IVID, or REF_PAR_IRID.
However, all the objects are present in the repository.
Any idea?
~Shampa M.You might get a better response if you ask this in the Designer Forun.
-
Case when statement not working
hi there, I am trying to work out how to get my case statement to work.
I have got the following code.
select pthproto.pthdbo.cnarole.tpkcnarole, pthproto.pthdbo.cnaidta.formataddr as formataddr, cnaidta.dateeffect as maxdate, isnull(cast (pthproto.pthdbo.cnaaddr.prefix1key as varchar (50)),'') + ' ' + isnull(cast (pthproto.pthdbo.cnaaddr.prefix2key
as varchar (50)),'')+ ' ' + isnull(cast (pthproto.pthdbo.cnaaddr.prefix3key as varchar (50)),'') + ' ' + isnull (cast (pthproto.pthdbo.cnaaddr.houseidkey as varchar (100)),'') + ' ' + isnull (cast (pthproto.pthdbo.cnaaddr.component1
as varchar (100)),'') + ' ' + isnull (cast (pthproto.pthdbo.cnaaddr.component2 as varchar (100)),'') + ' ' + isnull (cast (pthproto.pthdbo.cnaaddr.component3 as varchar (100)),'') + ' ' + isnull (cast (pthproto.pthdbo.cnaaddr.component4
as varchar (100)),'') + ' ' + isnull (cast (pthproto.pthdbo.cnaaddr.component5 as varchar (100)),'') as mailaddress, row_number() over(partition by pthproto.pthdbo.cnarole.tpkcnarole order by cnaidta.dateeffect desc) as rn into #address from pthproto.pthdbo.cnarole
inner join pthproto.pthdbo.cnaidty on cnarole.tfkcnaidty =cnaidty.tpkcnaidty inner join pthproto.pthdbo.cnaidta on cnaidty.tpkcnaidty = cnaidta.tfkcnaidty inner join pthproto.pthdbo.cnaaddr on cnaidta.tfkcnaaddr = cnaaddr.tpkcnaaddr order by cnaidta.dateeffect
select *, case when mailaddress is not null then mailaddress else formataddr end as test from #address where tpkcnarole = '18306695'
The case when statement is struggling with how i have created the column mailaddress. As it does seem to understand when it is null. In the example I have got there is no value in any of the columns to create
the mailaddress. Hence why I am referencing it from elsewhere. Due to having a way on the system where it picks up data from 2 different places. The mailaddress is always correct if there is one, hence why
trying to reference that one first. So how do i change this case when statement to work ?It's ok I have fixed my own problem
when
(mailaddress
is
null
or mailaddress
=
then formataddr
else mailaddress
end
as test
case -
Case When Statement and ORA:01722 Invalid number error
Hi folks, I have posted this under another heading as well under E-business suite so apologies if some you have already seen it but I would really appreciate some help on this one. Any suggestions are most welcome.
We are trying to put together a calculation that returns the number of days absent an individual has had in a given time period. We need to cater for those absences that started before the period and are closed during it, absence that start during the period and end after it, and those that open and close within it.
The period is always a rolling 6 months from sysdate.
This is the calc we have come up with so far which works for some people but we get the invalid number error if the absence includes a half day - so 0.5, 1.5,etc.
This is probably over complicated but we are not techie at all so are learning as we go!
We are using the HRMS - Administration - Oracle Human Resources (Core) business area in 10G and the Absence Attendance and Person folders.
SUM(TO_NUMBER(NVL(( CASE WHEN Absence Attendance.Actual Start Date < TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') THEN ( CASE WHEN Absence Attendance."Actual End Date" > SYSDATE THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) IS NULL THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) END ) END ) ELSE ( CASE WHEN ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) IS NULL THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( Absence Attendance.Duration Days ) END ) END ) END ) END ) END ),( DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") )),'999999990D00'))Hi,
It could be that this is because you are using SYSDATE which contains the time as a fraction rather than TRUNC(SYSDATE) which just contains the current time. It could be that your working_dates_between raises this error.
However, your formula is far more complicated than it needs to be.
Firstly, you want to look at the date window ADD_MONTHS(TRUNC(SYSDATE), -6) to TRUNC(SYSDATE). Then you want to look at the portion of the absence that falls in the date window. This is GREATEST(Absence Attendance.Actual Start Date, ADD_MONTHS(TRUNC(SYSDATE), -6)) to LEAST(NVL(Absence Attendance."Actual End Date",TRUNC(SYSDATE)), TRUNC(SYSDATE)). You may need to add 1 to the absence end date because this is the last day of their absence rather than the date they return. It depends how you calculate the days between the start and end
date of the absence. You can create calculations for the start and end date of the absences within the 6 months time window. Create calculation AbsenceStart as
GREATEST(Absence Attendance.Actual Start Date, ADD_MONTHS(TRUNC(SYSDATE), -6))
and AbsenceEnd as
LEAST(NVL(Absence Attendance."Actual End Date",TRUNC(SYSDATE)), TRUNC(SYSDATE))
Then you need to only pick up absence that a part of the absence in your 6 month date window. You can use a condition in the workbook or a condition in a case statement to do this. You then need to calculate the difference between these dates and SUM all the values.
SUM(CASE WHEN AbsenceEnd >= AbsenceStart THEN WORKING_DAYS_BETWEEN(AbsenceStart, AbsenceEnd) END)
That's it. Not so complicated after all.
Rod West -
Case When Statement and ORA:1722 Invalid number error
Sorry I posted this in the wrong forum - I have the answer now
Cheers
HELP!!!
We are trying to put together a calculation that returns the number of days absent an individual has had in a given time period. We need to cater for those absences that started before the period and are closed during it, absence that start during the period and end after it, and those that open and close within it.
The period is always a rolling 6 months from sysdate.
This is the calc we have come up with so far which works for some people but we get the invalid number error if the absence includes a half day - so 0.5, 1.5,etc.
This is probably over complicated but we are not Techie at all so are learning as we go! We are using the HRMS - Administration - Oracle Human Resources (Core) business area in 10G and the Absence Attendance and Person folders.
SUM(TO_NUMBER(NVL(( CASE WHEN Absence Attendance.Actual Start Date < TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') THEN ( CASE WHEN Absence Attendance."Actual End Date" > SYSDATE THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) IS NULL THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) END ) END ) ELSE ( CASE WHEN ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) IS NULL THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( Absence Attendance.Duration Days ) END ) END ) END ) END ) END ),( DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") )),'999999990D00'))
Edited by: CPearce on Sep 25, 2008 8:03 AMHi,
It could be that this is because you are using SYSDATE which contains the time as a fraction rather than TRUNC(SYSDATE) which just contains the current time. It could be that your working_dates_between raises this error.
However, your formula is far more complicated than it needs to be.
Firstly, you want to look at the date window ADD_MONTHS(TRUNC(SYSDATE), -6) to TRUNC(SYSDATE). Then you want to look at the portion of the absence that falls in the date window. This is GREATEST(Absence Attendance.Actual Start Date, ADD_MONTHS(TRUNC(SYSDATE), -6)) to LEAST(NVL(Absence Attendance."Actual End Date",TRUNC(SYSDATE)), TRUNC(SYSDATE)). You may need to add 1 to the absence end date because this is the last day of their absence rather than the date they return. It depends how you calculate the days between the start and end
date of the absence. You can create calculations for the start and end date of the absences within the 6 months time window. Create calculation AbsenceStart as
GREATEST(Absence Attendance.Actual Start Date, ADD_MONTHS(TRUNC(SYSDATE), -6))
and AbsenceEnd as
LEAST(NVL(Absence Attendance."Actual End Date",TRUNC(SYSDATE)), TRUNC(SYSDATE))
Then you need to only pick up absence that a part of the absence in your 6 month date window. You can use a condition in the workbook or a condition in a case statement to do this. You then need to calculate the difference between these dates and SUM all the values.
SUM(CASE WHEN AbsenceEnd >= AbsenceStart THEN WORKING_DAYS_BETWEEN(AbsenceStart, AbsenceEnd) END)
That's it. Not so complicated after all.
Rod West -
Hello everybody,
I have the following SQL statement. To verify that p01.euro IS NOT NULL, I think I should add a "CASE WHEN" statement into the code, the problem is, that I don't know how to this here... The "CASE WHEN" statement should be for the subselect - statement I've marked in red color...
Perhaps you have an idea... Thanks
select
(select apex_item.select_list_from_query (5,name,'select name from cn_pl_projektidee order by idee_id asc', 'style="width:130px"', NULL) name
from cn_pl_projektidee s01 where s01.idee_id = t1.idee_id) idee,
(select htmldb_item.text(6,sum(stunden))stunden_ilp from cn_pl_std_peplanung t02
where abt_id = '1'
and t02.pe_id = t1.pe_id
and t02.version_id = t1.version_id
and t02.idee_id = t1.idee_id) stunden_ilp,
(select htmldb_item.text(7,sum(stunden))stunden_ild from cn_pl_std_peplanung t02
where abt_id = '3'
and t02.pe_id = t1.pe_id
and t02.version_id = t1.version_id
and t02.idee_id = t1.idee_id) stunden_ild,
(select htmldb_item.text(8,sum(stunden))stunden_ilm from cn_pl_std_peplanung t02
where abt_id = '4'
and t02.pe_id = t1.pe_id
and t02.version_id = t1.version_id
and t02.idee_id = t1.idee_id) stunden_ilm,
(select htmldb_item.text(9,sum(stunden))stunden_ief from cn_pl_std_peplanung t02
where abt_id = '9'
and t02.pe_id = t1.pe_id
and t02.version_id = t1.version_id
and t02.idee_id = t1.idee_id) stunden_ief,
(select htmldb_item.text(10,sum(stunden))stunden_ir from cn_pl_std_peplanung t02
where abt_id = '10'
and t02.pe_id = t1.pe_id
and t02.version_id = t1.version_id
and t02.idee_id = t1.idee_id) stunden_ir,
(select sum(euro) from cn_pl_primaerkostenplanung p01
where p01.pe_id = t1.pe_id
and p01.version_id = t1.version_id
and p01.idee_id = t1.idee_id) summe_la,
"CASE WHEN p01.euro IS NOT NULL THEN"
(select sum((sum(t02.stunden) * k01.euro_std * 8)+(select sum(p01.euro) from cn_pl_primaerkostenplanung p01
where p01.pe_id = t1.pe_id
and p01.version_id = t1.version_id
and p01.idee_id = t1.idee_id))
from cn_pl_std_peplanung t02, cn_pl_sap_leistungsarten k01
where k01.l_art_id = t1.l_art_id
and t02.pe_id = t1.pe_id
and t02.version_id = t1.version_id
and t02.idee_id = t1.idee_id
group by t02.pe_id, k01.euro_std) "END" kosten_ges,
(select distinct htmldb_item.hidden(2,pe_id) pe_id from cn_pl_std_peplanung t02
where t02.pe_id = t1.pe_id
and t02.version_id = t1.version_id) pe_id,
(select distinct htmldb_item.hidden(3,l_art_id) l_art_id from cn_pl_std_peplanung t02
where t02.pe_id = t1.pe_id
and t02.version_id = t1.version_id) l_art_id,
(select distinct htmldb_item.hidden(4,version_id) version_id from cn_pl_std_peplanung t02
where t02.pe_id = t1.pe_id
and t02.version_id = t1.version_id) version_id
from cn_pl_std_peplanung t1, cn_pl_projektelemente z1, cn_pl_version u1, cn_pl_projektidee s1
where t1.version_id = '&P6_VERSION_WAHL.' and t1.pe_id ='&P6_HELP_PRODET.' and t1.l_art_id ='&P6_L_ART_ID.'
group by t1.pe_id, t1.version_id, t1.idee_id, t1.l_art_id order by t1.idee_id descNot sure if the rest is ok, but syntactically you can go for
SELECT (SELECT apex_item.select_list_from_query (
5,
name,
'select name from cn_pl_projektidee order by idee_id asc',
'style="width:130px"',
NULL
name
FROM cn_pl_projektidee s01
WHERE s01.idee_id = t1.idee_id)
idee,
(SELECT htmldb_item.text (6, SUM (stunden)) stunden_ilp
FROM cn_pl_std_peplanung t02
WHERE abt_id = '1'
AND t02.pe_id = t1.pe_id
AND t02.version_id = t1.version_id
AND t02.idee_id = t1.idee_id)
stunden_ilp,
(SELECT htmldb_item.text (7, SUM (stunden)) stunden_ild
FROM cn_pl_std_peplanung t02
WHERE abt_id = '3'
AND t02.pe_id = t1.pe_id
AND t02.version_id = t1.version_id
AND t02.idee_id = t1.idee_id)
stunden_ild,
(SELECT htmldb_item.text (8, SUM (stunden)) stunden_ilm
FROM cn_pl_std_peplanung t02
WHERE abt_id = '4'
AND t02.pe_id = t1.pe_id
AND t02.version_id = t1.version_id
AND t02.idee_id = t1.idee_id)
stunden_ilm,
(SELECT htmldb_item.text (9, SUM (stunden)) stunden_ief
FROM cn_pl_std_peplanung t02
WHERE abt_id = '9'
AND t02.pe_id = t1.pe_id
AND t02.version_id = t1.version_id
AND t02.idee_id = t1.idee_id)
stunden_ief,
(SELECT htmldb_item.text (10, SUM (stunden)) stunden_ir
FROM cn_pl_std_peplanung t02
WHERE abt_id = '10'
AND t02.pe_id = t1.pe_id
AND t02.version_id = t1.version_id
AND t02.idee_id = t1.idee_id)
stunden_ir,
(SELECT SUM (euro)
FROM cn_pl_primaerkostenplanung p01
WHERE p01.pe_id = t1.pe_id
AND p01.version_id = t1.version_id
AND p01.idee_id = t1.idee_id)
summe_la,
CASE
WHEN p01.euro IS NOT NULL
THEN
( SELECT SUM( (SUM (t02.stunden) * k01.euro_std * 8)
+ (SELECT SUM (p01.euro)
FROM cn_pl_primaerkostenplanung p01
WHERE p01.pe_id = t1.pe_id
AND p01.version_id = t1.version_id
AND p01.idee_id = t1.idee_id))
FROM cn_pl_std_peplanung t02, cn_pl_sap_leistungsarten k01
WHERE k01.l_art_id = t1.l_art_id
AND t02.pe_id = t1.pe_id
AND t02.version_id = t1.version_id
AND t02.idee_id = t1.idee_id
GROUP BY t02.pe_id, k01.euro_std)
END
kosten_ges,
(SELECT DISTINCT htmldb_item.hidden (2, pe_id) pe_id
FROM cn_pl_std_peplanung t02
WHERE t02.pe_id = t1.pe_id AND t02.version_id = t1.version_id)
pe_id,
(SELECT DISTINCT htmldb_item.hidden (3, l_art_id) l_art_id
FROM cn_pl_std_peplanung t02
WHERE t02.pe_id = t1.pe_id AND t02.version_id = t1.version_id)
l_art_id,
(SELECT DISTINCT htmldb_item.hidden (4, version_id) version_id
FROM cn_pl_std_peplanung t02
WHERE t02.pe_id = t1.pe_id AND t02.version_id = t1.version_id)
version_id
FROM cn_pl_std_peplanung t1,
cn_pl_projektelemente z1,
cn_pl_version u1,
cn_pl_projektidee s1
WHERE t1.version_id = '&P6_VERSION_WAHL.'
AND t1.pe_id = '&P6_HELP_PRODET.'
AND t1.l_art_id = '&P6_L_ART_ID.'
GROUP BY t1.pe_id,
t1.version_id,
t1.idee_id,
t1.l_art_id
ORDER BY t1.idee_id DESC -
Problem with case when statement, when doing an insert.
Hi there, I have written the following coding, that has got an issue, due to not being allowed null values to be inserted into a column on a table.
,Case
WHENCL.LocationISNOTNULLANDCL.[Floor]ISNOTNULLANDCL.RoomISNULLTHEN
(SELECTTop1
FL.FloorIDFROMPMIS.dbo.ConsentLocationF
JOINtbBuildingBONB.BuildingNumber=F.LocationCOLLATELatin1_General_CI_AS
JOINtbFloorFLONFL.BuildingID=B.BuildingID
WHEREF.Location=CL.LocationANDFL.FloorName=CL.[Floor]COLLATELatin1_General_CI_AS)
WHENCL.LocationISNOTNULLANDCL.[Floor]ISNOTNULLANDCL.RoomISNOTNULLTHEN
(SELECTTop1
R.RoomIDFROMPMIS.dbo.ConsentLocationF
JOINtbBuildingBONB.BuildingNumber=F.LocationCOLLATELatin1_General_CI_AS
JOINtbFloorFLONFL.BuildingID=B.BuildingID
JOINtbRoomRONR.FloorID=FL.FloorID
WHEREF.Location=CL.LocationANDFL.FloorName=CL.[Floor]COLLATELatin1_General_CI_ASANDR.RoomNumber=CL.RoomCOLLATELatin1_General_CI_AS)
ENDasParentID
I have written this case when statement above to find a ParentID. I have got the case when statement to work individually, e.g. I get the correct records back. However when I put it into a insert statement, as I want this ParentID to go
into a column in a table I get an error with the following message.
Cannot insert the value NULL into column 'ParentID', table 'K2_Master_4_Test.dbo.tbConsentLink'; column does not allow nulls. INSERT fails.
Can someone point me in the right direction, as to what I need to do to get this case when statement working? Also no I cannot change the structure of the table to allow for null values either. So I need to modifiy this one.The error is valid because your table column has 'not null' constraint and when your case expression does not satisfy either of the 'when' conditions, it is returning NULL to the insert statement.
you can get around this by defining a generic value. Simple Example
select case when <<Column>>=1 then 'First' When <<Column>>=2 then 'Second' Else 'Last' End
In this case, when column value is not 1 or 2, it will insert 'Last'.
So, you have to do something like this...i.e add ELSE condition to your case..
Hope it Helps!! -
Using case when statement in the select query to create physical table
Hello,
I have a requirement where in I have to execute a case when statement with a session variable while creating a physical table using a select query. let me explain with an example.
I have a physical table based on a select table with one column.
SELECT 'VALUEOF(NQ_SESSION.NAME_PARAMETER)' AS NAME_PARAMETER FROM DUAL. Let me call this table as the NAME_PARAMETER table.
I also have a customer table.
In my dashboard that has two pages, Page 1 contains a table with the customer table with column navigation to my second dashboard page.
In my second dashboard page I created a dashboard report based on NAME_PARAMETER table and a prompt based on customer table that sets the NAME_ PARAMETER request variable.
EXECUTION
When i click on a particular customer, the prompt sets the variable NAME_PARAMETER and the NAME_PARAMETER table shows the appropriate customer.
everything works as expected. YE!!
Now i created another table called NAME_PARAMETER1 with a little modification to the earlier table. the query is as follows.
SELECT CASE WHEN 'VALUEOF(NQ_SESSION.NAME_PARAMETER)'='Customer 1' THEN 'TEST_MART1' ELSE TEST_MART2' END AS NAME_PARAMETER
FROM DUAL
Now I pull in this table into the second dashboard page along with the NAME_PARAMETER table report.
surprisingly, NAME_PARAMETER table report executes as is, but the other report based on the NAME_PARAMETER1 table fails with the following error.
Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 16001] ODBC error state: S1000 code: 1756 message: [Oracle][ODBC][Ora]ORA-01756: quoted string not properly terminated. [nQSError: 16014] SQL statement preparation failed. (HY000)
SQL Issued: SET VARIABLE NAME_PARAMETER='Novartis';SELECT NAME_PARAMETER.NAME_PARAMETER saw_0 FROM POC_ONE_DOT_TWO ORDER BY saw_0
If anyone has any explanation to this error and how we can achieve the same, please help.
Thanks.Hello,
Updates :) sorry.. the error was a stupid one.. I resolved and I got stuck at my next step.
I am creating a physical table using a select query. But I am trying to obtain the name of the table dynamically.
Here is what I am trying to do. the select query of the physical table is as follows.
SELECT CUSTOMER_ID AS CUSTOMER_ID, CUSTOMER_NAME AS CUSTOMER_NAME FROM 'VALUEOF(NQ_SESSION.SCHEMA_NAME)'.CUSTOMER.
The idea behind this is to obtain the data from the same table from different schemas dynamically based on what a session variable. Please let me know if there is a way to achieve this, if not please let me know if this can be achieved in any other method in OBIEE.
Thanks. -
hi gems...
i have a case when statement in a select clause...there are total three conditions in the case when statemnt.
now my question is if all theconditions gets matched, then what will happen???
is only first condition gets executed and rest two will be ignored or the third condition will overwrite the previous two???
please help...thanks in advance...Hello
This isn't very difficult to test....
select
CASE
WHEN 1=1 THEN
1
WHEN 1=1 THEN
2
WHEN 1=1 THEN
3
END c
FROM
dual
C
1
1 row selected.It wil return the first match.
David -
"IN" operator in Case When statement
Hi
When I'm trying to use "IN" operator in the "Case When" statement , the following error is being displayed : " [nQSError: 27002] Near <In>: Syntax error [nQSError: 26012] " .
Please let me know wether we can use "IN" oprerator in the Case When statement.
Thanks.Hi
Below is the code in which I'm trying to use "IN" operator in the CASE WHEN statement :
CASE WHEN Month=1 then Year IN (2009,2010) else 0 end
Above - (Year and month are of integer datatype, hence i did not use single quotes)
Thanks -
Using more than one case when statement
Hi there,
I have a question on using case when statements.
Currently I have a table where it shows me mulitple dates.
Order Saledate TransferDate StartDate Enddate GetDate
I have created a where statement to show me records against the transferdate dependant if it appears within the date range of the year, or if it appears within the startdate and today's date.
(lpatran.trandate between targets.startdate
and (case when targets.enddate < getdate() then targets.enddate else getdate() end))
However on some of the records the transfer date is null, and so they want to use the saledate as the date to use.
So I created
(case when Lpatran.trandate is not null then (Lpatran.trandate between targets.startdate
and (case when targets.enddate < getdate() then targets.enddate else getdate()))
else (lpatran.saledate between targets.startdate
and (case when targets.enddate < getdate() then targets.enddate else getdate())) end )
However it gives me an incorrect syntax near the word ‘between ‘
Is there a simple fix for this or does sql not allow me to do this?I have created a new column called transferdate and done a case when statement
CASE
WHEN lpatran.trandate
IS
NULL
THEN lpatran.saledate
ELSE lpatran.trandate
END
AS Transferdate,
Then created a temptable and did a select * from temptable. Created a where statement from transferdate, which does work and gives me the correct data.
TransferDate between startdate
and(case
when enddate
<
getdate()
then enddate
else
getdate()
end))
However I wanted to know if there was a way of obtaining the same data without having to use the temptable ? -
How to create nested case when statement in OBIEE 11g?
Hi All,
I need to create a formula using nested case when statement. The formula to be created is below:
=If([AWRV]<0; "<0";
If([AWRV]=0; "0";
If([AWRV]<=15; ">0 and <=15";
If([AWRV]<=25; ">15 and <=25";
If([AWRV]<=50; ">25 and <=50";
If([AWRV]<=75; ">50 and <=75";
If([AWRV]<=100; ">75 and <=100";
If([AWRV]<=200; ">100 and <=200";
If([AWRV]<=500; ">200 and <=500";
If([AWRV]<=1000; ">500 and <=1000";
If([AWRV]<=5000; ">1000 and <=5000";
If([AWRV]<=10000; ">5000 and <=10000"; ">10000"))))))))))))
How to recreate using Nested case when? I tried in many different ways but it is displaying syntax error in obiee11g. This is very critical. Can anybody shed light on this issue pls?
Thanks in advance,
ThenmozhiHoney26 wrote:
Hi All,
I need to create a formula using nested case when statement. The formula to be created is below:
=If([AWRV]<0; "<0";
If([AWRV]=0; "0";
If([AWRV]<=15; ">0 and <=15";
If([AWRV]<=25; ">15 and <=25";
If([AWRV]<=50; ">25 and <=50";
If([AWRV]<=75; ">50 and <=75";
If([AWRV]<=100; ">75 and <=100";
If([AWRV]<=200; ">100 and <=200";
If([AWRV]<=500; ">200 and <=500";
If([AWRV]<=1000; ">500 and <=1000";
If([AWRV]<=5000; ">1000 and <=5000";
If([AWRV]<=10000; ">5000 and <=10000"; ">10000"))))))))))))
How to recreate using Nested case when? I tried in many different ways but it is displaying syntax error in obiee11g. This is very critical. Can anybody shed light on this issue pls?
Thanks in advance,
ThenmozhiTry the below:
CASE WHEN "Fact - Open Chargeback"."Sub Chbk Amt" < 0 THEN ' <0'
WHEN "Fact - Open Chargeback"."Sub Chbk Amt" = 0 THEN '0'
WHEN "Fact - Open Chargeback"."Sub Chbk Amt" BETWEEN 0 AND 15 THEN '>0 AND <=15'
END
Hope this helps.
Maybe you are looking for
-
Is it possible to change ur password from lock screen?
My iPod stopped charging after while of use, so I stopped using it, but I found a way to charge it, but I forgot the password on it. Is there any way I can reset the password from the lock screen?
-
Hi all, I did import a "SWF" small movie into a new flash document.... the idea is to create two buttons, STOP/PAUSE and PLAY. But I can't figure this out using the behaviors tool from the windows menu.. In the first layer is the movie "sample.swf" i
-
Adobe FP 10-A Script in this movie is causing Adobe FP 10 to run slowly. If it continues to run your computer may become unresponsive. Do you want to abort this script? yes or no. How do I fix this crash?
-
Try to Execute CRM_TEXT_MAINTAIN_OW
Hi Experts, i am trying to execute the fm CRM_TEXT_MAINTAIN_OW, but i will not work, what is the mistake in my test report, i cannot find him. *& Report ZTEST_CRM_TEXT_MAINTAIN_OW REPORT ZTEST_CRM_TEXT_MAINTAIN_OW. DATA: lv_guid_ref TYPE crmt_object_
-
I would like to know what recommendations people have for poster software? I have a mac osx 10.6.8 and would like to know if there are any versions of photoshop that would be suitable. Any help appreciated. Thanks.