Help with Query function on EAI Siebel Adapter
Can anyone help?
I have a workflow that uses the Query method on EAI Siebel Adapter to search for a Contact in Siebel. The Root component is Contact and the Child component is Address.
When I pass in a message that contains Contact data (i.e. LastName='Jones') and Address data (City='Perth') to query on, it returns all Contacts that match the Contact data, and for each of those Contacts if the address data matches it also returns the address.
What I want it to do is only return those Contacts that match both the Contact data 'AND' the address data, not all of the Contacts that match the contact data.
I hope this makes sense.
I've also tried using the searchspec function too, but this does not do what I want it to do either.
Hope you can help.
Thanks,
Carl
Can a
Hi,
can you create a MVG in Contact which will refer to Business Address & then try to use searchspec argument. I hope it will work for you.
Similar Messages
-
EAI Siebel Adapter Updating Join Field
Hi Folks,
I insert an Account using EAI Siebel Adapter "Execute" Method.
Account BC has an explicit join named "Primary Industry" that "Primary Industry Id" points the "ROW_ID" of "S_INDUST" table. In Account BC fields there is an "Industry Name" field using "Primary Industry" join.
External System knows the Industry Name but it doesn't know the ROW_ID of given value.So Primary Industry Id (join field) couldn't be set.
Example S_INDUST record: ROW_ID:"1-ABC" INDUSTRY_NAME:"Energy"
XML Input from External System: <Account><Name>Account1</Name><IndustryName>Energy</IndustryName></A ccount>
When executing execute method of EAI Siebel Adapter It creates Account1 and sets Primary Industry Id to NULL.
What I need a lookup that uses the "Energy" keyword (Industry Name) and update the Primary Industry Id to "1-ABC"
What configurations should i make in order to set explicit join fields?
I appreciate if someone can help me.
Thanks.
Best Regards.
Doan.Hi Doan,
You will have to write a script on the Account BC to update the details coming in from the Explicit Join Table. For this there should be a BC on the Join Table and your script can update the requisite fields by doing a query with the details in the XML that comes in.
So basically you will be querying on the other BC and setting field values there. Do this in the WriteRecord of your Account BC and you should be fine.
I am not aware of any other way of achieving this.
With Regards,
Tanmay Jain -
Hi...I was wondering if I could get help with this function. How do i write a function to return hours between a begin date and an end date for an employee. Thanks so much
EdStevens wrote:
AlexeyDev wrote:
sb92075 wrote:
select (date2-date1)*24 from dual;not as above but as below
select (date2-date1)/24 from dual;date2-date1 is amount of days. Divide it by 24 and what? if you multiply it on 24 you will have a chance to know how many hours between these two dates. :-)Don't forget that a DATE type also includes a time component.I suppose it doesn't matter if you did a difference between two dates. The result is always number of days. -
Help with query calculations (recursive)
Hi All,
I want some help with a query using a base rate and the result use in the next calculation year.
Here an example:
create table rate_type(
rate_type_id number,
rate_desc nvarchar2(50),
rate_base_year number
insert into rate_type(rate_type_id, rate_desc, rate_base_year) values (1, 'Desc1', 4.6590);
insert into rate_type(rate_type_id, rate_desc, rate_base_year) values (2, 'Desc2', 4.6590);
create table rates (
rate_type_id number
rate_year number,
rate_value number
insert into rates(rate_type_id, rate_year, rate_value) values (1, 2012, 1.2);
insert into rates(rate_type_id, rate_year, rate_value) values (1, 2013, 1.3);
insert into rates(rate_type_id, rate_year, rate_value) values (1, 2014, 1.4);
insert into rates(rate_type_id, rate_year, rate_value) values (2, 2012, 1.2);
insert into rates(rate_type_id, rate_year, rate_value) values (2, 2013, 1.3);
insert into rates(rate_type_id, rate_year, rate_value) values (2, 2014, 1.4);The calculation for the first year should be the base rate of the rate type. The next year should use the result of the previous year and so on.
The result of my sample data is:
2012 = 4.659 + 1.2 + 4.659 * (1.2 * 0.01) = 5.9149
2013 = 5.9149 + 1.3 + 5.9149 * (1.3 * 0.01) = 7.1859
2014 = 7.1859 + 1.4 + 7.1859 * (1.4 * 0.01) = 8.4721Query result:
NAME 2012 2013 2014
Desc1 5.9149 7.1859 8.4721
Desc2 XXXX XXX XXXX
How can I do this in one select statement? Any ideas?
Thanks!Assuming you are on 11.2:
with t as (
select a.rate_type_id,
rate_desc,
rate_year,
rate_base_year,
rate_value,
count(*) over(partition by a.rate_type_id) cnt,
row_number() over(partition by a.rate_type_id order by rate_year) rn
from rate_type a,
rates b
where a.rate_type_id = b.rate_type_id
r(
rate_type_id,
rate_desc,
rate_year,
rate_base_year,
rate_value,
cnt,
rn,
result
) as (
select rate_type_id,
rate_desc,
rate_year,
rate_base_year,
rate_value,
cnt,
rn,
rate_base_year + rate_value + rate_base_year * rate_value * 0.01 result
from t
where rn = 1
union all
select t.rate_type_id,
t.rate_desc,
t.rate_year,
t.rate_base_year,
t.rate_value,
t.cnt,
t.rn,
r.result + t.rate_value + r.result * t.rate_value * 0.01 result
from r,
t
where t.rate_type_id = r.rate_type_id
and t.rn = r.rn + 1
select *
from (
select rate_desc name,
rate_year,
result
from r
where rn <= cnt
pivot (sum(result) for rate_year in (2012,2013,2014))
order by name
NAME 2012 2013 2014
Desc1 5.914908 7.2918018 8.79388703
Desc2 5.914908 7.2918018 8.79388703
SQL> Obviously pivoting assumes you know rate_year values upfront. If not, then without pivoting:
with t as (
select a.rate_type_id,
rate_desc,
rate_year,
rate_base_year,
rate_value,
count(*) over(partition by a.rate_type_id) cnt,
row_number() over(partition by a.rate_type_id order by rate_year) rn
from rate_type a,
rates b
where a.rate_type_id = b.rate_type_id
r(
rate_type_id,
rate_desc,
rate_year,
rate_base_year,
rate_value,
cnt,
rn,
result
) as (
select rate_type_id,
rate_desc,
rate_year,
rate_base_year,
rate_value,
cnt,
rn,
rate_base_year + rate_value + rate_base_year * rate_value * 0.01 result
from t
where rn = 1
union all
select t.rate_type_id,
t.rate_desc,
t.rate_year,
t.rate_base_year,
t.rate_value,
t.cnt,
t.rn,
r.result + t.rate_value + r.result * t.rate_value * 0.01 result
from r,
t
where t.rate_type_id = r.rate_type_id
and t.rn = r.rn + 1
select rate_desc name,
rate_year,
result
from r
where rn <= cnt
order by name,
rate_year
NAME RATE_YEAR RESULT
Desc1 2012 5.914908
Desc1 2013 7.2918018
Desc1 2014 8.79388703
Desc2 2012 5.914908
Desc2 2013 7.2918018
Desc2 2014 8.79388703
6 rows selected.
SQL> SY. -
Hi all,
I need some help with ASO mdx function.
Avg({Leaves([Employees].Currentmember)}, [Calculated_Field]). This will give me the average for Calculated_Field for all levels of Employees. But i want to add more dimensions like Region and year.
Please advice how can I achieve this.
Thanks
Andyyou have to use cross join in order to add more dimension members to the formula.This will give you some idea
Re: Writing formula in Outline??????
Regards,
RSG -
I need help with Analytic Function
Hi,
I have this little problem that I need help with.
My datafile has thousands of records that look like...
Client_Id Region Countries
[1] [1] [USA, Canada]
[1] [2] [Australia, France, Germany]
[1] [3] [China, India, Korea]
[1] [4] [Brazil, Mexico]
[8] [1] [USA, Canada]
[9] [1] [USA, Canada]
[9] [4] [Argentina, Brazil]
[13] [1] [USA, Canada]
[15] [1] [USA]
[15] [4] [Argentina, Brazil]
etc
My task is is to create a report with 2 columns - Client_Id and Countries, to look something like...
Client_Id Countries
[1] [USA, Canada, Australia, France, Germany, China, India, Korea, Brazil, Mexico]
[8] [USA, Canada]
[9] [USA, Canada, Argentina, Brazil]
[13] [USA, Canada]
[15] [USA, Argentina, Brazil]
etc.
How can I achieve this using Analytic Function(s)?
Thanks.
BDFHi,
That's called String Aggregation , and the following site shows many ways to do it:
http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php
Which one should you use? That depends on which version of Oracle you're using, and your exact requirements.
For example, is order importatn? You said the results shoudl include:
CLIENT_ID COUNTRIES
1 USA, Canada, Australia, France, Germany, China, India, Korea, Brazil, Mexicobut would you be equally happy with
CLIENT_ID COUNTRIES
1 Australia, France, Germany, China, India, Korea, Brazil, Mexico, USA, Canadaor
CLIENT_ID COUNTRIES
1 Australia, France, Germany, USA, Canada, Brazil, Mexico, China, India, Korea?
Mwalimu wrote:
... How can I achieve this using Analytic Function(s)?The best solution may not involve analytic functions at all. Is that okay?
If you'd like help, post your best attempt, a little sample data (CREATE TABLE and INSERT statements), the results you want from that data, and an explanation of how you get those results from that data.
Always say which version of Oracle you're using.
Edited by: Frank Kulash on Aug 29, 2011 3:05 PM -
Help with Sort function in Terminal
Hello all... this is my first post on here as I'm having some trouble with some Termianl commands. I'm trying to learn Terminal at the moment as it is but I would appreciate some help with this one....
I'm trying to sort a rather large txt file into alphabetical order and also delete any duplicates. I've been using the following command in Terminal:
sort -u words.txt > words1.txt
but after a while I get the following error
sort: string comparison failed: Illegal byte sequence
sort: Set LC_ALL='C' to work around the problem.
sort: The strings compared were `ariadnetr\345dens\r' and `ariadnetr\345ds\r'.
What should my initial command be? What is Set LC_ALL='C'?
Hope you guys can help?Various languages distinct sorting - collation - sequences.
The characters can and variously do sort differently, depending on what language is involved.
Languages here can include the written languages of humans, and a few settings associated with programming languages. This is all part of what is known as internationalization and localization, and there are are various documents around on that topic.
The LC_ALL environment variable sets all of the locale-related settings en-mass, including the collation sequence that is established via LC_COLLATE et al, and the sort tool is suggesting selecting the C language collation.
Here, the tool is suggesting the following syntax:
LC_ALL=C sort -u words.txt > words1.txt
This can also be done by exporting the LC_ALL, but it's probably better to just do this locally before invoking the tool.
Also look at the lines of text in question within the files, and confirm the character encoding of the file.
Files can have different character encodings, and there's no reliable means to guess the encoding. For some related information, see the file command:
file words.txt
...and start reading some of the materials on internationalization and localization that are posted around the 'net. Here's Apple's top-level overview.
In this case, it looks like there's an "odd" character and probably an å character on that line and apparently the Svenska ariadnetrådens.
Switching collation can help here, or - if the character is not necessary - removing it via tr or replacing it via sed can be equally effective solutions.
Given it appears to be Svenska, it might work better to switch to Svenska collation thanto the suggested C collation.
I think that's going to be sv_SE, which would make the command:
LC_ALL=sv_SE sort -u words.txt > words1.txt
This is all generic bash shell scripting stuff, and not specific to OS X. If you haven't already seen them, the folks over at tldp have various guides including a bash guide for beginners, and an advanced bash scripting guide - both can be worth skimming. They're not exactly the same as bash on OS X and some specific commands and switches can differ, and as bash versions can differ, but bash is quite similar across all the platforms. -
Help with bash function(set background=dark/light in vimrc)
I couldn't find any gvimrc files so I guess it uses the regular one. And since I work pretty much in X too I thought it would be nice with a function that sets background=light if I'm in X an background=dark if not. Is that possible?
/Richardvimrc configuration is not the same as bash.
You probably want something like this in your ~/.vimrc:
if has('gui_running')
set background=light
else
set background = dark
endif -
Help with aggregate function max query
I have a large database which stores daily oil life, odo readings from thousands of vehicles being tested but only once a month.
I am trying to grab data from one month where only the EOL_READ = 0 and put all of those values into the previous month's query where EOL_READ = anything.
Here is the original query which grabs everything
(select distinct vdh.STID, vdh.CASE_SAK,
max(to_number(decode(COMMAND_ID,'EOL_READ',COMMAND_RESULT,-100000))) EOL_READ,
max(to_number(decode(COMMAND_ID,'ODO_READ',COMMAND_RESULT,-100000))) ODO_READ,
max(to_number(decode(COMMAND_ID,'OIL_LIFE_PREDICTION',COMMAND_RESULT,-100000))) OIL_LIFE_PREDICTION
from veh_diag_history vdh, c2pt_data_history cdh
where vdh.veh_diag_history_sak = cdh.veh_diag_history_sak
and cdh.COMMAND_ID in ('EOL_READ','ODO_READ','OIL_LIFE_PREDICTION')
and vdh.LOGICAL_TRIGGER_SAK = 3
and cdh.CREATED_TIMESTAMP =vdh.CREATED_TIMESTAMP
and cdh.CREATED_TIMESTAMP >= to_date('03/01/2007 12:00:00 AM','mm/dd/yyyy HH:MI:SS AM')
and cdh.CREATED_TIMESTAMP < to_date('04/01/2007 12:00:00 AM','mm/dd/yyyy HH:MI:SS AM')
group by vdh.STID, vdh.case_sak
having count(distinct command_id) = 3
order by OIL_LIFE_PREDICTION)
which gives 5 columns:
STID, CASE_SAK, EOL_READ, ODO_READ, and OIL_LIFE_PREDICTION
and gives me about 80000 rows returned for the above query
I only want one reading per month, but sometimes I get two.
STID is the unique identifier for a vehicle.
I tried this query:
I tried this query which nests one request within the other and SQL times out every time:
select distinct vdh.STID, vdh.CASE_SAK,
max(to_number(decode(COMMAND_ID,'EOL_READ',COMMAND_RESULT,-100000))) EOL_READ,
max(to_number(decode(COMMAND_ID,'ODO_READ',COMMAND_RESULT,-100000))) ODO_READ,
max(to_number(decode(COMMAND_ID,'OIL_LIFE_PREDICTION',COMMAND_RESULT,-100000))) OIL_LIFE_PREDICTION
from veh_diag_history vdh, c2pt_data_history cdh
where vdh.veh_diag_history_sak = cdh.veh_diag_history_sak
and cdh.COMMAND_ID in ('EOL_READ','ODO_READ','OIL_LIFE_PREDICTION')
and vdh.LOGICAL_TRIGGER_SAK = 3
and cdh.CREATED_TIMESTAMP =vdh.CREATED_TIMESTAMP
and cdh.CREATED_TIMESTAMP >= to_date('02/01/2007 12:00:00 AM','mm/dd/yyyy HH:MI:SS AM')
and cdh.CREATED_TIMESTAMP < to_date('03/01/2007 12:00:00 AM','mm/dd/yyyy HH:MI:SS AM')
group by vdh.STID, vdh.case_sak
having count(distinct command_id) = 3
and vdh.stid in (select distinct vdh.STID, vdh.CASE_SAK,
max(to_number(decode(COMMAND_ID,'EOL_READ',COMMAND_RESULT,-100000))) EOL_READ,
max(to_number(decode(COMMAND_ID,'ODO_READ',COMMAND_RESULT,-100000))) ODO_READ,
max(to_number(decode(COMMAND_ID,'OIL_LIFE_PREDICTION',COMMAND_RESULT,-100000))) OIL_LIFE_PREDICTION
from veh_diag_history vdh, c2pt_data_history cdh
where vdh.veh_diag_history_sak = cdh.veh_diag_history_sak
and cdh.COMMAND_ID in ('EOL_READ','ODO_READ','OIL_LIFE_PREDICTION')
and vdh.LOGICAL_TRIGGER_SAK = 3
and cdh.CREATED_TIMESTAMP =vdh.CREATED_TIMESTAMP
and cdh.CREATED_TIMESTAMP >= to_date('03/01/2007 12:00:00 AM','mm/dd/yyyy HH:MI:SS AM')
and cdh.CREATED_TIMESTAMP < to_date('04/01/2007 12:00:00 AM','mm/dd/yyyy HH:MI:SS AM')
group by vdh.STID, vdh.case_sak
having count(distinct command_id) = 3
and (max(to_number(decode(COMMAND_ID,'EOL_READ',COMMAND_RESULT,-100000)))) = 0)
order by OIL_LIFE_PREDICTION
so in summary I am trying to select values from the previous month only from those stids where this month's value for EOL_READ = 0
Any ideas.....please help.You can use row_number() within each stid and each month to determine the first read of each month. Then you can use lag() to get the previous month's reading of the current month's reading is zero.
with all_data as (
select stid,
case_sak,
eol_read,
timestamp,
row_number() over (partition by stid, trunc(timestamp,'mm') order by timestamp) AS rn
from veh_diag_history
select stid,
case_sak,
case
when eol_read = 0
then lag(eol_read) over (partition by stid order by timestamp)
else eol_read
end as eol_read
from all_data
where rn = 1; -
Need help with responsibility/ functions query
hi,
we are working in oracle applications 11i.
I have a requirement to extract the responsibility list of functions and menus.
I need to omit the excluded menus from each responsibility
this what I have so far (after researching the internet):
SELECT
FRTL.RESPONSIBILITY_NAME,
FFL.USER_FUNCTION_NAME, FFF.FUNCTION_NAME,ft.RESPONSIBILITY_NAME
FROM
FND_USER_RESP_GROUPS FURG,
fnd_responsibility_tl ft ,
FND_RESPONSIBILITY FR,
FND_COMPILED_MENU_FUNCTIONS FCMF,
FND_FORM_FUNCTIONS FFF,
FND_RESPONSIBILITY_TL FRTL,
FND_FORM_FUNCTIONS_TL FFL
WHERE
FURG.RESPONSIBILITY_ID = FR.RESPONSIBILITY_ID
and ft.RESPONSIBILITY_ID(+)= fr.RESPONSIBILITY_ID
AND FURG.RESPONSIBILITY_APPLICATION_ID = FR.APPLICATION_ID
AND FR.MENU_ID = FCMF.MENU_ID
AND FCMF.GRANT_FLAG = 'Y'
AND FCMF.FUNCTION_ID = FFF.FUNCTION_ID
AND SYSDATE BETWEEN FR.START_DATE AND NVL(FR.END_DATE, SYSDATE+1)
and fr.CREATION_DATE >= to_date('01-jan-2005','dd-mon-yyyy')
AND FURG.RESPONSIBILITY_ID = FRTL.RESPONSIBILITY_ID
AND FR.RESPONSIBILITY_ID = FRTL.RESPONSIBILITY_ID
AND FRTL.LANGUAGE = 'US'
AND FFL.LANGUAGE = 'US'
AND FFF.FUNCTION_ID = FFL.FUNCTION_ID
AND (FURG.END_DATE > SYSDATE
OR FURG.END_DATE IS NULL)
AND FFF.FUNCTION_NAME NOT IN
SELECT FF.FUNCTION_NAME
FROM FND_RESPONSIBILITY R, FND_USER_RESP_GROUPS RG
, FND_RESP_FUNCTIONS RF, FND_FORM_FUNCTIONS FF, FND_RESPONSIBILITY_TL FRTL
WHERE RG.RESPONSIBILITY_ID = R.RESPONSIBILITY_ID
AND RF.RESPONSIBILITY_ID = R.RESPONSIBILITY_ID
AND RF.RULE_TYPE = 'F'
AND FF.FUNCTION_ID = RF.ACTION_ID
AND FRTL.RESPONSIBILITY_ID = R.RESPONSIBILITY_ID
AND FRTL.RESPONSIBILITY_ID = RG.RESPONSIBILITY_ID
AND FRTL.LANGUAGE = 'US'
help me please to exclude the menus.tried it and had the following error:
if((tbl_menu_id.FIRST is NULL) or (tbl_menu_id.FIRST 1)) then
ERROR at line 136:
ORA-06550: line 136, column 54:
PLS-00103: Encountered the symbol "1" when expecting one of the following:
*. ( ) , * @ % & | = - + < / > at in is mod not range rem =>*
*.. <an exponent (**)> <> or != or ~= >= <= <> and or like*
between ||
The symbol "," was substituted for "1" to continue.
from another perspective, from applications front end, when I press ctrl +L on any responsibility menu, I get the list of the forms names.
which database tables can I get that from? -
Help with Date function in sql query....
My question I guess is really 2...I'm trying to use the date function as a comparison in my WHERE clause in my sql command.
1. My date format is dd-MMM-yy eg. (01-Apr-06) ... my problem is the Apr is lower case where my field in the database is 01-APR-06 so when I compare 01-Apr-06 to 01-APR-06 is doesnt find any rows. Is there away that I can make the Apr all upper case so that it is APR.
2. My second problem is getting this "date" field to work in my sql stmt I keep getting errors and it works fine if I take my attempts at trying to compare the date.
--------------Date Code----------------------------------------------------------
<%!
String getFormattedDate(java.util.Date d)
SimpleDateFormat simpleDate = new SimpleDateFormat("01-MMM-yy");
return simpleDate.format(d);
%>
<%
java.util.Date d = new java.util.Date();
String dateString = getFormattedDate (d);
%>
---------------------------Sql statment------------------------------------------
ResultSet rset = stmt.executeQuery ("SELECT name " + " FROM table where rdate = '01-APR-06' order by name ");
Currently Im just hard coding the date but I need to make it so it uses the date code...so....
rdate should equal the date from the formatted date in upper case
something like
rdate = <%= dateString %>
Thanks in advance for any ideas anyone may have...There are sql functions upper & lower.
SELECT name FROM table where upper(rdate) = '01-APR-06' order by name Or you could convert the date to a string, and use the toUpperCase & toLowerCase java.lang.String methods. It doesn't make much of a difference--do you want the java compiler to do the string conversion or the database? -
Need Help With Query Using Aggregation
If I have a table, defined like this:
CREATE TABLE range_test
range_id NUMBER(20) NOT NULL,
grade CHAR(1) NOT NULL,
lower_bound_of_range NUMBER(5,2) NOT NULL,
upper_bound_of_range NUMBER(5,2) NOT NULL,
received_date_time_stamp TIMESTAMP DEFAULT SYSTIMESTAMP NOT NULL
And I wanted to query the table to find the range associated with the last inserted row for each 'grade' (e.g. 'A', 'B', 'C', etc), how would I go about that?
I want something like the following, but I know that this won't work right:
SELECT
grade,
lower_bounding_of_range,
upper_bounding_of_range,
max(received_date_time_stamp)
FROM
range_test GROUP BY received_date_time_stamp;
Thanks for your help. . .I'm frustrating myself with this one and I think it should be possible without having to use PL/SQL (i.e. SQL aggregate functions or sub-queries should work).Perhaps something along the lines of...
SQL> ed
Wrote file afiedt.buf
1 select deptno, empno, ename, hiredate
2 from emp
3* order by deptno, empno
SQL> /
DEPTNO EMPNO ENAME HIREDATE
10 7782 CLARK 09-JUN-1981 00:00:00
10 7839 KING 17-NOV-1981 00:00:00
10 7934 MILLER 23-JAN-1982 00:00:00
20 7369 SMITH 17-DEC-1980 00:00:00
20 7566 JONES 02-APR-1981 00:00:00
20 7788 SCOTT 19-APR-1987 00:00:00
20 7876 ADAMS 23-MAY-1987 00:00:00
20 7902 FORD 03-DEC-1981 00:00:00
30 7499 ALLEN 20-FEB-1981 00:00:00
30 7521 WARD 22-FEB-1981 00:00:00
30 7654 MARTIN 28-SEP-1981 00:00:00
30 7698 BLAKE 01-MAY-1981 00:00:00
30 7844 TURNER 08-SEP-1981 00:00:00
30 7900 JAMES 03-DEC-1981 00:00:00
14 rows selected.
SQL> ed
Wrote file afiedt.buf
1 select deptno, empno, ename, hiredate
2 from (
3 select deptno, empno, ename, hiredate
4 ,row_number() over (partition by deptno order by hiredate desc) as rn
5 from emp
6 )
7 where rn = 1
8* order by deptno, empno
SQL> /
DEPTNO EMPNO ENAME HIREDATE
10 7934 MILLER 23-JAN-1982 00:00:00
20 7876 ADAMS 23-MAY-1987 00:00:00
30 7900 JAMES 03-DEC-1981 00:00:00
SQL> -
Help with query to do with aggregating for MIN(DATE)
Say i have the following table of data:
Table: TEST
ID TDATE CLIENT VAL
1A 1/10/2005 client1 10
2A 2/10/2005 client1 30
3A 3/11/2005 client2 22
4A 5/10/2005 client2 43
5A 5/10/2005 client2 3
6A 6/10/2005 client3 5
7A 7/10/2005 client3 76
I want to create a query that will retrieve a distinct list of the CLIENT column (ie. in the above table I want only 3 records retrieved in the query as there are only 3 clients) and the corresponding ID and VAL for the client record with the MIN(DATE). In the case where 2 dates are the same, I dont care which record is selected as long as the ID and VAL columns belong to the same record.
For example in the above data I would expect the following returned in the query:
ID CLIENT VAL
1A client1 10
4A client2 43 <- this record could also be 5A, client2, 3
6A client3 5
Please help.Hi Joshua,
You didn't post your Oracle version but I hope it supports analytic functions.
Try as follows:
SQL> select id,
2 tdate,
3 client,
4 val
5 from (select t.*,
6 row_number() over
7 (partition by client order by tdate) rn
8 from test t)
9 where rn = 1;
ID TDATE CLIENT VAL
1A 01/10/2005 client1 10
4A 05/10/2005 client2 43
6A 06/10/2005 client3 5Regards. -
Hi,
I am trying to get a daily statistics of failed instances using Query Builder. I tried to use fields like SI_UPDATE_TS and SI_STARTTIME to filter instances with in a date range, but date range functions does not seem to work. Is there documentation somewhere as to which fields can be used or how the query should be formatted to get results like this?
Thanks
AjithHello Ajith,
The Query Builder interface is actually rather limited, as you have found out yourself. I don't know if you have any programming experience, but the Query Builder is nothing more than an interface which will use the SDK in the background to talk to the CMS. In other words, if you know how to program for your BO XI deployment (Java or .NET), you can write the logic necessary to retrieve whatever information you want. You'll also find that the SDK documentation contains an explanation (though sometimes limited) for the properties and members that are available.
Although using the SDK might seem overwhelming at first, it's actually quite easy and far more powerful than the Query Builder alternative. Also, Business Objects hosts quite a few code samples that should easily get you started. There's also a dedicated SDK forum for all specific issues relating to development.
Some links to get you up and running:
[Developer Library|https://boc.sdn.sap.com/developer/library]
[Code Samples|https://www.sdn.sap.com/irj/sdn/businessobjects-samples]
[Business Objects SDK Application Development Forums|https://www.sdn.sap.com/irj/sdn/businessobjects-sdk-forum]
Hope this helps!
Kind regards,
Kristof -
Hello, I have the following query that I'm running in Oracle SQL Developer 1.2.1
WITH group_by_4_column_results AS
(SELECT m_atschunk.employee AS employee,
SUM(CASE
WHEN
M_ATSCHUNK.rolloffDaysCount = '108545043' AND m_atschunk.infractiondate BETWEEN SYSDATE - 365 AND SYSDATE THEN 1 ELSE 0 END) as rolloffs,
M_ATSCHUNK.INFRACTIONDATE + 365 as infractionDate
FROM M_ATSCHUNK
group by employee, infractionDate, rolloffDaysCount
SELECT g4.*,
SUM (rolloffs) OVER (PARTITION BY employee) AS total_rolloffs
FROM group_by_4_column_results g4
It will output the key elements of what I need. But where it sums up the 'total_rolloffs', I need to add that number back into the infractiondate column. Any help would be greatly appreciated.
CREATE TABLE M_ATSCHUNK
(EMPLOYEE varchar(50),
ROLLOFFDAYSCOUNT varchar(3),
INFRACTIONDATE date)
INSERT INTO M_ATSCHUNK (EMPLOYEE, ROLLINGOFFDAYSCOUNT, INFRACTIONDATE)
VALUES ('PHIL','YES', (to_date('2010/01/01 08:00:00', 'yyyy/mm/dd hh24:mi:ss'))),
VALUES ('PHIL','YES', (to_date('2010/01/02 08:00:00', 'yyyy/mm/dd hh24:mi:ss'))),
VALUES ('PHIL','YES', (to_date('2010/01/03 08:00:00', 'yyyy/mm/dd hh24:mi:ss'))),
VALUES ('PHIL','YES', (to_date('2010/01/04 08:00:00', 'yyyy/mm/dd hh24:mi:ss'))),
VALUES ('PHIL','YES', (to_date('2010/01/05 08:00:00', 'yyyy/mm/dd hh24:mi:ss'))),
VALUES ('PHIL','NO', (to_date('2010/02/01 08:00:00', 'yyyy/mm/dd hh24:mi:ss'))),
VALUES ('PHIL','NO', (to_date('2010/03/01 08:00:00', 'yyyy/mm/dd hh24:mi:ss'))),
VALUES ('NIKI','YES', (to_date('2010/01/01 08:00:00', 'yyyy/mm/dd hh24:mi:ss'))),
VALUES ('NIKI','YES', (to_date('2010/01/01 08:00:00', 'yyyy/mm/dd hh24:mi:ss'))),
VALUES ('NIKI','YES', (to_date('2010/01/01 08:00:00', 'yyyy/mm/dd hh24:mi:ss'))),
VALUES ('NIKI','NO', (to_date('2010/01/01 08:00:00', 'yyyy/mm/dd hh24:mi:ss'))),
VALUES ('NIKI','NO', (to_date('2010/01/01 08:00:00', 'yyyy/mm/dd hh24:mi:ss'))),
VALUES ('NIKI','NO', (to_date('2010/01/01 08:00:00', 'yyyy/mm/dd hh24:mi:ss'))),
VALUES ('NIKI','NO', (to_date('2010/01/01 08:00:00', 'yyyy/mm/dd hh24:mi:ss')))Phil3061 wrote:
I need to add that number back into the infractiondate column.Well, in general you need to use UPDATE or better MERGE. Howebver, your data sample does not show any rollofs:
SQL> SELECT * FROM M_ATSCHUNK;
EMPLOYEE ROL INFRACTIO
PHIL YES 01-JAN-10
PHIL YES 02-JAN-10
PHIL YES 03-JAN-10
PHIL YES 04-JAN-10
PHIL YES 05-JAN-10
PHIL NO 01-FEB-10
PHIL NO 01-MAR-10
NIKI YES 01-JAN-10
NIKI YES 01-JAN-10
NIKI YES 01-JAN-10
NIKI NO 01-JAN-10
EMPLOYEE ROL INFRACTIO
NIKI NO 01-JAN-10
NIKI NO 01-JAN-10
NIKI NO 01-JAN-10
14 rows selected.
SQL> WITH group_by_4_column_results AS
2 (SELECT m_atschunk.employee AS employee,
3 SUM(CASE
4 WHEN
5 M_ATSCHUNK.rolloffDaysCount = '108545043' AND m_atschunk.infractiondate BETWEEN SYSDATE - 365 AND SYSDATE THEN 1 ELSE 0 END) as
rolloffs,
6 M_ATSCHUNK.INFRACTIONDATE + 365 as infractionDate
7 FROM M_ATSCHUNK
8 group by employee, infractionDate, rolloffDaysCount
9 )
10 SELECT g4.*,
11 SUM (rolloffs) OVER (PARTITION BY employee) AS total_rolloffs
12 FROM group_by_4_column_results g4
13 /
EMPLOYEE ROLLOFFS INFRACTIO TOTAL_ROLLOFFS
NIKI 0 01-JAN-11 0
NIKI 0 01-JAN-11 0
PHIL 0 01-JAN-11 0
PHIL 0 02-JAN-11 0
PHIL 0 03-JAN-11 0
PHIL 0 04-JAN-11 0
PHIL 0 05-JAN-11 0
PHIL 0 01-FEB-11 0
PHIL 0 01-MAR-11 0
9 rows selected.
SQL> So adjust data sample and based on it tell us what are the expected results.
SY.
Maybe you are looking for
-
Impact of "IR" and "GR-BasedIV" indicators at P/O lines on Account Postings
Hi, Can anyone advise on the above and which where can i find/configure such relation in MM? Thanks
-
Where can i find a e-book PS lightroom with indonesian language?
I want to learn a lot about PS Lightroom, where I can download the Indonesian language tutorial book, because I am from Indonesia, so it's easy and familiar to me. oiya, please visit my post about seandainya saya menjadi anggota DPD RI
-
Microsoft Notebook Wireless Mouse 6000 bluetooth issues.
Ok, I bought the microsoft mouse to free up usb ports because I assumed you could use bluetooth for the device as apposed to the receiver it comes with, but I cannot figure out how to get it to work without the receiver. Can you just use Macs bluetoo
-
WDRuntimeException with adobe form under CE 7.1
Hi all, i am new to CE7.1 and i would like to do a simple hello world adobe form web dynpro java app. like in nw7.0, i create a interactive component, bind a Binary type to "pdfSource", open up LiveCycle 7.1 to put a static text "hello world" into th
-
Splitting BOXI infrastructure into two
Hi, Our organisation is splitting into two. We currently have two clusted servers A and B and wish to assign one to each of the new organisations. If I tried the following would it work ? 1. Remove Server B from the cluster. 2. Create a new database