calculate an average for each record
Hellowhat I want is: I have a table
SCHOOLBOY (id, first_name, last_name,...)
and another table
BRANDS (id, schoolboy_id, discipline_id, mark, mark_type). a schoolboy
on a discipline (math, for example), a schoolboy may have more points. I want to calculate the average mark, but for every schoolchild. then, for example I want to generate a report that contains the first name, the family name of the schoolboy and nearby, the average of the marks.
How can I calculate the average of all brands for every schoolchild ?
Thank you!
Edited by: Roger22 06.06.2009 at 01:43
Maybe something like:
SELECT first_name, last_name, b1.avg_mark
FROM schoolboys a1, ( SELECT schoolboy_id, AVG (mark) avg_mark
FROM marks
WHERE discipline_id = 4 -- specify whatever discipline_id you want
GROUP BY schoolboy_id) b1
WHERE a1.id = b1.schoolboy_id
/
Kind regards
JO
Edit: Corrected the Code tags
Tags: Database
Similar Questions
-
How to calculate an average for each quarter in a year
Hello world
I have a table that stores all the unit tests for the data. I'm figuring avg unit tests that have been recorded by quarter in one year
I tried with avg and the meter, but I'm sure that the results returned are not perfect
Help me in this scenario.
Thank you
Sriksuser10699584 wrote:
so if there are 10 unit tests then the avg is 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10/10
It is a weird way to definig average. Anyway, why:
2005-2 Q 5 2.5
According to your package:
(1 + 2 + 3 + 4 + 5) / 5 = 3
not 2.5. I'll assume that it's a typo. Now based on Mathematics:
1 + 2 + 3 +... + n = (1 + n) * n / 2
The foregoing your 'average' would be:
(Count + 1 / 2)
Also, I suspect tc_vts column data type is DATE, if so:
select to_char(tc_vts,'YYYY-Q"Q"') "year-Quarter", count(*) "Total cases", (1 + count(*)) / 2 "Average of total cases" from Testcycl group by to_char(tc_vts,'YYYY-Q"Q"') order by "year-Quarter" /
SY.
-
Hi all! This code works great, it returns the average value for contragentid = 1. So correct result is LUAHPER = 14996837,94
But when I add the values for contragentid = 2 (see commented strings), my statement returns incorrect result LUAHPER = 5497801,81
How can I improve my code in order to calculate the average for each contragentid?
Edited by: 858774 14/06/2011 02:29with t as ( select to_date('12.03.2011','dd.mm.yyyy') as arcdate, 1 as contragentid,14275303.54 as luah, 214275303.54 as lusd from dual union all select to_date('14.03.2011','dd.mm.yyyy') as arcdate, 1 as contragentid,14275303.54 as luah, 214275303.54 as lusd from dual union all select to_date('15.03.2011','dd.mm.yyyy') as arcdate, 1 as contragentid,14275303.54 as luah, 214275303.54 as lusd from dual union all select to_date('16.03.2011','dd.mm.yyyy') as arcdate, 1 as contragentid,15274795.50 as luah, 215274795.50 as lusd from dual union all select to_date('17.03.2011','dd.mm.yyyy') as arcdate, 1 as contragentid,15431807.40 as luah, 215431807.40 as lusd from dual union all select to_date('18.03.2011','dd.mm.yyyy') as arcdate, 1 as contragentid,15480730.00 as luah, 215480730 as lusd from dual union all select to_date('21.03.2011','dd.mm.yyyy') as arcdate, 1 as contragentid,15480730.00 as luah, 215480730 as lusd from dual /*union all select to_date('12.03.2011','dd.mm.yyyy') as arcdate, 2 as contragentid,214275303.54 as luah, 214275303.54 as lusd from dual union all select to_date('14.03.2011','dd.mm.yyyy') as arcdate, 2 as contragentid,214275303.54 as luah, 214275303.54 as lusd from dual union all select to_date('15.03.2011','dd.mm.yyyy') as arcdate, 2 as contragentid,214275303.54 as luah, 214275303.54 as lusd from dual union all select to_date('16.03.2011','dd.mm.yyyy') as arcdate, 2 as contragentid,215274795.50 as luah, 215274795.50 as lusd from dual union all select to_date('17.03.2011','dd.mm.yyyy') as arcdate, 2 as contragentid,215431807.40 as luah, 215431807.40 as lusd from dual union all select to_date('18.03.2011','dd.mm.yyyy') as arcdate, 2 as contragentid,215480730 as luah, 215480730 as lusd from dual union all select to_date('21.03.2011','dd.mm.yyyy') as arcdate, 2 as contragentid,215480730 as luah, 215480730 as lusd from dual*/ ) select contragentid, sum(luahper) / cnt as luahper from ( select contragentid, (lead(arcdate,1,date '2011-03-20' + 1) over(order by arcdate) - arcdate) * luah luahper, date '2011-03-20' - date '2011-03-13' + 1 cnt from ( select arcdate, contragentid, luah, lusd from t where arcdate > date '2011-03-13' and arcdate <= date '2011-03-20' union all select greatest(arcdate,date '2011-03-13'), contragentid, luah, lusd from t where arcdate = (select max(arcdate) from t where arcdate <= date '2011-03-13') ) ) where contragentid = 1 group by contragentid, cnt
Hello
858774 wrote:
But when I add the values for contragentid = 2 (see commented strings), my statement returns incorrect result LUAHPER = 5497801,81I guess that's because you don't join and partition on contragentid.
This appears to do:Scott@my10g SQL>/ CONTRAGENTID LUAHPER ------------ ---------- 1 14996837.9 Scott@my10g SQL>l 1 with t as ( 2 select to_date('12.03.2011','dd.mm.yyyy') as arcdate, 1 as contragentid,14275303.54 as luah, 214275303.54 as lusd from dual 3 union all 4 select to_date('14.03.2011','dd.mm.yyyy') as arcdate, 1 as contragentid,14275303.54 as luah, 214275303.54 as lusd from dual 5 union all 6 select to_date('15.03.2011','dd.mm.yyyy') as arcdate, 1 as contragentid,14275303.54 as luah, 214275303.54 as lusd from dual 7 union all 8 select to_date('16.03.2011','dd.mm.yyyy') as arcdate, 1 as contragentid,15274795.50 as luah, 215274795.50 as lusd from dual 9 union all 10 select to_date('17.03.2011','dd.mm.yyyy') as arcdate, 1 as contragentid,15431807.40 as luah, 215431807.40 as lusd from dual 11 union all 12 select to_date('18.03.2011','dd.mm.yyyy') as arcdate, 1 as contragentid,15480730.00 as luah, 215480730 as lusd from dual 13 union all 14 select to_date('21.03.2011','dd.mm.yyyy') as arcdate, 1 as contragentid,15480730.00 as luah, 215480730 as lusd from dual 15 -- 16 union all 17 select to_date('12.03.2011','dd.mm.yyyy') as arcdate, 2 as contragentid,214275303.54 as luah, 214275303.54 as lusd from dual 18 union all 19 select to_date('14.03.2011','dd.mm.yyyy') as arcdate, 2 as contragentid,214275303.54 as luah, 214275303.54 as lusd from dual 20 union all 21 select to_date('15.03.2011','dd.mm.yyyy') as arcdate, 2 as contragentid,214275303.54 as luah, 214275303.54 as lusd from dual 22 union all 23 select to_date('16.03.2011','dd.mm.yyyy') as arcdate, 2 as contragentid,215274795.50 as luah, 215274795.50 as lusd from dual 24 union all 25 select to_date('17.03.2011','dd.mm.yyyy') as arcdate, 2 as contragentid,215431807.40 as luah, 215431807.40 as lusd from dual 26 union all 27 select to_date('18.03.2011','dd.mm.yyyy') as arcdate, 2 as contragentid,215480730 as luah, 215480730 as lusd from dual 28 union all 29 select to_date('21.03.2011','dd.mm.yyyy') as arcdate, 2 as contragentid,215480730 as luah, 215480730 as lusd from dual 30 -- 31 ) 32 select contragentid, sum(luahper) / cnt as luahper 33 from ( 34 select contragentid, (lead(arcdate,1,date '2011-03-20' + 1) over(partition by contragentid order by arcdate) - arcdate) * luah luahper, 35 date '2011-03-20' - date '2011-03-13' + 1 cnt 36 from ( 37 select arcdate, contragentid, luah, lusd 38 from 39 t 40 where arcdate > date '2011-03-13' 41 and arcdate <= date '2011-03-20' 42 union all 43 select greatest(arcdate,date '2011-03-13'), 44 contragentid, luah, lusd 45 from 46 t 47 where arcdate = (select max(arcdate) from 48 t t2 49 where arcdate <= date '2011-03-13' 50 and t.contragentid=t2.contragentid) 51 ) ) 52 where contragentid = 1 53* group by contragentid, cnt Scott@my10g SQL>/ CONTRAGENTID LUAHPER ------------ ---------- 1 14996837.9
858774 wrote: How can I improve my code in order to calculate the average for each contragentid?
When I remove the 'where contragentid = 1' seems to do with above query:
Scott@my10g SQL>/ CONTRAGENTID LUAHPER ------------ ---------- 2 214996838 1 14996837.9
-
generation of XML for each record
I have a table db with a few thousand records in it. I need to generate an xml file for each record so that it can power a search machine.
Can someone help me with this? I could not get it. Here is the example of table.
create table test_xml)
number of U_ID
title varchar2 (500),
VARCHAR2 (500) keywords.
Description varchar2 (500),
VARCHAR2 (500) of the user.
e-mail varchar2 (500),
initiator_function varchar2 (500),
function_impacted varchar2 (500),
old_request_num varchar2 (500),
project_region varchar2 (500)
);
insert into test_xml values (1, "Heading1 test", "blah bla1", "test 123 ', 1234567',' [email protected]', 'test init funct', 'funct hit test', '55556677', 'abc' ');
insert into test_xml values (2, 'Title2 test', 'blah bla2', ' test 1232', 1234522',' [email protected]', 'test init funct2 ',' test power supply impacted2', ' 55556679', 'abcccs' ");
the end result is an XML for each record in this format.
<? XML version = "1.0" encoding = "utf-8"? >
<! DOCTYPE gsafeed PUBLIC "-//Google//DTD GSA RSS / / IN" "" > "".
< gsafeed >
< header >
< datasource > ID 1 < / datasource >
< feedtype > full < / feedtype >
< / header >
<>Group
" < analysis record immediately = 'true' url = ' http://test.com/SearchResult.php?id=1 "action = 'Add' mimetype =" text/html"lock ="true"> "
< content > <! [CDATA]
< html >
< head >
Heading1 test < title > < /title >
< meta name = "Keywords" content = "bla bla1" / >
< name meta = "description" content = "testing 123" / >
< name meta = "user" content = "1234567" / >
" < name meta = 'EMAIL' content = ' [email protected] " />
< name meta = "Source" content = "1" / >
< / head >
< body >
< p > user: 1234567
< p > EMAIL: bob . [email protected]
< p > INITIATOR_FUNCTION: test init funct
< p > FUNCTION_IMPACTED: test hit funct
< p > OLD_REQUEST_NUM: 555566777
< p > PROJECT_REGION: abc
< /p > < / body >
< / html >
[]] > < / content / >
< / recording >
< / Group >
< / gsafeed >
Thanks for any help.
I'd use SQL/XML functions, more rapid way to generate XML from relational data data.
Something like the following should you get.
It displays a document (such as a CLOB) per line in the base table:
with html_content as ( select xmlcdata( xmlserialize(document xmlelement("html" , xmlelement("head" , xmlelement("title", t.title) , xmlelement("meta", xmlattributes('Keywords' as "name", t.keywords as "content")) , xmlelement("meta", xmlattributes('description' as "name", t.description as "content")) , xmlelement("meta", xmlattributes('user' as "name", t.user_ as "content")) , xmlelement("meta", xmlattributes('EMAIL' as "name", t.email as "content")) , xmlelement("meta", xmlattributes('Source' as "name", t.u_id as "content")) -- ?? ) , xmlelement("body" , xmlelement("p", 'EMAIL: '||t.email) , xmlelement("p", 'INITIATOR_FUNCTION: '||t.initiator_function) , xmlelement("p", 'FUNCTION_IMPACTED: '||t.function_impacted) , xmlelement("p", 'OLD_REQUEST_NUM: '||t.old_request_num) , xmlelement("p", 'PROJECT_REGION: '||t.project_region) ) ) indent ) ) as content from test_xml t ) select '' || '' || xmlserialize(document xmlelement("gsafeed" , xmlelement("header" , xmlelement("datasource", 'ID 1') , xmlelement("feedtype", 'full') ) , xmlelement("group" , xmlelement("record" , xmlattributes( 'true' as "crawl-immediately" , 'http://test.com/searchresult.php?ID=1' as "url" , 'add' as "action" , 'text/html' as "mimetype" , 'true' as "lock" ) , xmlelement("content", html.content) ) ) ) indent ) from html_content html ;
NB: indent option is to print only, you can remove it if you don't need.
-
Hallo,
I need to create a page that displays the records of a VO, but I would not use a table.
Instead, I would like to display a form for each record to be displayed.
Forms must appear one above the other and each form should have 2 buttons: one to remove the file/form itself and one to add a new file/form.
When you press the button Add a new empty form should be dynamically added to the page (so that the user can fill) and created related record.
When REMOVE button is pressed the form (which contains the operated button) should be disappear and the record shuould be deleted.
Creations and destruction must be applied only if the user clicks a button on CONFIRMATION / COMMIT.
Maybe this http://digilander.libero.it/flattit82/OTN_FILES/MultiFormPage.png picture can help to understand what I want to do.
You kindly help me?
Thank you
Federico
Hi Federico
I was saying that your page layout can be achieved using af: table
See this image:
This provision is af:table (I think same as yours), just add a column in the table and put all the fields in this column then correct layout allows to design as a provision on the form or group layouts
I'm not saying it's the best approach, but you can try this
Thank you
-
Hi all
I have a requirement where I need to get all the records, for each record in double, I need to get a single column with null or 0.
create table a1
(
Identification number,
VARCHAR2 (100), the point
part varchar2 (100));
Insert into a1
values (1, 'ABC', 'A1');
Insert into a1
values (2, 'DEF', 'A2');
TABLE A
PART ITEM ID
1 ABC A1
1 ABC A1
1 ABC A1
DEF 2 A2
DEF 2 A2
3 DEF A2
O/P
PART ITEM ID
1 ABC A1
1 ABC 0
1 ABC 0
DEF 2 A2
2 DEF 0
3 DEF 0
Thanks in advance.
Thanks for your help FrankKalush...
This one will work.
WITH got_r_num AS
(
SELECT NVL (a1.id, a1.id) as id
NVL (a1.item, a1.item) AS element
NVL (a1.part, a1.part) IN the framework
a1.id AS a_id
ROW_NUMBER () OVER (PARTITION BY a1.id
ORDER BY NULL
) AS r_num
BY the a1
)
SELECT id
element
CASE
WHEN a_id IS NOT NULL
AND r_num = 1
THEN part
ELSE ' 0'
END in the framework
OF got_r_num
;
-
Create id, id of the update with the date for each record
Hello
Please give me brief idea or document for this concept:
I need to create id, date, update id, updated for each record inserted or updated in the database (multiple tables).
(1) how the user id can be obtained?
(2) is it better if I use views instead of tables for this?
(3) is it possible for each record?
Please show me the full scenario. a piece of code can also be useful.
Thanks in advance.http://psoug.org/reference/table_trigger.html
Concerning
Biju -
number for each record that is extracted (query)
Hello
I want to what a number for each record that is retrieved from the recording which was released by this query
For example
For the first line/recored
Number generated, ksnumber, date
1, gg111 11/05/05
2, oo235 06/12/05
the query returned 2 records 1 and 2 are the number generated by this code.
In addition if it is built in function, where in the code can I put it?
< cfquery = name "gelov datasource ="kl90">"
SELECT
-------------------------------------------
Of
--------------------------------
WHERE
-----------------------------------------
-----------------------------------------------------
ORDER BY
< cfswitch expression = "#Form.orderBy #" >
< cfks value = "KSNUMBER" >
KS. KS_NBR
< / cfks >
< cfks value = "DATECREATED" >
KS. KREATDAT
< / cfks >
< / cfswitch >
< / cfquery >
<! - report html - >
< cfswitch expression = "#Form.outputFormat #" >
< cfks value = "HTML" >
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional / / IN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
"< html xmlns =" http://www.w3.org/1999/xhtml "> "
< head >
< meta http-equiv = "Content-Type" content = text/html"; charset = iso-8859-1 "/ >"
Report Kss Ctwye < title > < / title >
< / head >
< style type = "text/css" >
table {}
do-family: Arial, Helvetica, without serif.
do-size: 10px;
}
TD {}
do-family: Arial, Helvetica, without serif.
do-size: 10px;
}
Th {}
do-family: Arial, Helvetica, without serif.
do-size: 10px;
}
H2 {}
do-family: Arial, Helvetica, without serif.
do-size: 12px;
}
H3 {}
do-family: Arial, Helvetica, without serif.
font-size: 13px;
}
< / style >
< body >
< cfoutput >
< table border = "0" cellpadding = "3" cellspacing = "0" >
< b >
< td align = "center" >
Kss Ctwye report < h3 > < / h3 > < br > < br > < table >
< /tr >
< b >
< td align = "center" >
< / h2 > report returned #getCtwyeKss.RecordCount # entries < / h2 > < table >
< /tr >
< b >
< td >
< table border = "1" cellpadding = "2" cellspacing = "0" >
< b >
< td width = "160" > Ks number < table >
Date of creation of the < td > < table >
<!-< class = 'dataField' td > address < table >
< class td 'dataField' = > Type < table >
< class td 'dataField' = >-> Description < table >
< /tr >
< cfloop query = "getCtwyeKss" >
< tr bgcolor = "< cfif currentrow mod 2 > F8F8FF < cfelse > WHITE < / cfif >" >
< td > #KS_NBR # < table >
< td > #dateformat(KREATDAT,"mm/dd/yyyy") # < table >
< /tr >
< / cfloop >
< /table >
< table >
< /tr >
< /table >
< / BODY >
< / HTML >
< / cfoutput >
< / cfks >
< cfks value = "CSV" >
< NAME CFHEADER = "Content-Disposition" VALUE = "attachment; filename = ctwye.csv">
< cfcontent type = "application/msexcel" > "Ks number", "Date of creation".
< cfoutput query = "getCtwyeKss" > #ltrim (KS_NBR) #, "#dateformat(KREATDAT,"mm/dd/yyyy")" # "< tr #IIF (getCtwyeKss.CurrentRow MOD 2, OF (»), DE('backgroundColor="##999"')) # >"
<!-< tr bgcolor = "< cfif currentrow mod 2 > # 808080 < cfelse > ##ffffff < / cfif >" >-->
< / cfoutput >
< / cfks >
< / cfswitch >
is not a Coldfusion tag. Use instead. The following code prints line numbers
Select ksnumber, date
from yourTable
#currentrow #, #ksnumber #, #date #.
-
Filtering and calculate the averages for subsets of a table
I have a 2D picture that comes out of a loop, and I need to calculate the average of the subsets corresponding to iterations 0-9, 10-19, etc... In addition, I need to filter the values above and below acceptable limits before calculating the average. Any suggestions for how to address the issue?
Here are examples of code does exactly that. This post, looks like you need an upper limit as well. I'll leave that as an exercise for you.
-
Media Center is Reporting insufficient disk space for each record programmed
Since the upgrade to Windows 8 Media Center reports that there is not enough disk space for each scheduled TV recording despite there are currently more than 1 TB of free space. The programs record very well, but it is impossible to tell when it is a genuine issue (for example, a program conflict) as an indicator of each scheduled recording is also problematic.
There is a simple solution to this in Media Center as an administrator (which implies that there may be a problem of permissions with Windows 8). However, I also use an XBox 360 as an Extender and there is no known method to apply this workaround to an Extender then it continues to be a lack of disk space for each unique record.
I tried completely removing the recorded TV folder, followed by a reboot to allow Media Center services recreate the folder, but it does not solve the problem. I checked all the settings and Media Center reports that it has enough free space to save more than 400 hours of television, but he's still complaining lack of disk space for each individual scheduled recording.
Any ideas?
I found a solution that worked for me on another thread.
See the post from Steve Scoltock on executing a recovery job in the computer management application, here:http://answers.Microsoft.com/en-us/Windows/Forum/windows_8-Winapps/Windows-8-TV-recording-problem-with-Windows-Media/f9695954-246F-4C59-8d1b-3729a81feee9?page=1&TM=1352456456164It worked for me. I hope this guy helps too. -
Activate auto sequence number for each records
Hi team,
I try to create a project in DRM for details. So I need a Unique ID (ID project) to create when I enter each record on the lower level. Basically, I need an Auto activated sequence so that whenever I have create a folder I get an Auto-generated number that I can use as a Unique ID. Please advice on how this can be validated in DRM.
Thank you
Roshi
Please go through the below document as a solution step by step to activate AutoID
http://blog.checkpointllc.com/Auto-ID-in-DRM-no-problem
Thank you
~ KKT ~.
-
My input XML file is...
I get this XML using file adapter...
<? XML version = "1.0" encoding = "UTF-8"? >
-< root xmlns:ns2 = "http://www.w3.org/2001/XMLSchema" >
-< ns2:ReceiptBatch >
< ns2:FileID > "99999" < / ns2:FileID >
< ns2:Warehouse > in THE < / ns2:Warehouse >
'L' < ns2:Revision > < / ns2:Revision >
< ns2:DocID > A4 < / ns2:DocID >
-< ns2:Receipt >
< ns2:DeliveryNo > 123 - OP < / ns2:DeliveryNo >
< ns2:ProcessDate > 112138 < / ns2:ProcessDate >
< ns2:ContainerNo > 98765 < / ns2:ContainerNo >
< ns2:Instructions > TREKAU < / ns2:Instructions >
< ns2:ReceiptType > 1 < / ns2:ReceiptType >
< ns2:SuppCustCode > 111 < / ns2:SuppCustCode >
TREK-Cycle < ns2:SuppCustName > < / ns2:SuppCustName >
-< ns2:ReceiptDetails >
< ns2:Line > 1 < / ns2:Line >
< ns2:ProductCode > 1000 < / ns2:ProductCode >
< ns2:QuantityAdvised > 1 < / ns2:QuantityAdvised >
< ns2:QuantityReceived > 1 < / ns2:QuantityReceived >
< / ns2:ReceiptDetails >
-< ns2:ReceiptDetails >
< ns2:Line > 2 < / ns2:Line >
< ns2:ProductCode > 2000 < / ns2:ProductCode >
< ns2:QuantityAdvised > 2 < / ns2:QuantityAdvised >
< ns2:QuantityReceived > 2 < / ns2:QuantityReceived >
< / ns2:ReceiptDetails >
-< ns2:ReceiptDetails >
< ns2:Line > 3 < / ns2:Line >
< ns2:ProductCode > 2000 < / ns2:ProductCode >
< ns2:QuantityAdvised > 3 < / ns2:QuantityAdvised >
< ns2:QuantityReceived > 3 < / ns2:QuantityReceived >
< / ns2:ReceiptDetails >
< / ns2:Receipt >
< / ns2:ReceiptBatch >
< / root >
There are 2 tables in the database.
Table 1 = T1743512
Table 2 = T2743002
table - structure
T1743512-
DOCO KCOO DTCO LNID LNIX LITM NOTICE USR JOBN UPMJ PID'M CKNU UREC
123 00026 1 1 1000 1 1 123 - OP OP
124 00026 1 1 1000 1 1 124 - OP OP
123 00026 2 2 1000 2 2 123 - OP OP
123 00026 3 3 1000 3 2 123 - OP OP
Things to do are:--
1. Research Notice T1743512 (table) with the following keys:
1.T1743512. CKNU = < DeliveryNo > XML
2.T1743512. LNIX = XML < row >
II. write a record in the T2743002 table for each < RecieptDetails >. (See map below)
Mapping of the records in the table T2743002 to < ReceiptDetails >
EDU - "SABSSV".
EDBT - < EDBT > (the same for all records)
EDTN - < DeliveryNo > (from the section < reception > XML)
EDLN - < row > (from < ReceiptDetails > section in XML format)
EDSP - white
DOCO - white
DCTO - white
KCOO - white
LNID - white
LITM - < ProductCode > < ReceiptDetails > section
UORG - < QuantityAdvised > < ReceiptDetails > section
UREC - < QuantityReceived > < ReceiptDetails > section
USER - "SABSSV".
JOBN - "SOA - 3PL".
PID - 'PO-ENTRANTS ".
UPMJ - current Date Julian
- Hour current HHMMSS
Please suggest the solution.
Published by: Prashant_AP on June 22, 2012 12:24 AMHello
Solution by using a loop in BPEL;
1 count the number of nodes for ReceiptDetails.
2 create a counter for loop through each node ReceiptDetails. Use a while loop in BPEL
3 search T1743512 (table) with DeliveryNo and the line. Make sure that you select the correct line from the ReceiptDetails node element node. This can be done using the counter example of xpatch ns2:ReceiptBatch / ns2:Receipt / ns2:ReceiptDetails [counter] / ns2:Line. Please use the DB adapter.
I guess that the DeliveryNo can only appear once in the document following your example.
4. for each receiptDetails you write a record in table too T2743002. Please use the DB adapter.
5. Since the time increment the counter. This is to ensure that the while loop stops at the point where the counter is greater then the number of nodes to ReceiptDetails.I think a better solution is to make the loop in PL/SQL. It will be faster. You specify an input of type of collection in your pl/sql package parameter. Assign all items receiptDetails and DeliverNo line to the PL/SQL package. Within PL/SQL unravel you the closure. With a little luck, you have the T2743002 in the same schema to create the record too. Otherwise create synonyms of the database or database links.
Good luck
Thank you
Sander
-
Several records displayed on the form to a time-2 lines for each record
Hello
I have a Web in which I want to display to 8 records at the time, in the data block, I've specified 8 as value "number of records".
However, the record includes too many fields to display on 1 vertical line, I wish so to divide the fields into two separate lines, there will always be 8 folders, but each in two lines.
How do I do that?
I use form 10g. The block is a block of database using QUERY CLAUSE, and the canvas is stacked.
Thank youSandy,
You will need set the 'Distance between Records' property for each item in the block for multiple registration. This will increase the space between the lines, so you can stack them in two rows. Unfortunately, you cannot set this property to the block - so you must set for each display element.Hope this helps,
Craig B-)If someone useful or appropriate, please mark accordingly.
-
Determine a value for each record for the whole group
< < Sorry I pasted erroneous results earlier > >
Hello
I have a table (in production, join the many tables, but for simplicity, I created a table), which has a few related accounts grouped by ACCT_GRP_ID I have to write a SQL (not a PL/SQL), who should have all columns of this table and an extra column "FLAG". For GA_CD = BBC, FLAG must have a value of 'No Show', if the APP_DT of at least a recording with the group is less than the current year also all the records in the group will have a value of 'Show '. For the record no BBC FLAG must always be 'Show '.
DDLS
{code}
CREATE TABLE ACCOUNTS
(NUMBER OF ACCT_GRP_ID,
GA_CD VARCHAR2 (10),
AGNT_NAME VARCHAR2 (50).
NUMBER OF CASE_NUM
NUMBER OF FUND_AMT
DATE OF APP_DT,
STATUS VARCHAR2 (10));
INSERT INTO ACCOUNT VALUES (1, 'BBC', 'SAMANTHA, JOSE, 12345, 234.33, 2 AUG 2008', ' PLACED');
INSERT INTO ACCOUNT VALUES (1, 'BBC', 'SAMANTHA, JOSE, 12346, 331,13, 24 APR 2009', ' PLACED');
INSERT INTO ACCOUNT VALUES (1, 'BBC', 'SAMANTHA, JOSE, 12347, 201,27, 13 FEB 2009', ' PLACED');
INSERT INTO ACCOUNT VALUES (2, 'BBC', ' MARK, ROSS, 12348, 98.12, 31 MAY 2009', 'PLACE' ");
INSERT INTO ACCOUNT VALUES (2, 'BBC', ' MARK, ROSS, 12349, 121.00, 25 JUNE 2009', 'PLACE' ");
INSERT INTO ACCOUNT VALUES (2, 'BBC', 'BRAND, ROSS, 12350, 11.00, 27 JUNE 2009', 'CLOSED');
INSERT INTO ACCOUNT VALUES (3, 'BBC', "RAJ MALIK", 12351, 89.00, 31 DEC 2008', 'PLACED');
INSERT INTO ACCOUNT VALUES (3, 'BBC', "RAJ MALIK", 12352, 22.00, 26 OCT 2008', 'PLACED');
INSERT INTO ACCOUNT VALUES (4, 'BBC', 'SHANE, WILLS', 12353, 443.00, 7 JUNE 2009', 'PLACE');
INSERT INTO ACCOUNT VALUES (5, 'BBC', 'JANE, WALLACE, 12354, 74.00, 17 JAN 2009', ' PLACED');
INSERT INTO ACCOUNT VALUES (NULL, 'BBC', 'ROSY, BETH', 12355, 124.00, 21 MAR 2009', 'PLACE');
INSERT INTO ACCOUNT VALUES (NULL, 'STAR', 'TINA, WZWICK', 22330, 89.00, 31 DEC 2008', 'PLACED');
INSERT INTO ACCOUNT VALUES (NULL, 'STAR', 'YANA, KORVIN', 27351, 22.00, 26 OCT 2008', 'PLACED');
INSERT INTO ACCOUNT VALUES (NULL, 'STAR', 'SARA, YUI', 22352, 443.00, 7 JUNE 2009', 'PLACE');
INSERT INTO ACCOUNT VALUES (NULL, 'STAR', 'MIKE, TROY, 22453, 74.00, 17 JAN 2009', ' PLACED');
COMMIT;
{code}
Required result:
{code}
APP_DT GA_CD AGNT_NAME STATE BOITE_ FUND_ ACCT_ INDICATOR
AMT NUM GRP_ID
1 SAMANTHA, JOSE PLACE 12347 201.27 BBC 13/02/2009 no show
1 SAMANTHA, JOSE PLACE 12346 331.13 BBC 24/04/2009 no show
1 SAMANTHA, JOSE PLACE 12345 234.33 BBC 08/02/2008 no show
MD2 BBC BRAND, ROSS CLOSED 12350 11 6/27/2009 see the
MD2 BBC BRAND, ROSS PLACED 12349 121 6/25/2009 see the
2 BRAND of BBC, ROSS PLACE 12348 98.12 show of 31/05/2009
3 BBC RAJ MALIK not PLACED 12352 22 10/26/2008 no show
3 BBC RAJ MALIK not PLACED 12351 89 12/31/2008 no show
4 BBC SHANE, WILLS PLACE 12353 443 6/7/2009 see the
5 BBC JANE, WALLACE PLACE 12354 74 1/17/2009 see the
STARS of MIKE, TROY PLACED 22453 74 1/17/2009 see the
See the BBC ROSE, BETH PLACED 12355 124 3/21/2009
STAR SARA, YUI PLACED 22352 443 6/7/2009 see the
TINA, WZWICK STAR PLACED 22330 89 12/31/2008 see the
YANA STAR, KORVIN PLACED 27351 22 10/26/2008 see the
{code}
As in the results Group 1 has a record with the date of 2008 for the whole group getting 'No Show'. Group 2 has all the records this year, so he gets the 'Show '.
Help, please!
Published by: Kuul13 on June 25, 2009 13:31
Published by: Kuul13 on June 25, 2009 13:43
I think I'm really having a BAD BAD day... Sorry again... I don't need the domain TOT_FUND_AMT...Hello
Thanks for posting the DDL and DML statements. This helps a lot.
I don't understand the output, however. Do you want to really two rows of output for each row in the table? The tot_fund_amt is copied from somewhere else? More important still, the results do not include the new flag column. Isn't the point of all of this question? It's good to describe how the indicator is calculated, but you have to show, too.
I think you want analytical MIN function to find the first app_dt in each group, like this:
SELECT a.* , CASE WHEN ga_cd = 'BBC' AND MIN (app_dt) OVER ( PARTITION BY ga_cd , acct_grp_id ) < TRUNC (SYSDATE, 'YYYY') THEN 'No Show' ELSE 'Show' END AS flag FROM accounts a ;
Output:
. ACCT _GRP GA CASE FUND _ID _CD AGNT_NAME _NUM _AMT APP_DT STATUS FLAG ------ ---- --------------- ------ -------- ---------- ------ ------- 1 BBC SAMANTHA, JOSE 12345 234.33 08/02/2008 PLACED No Show 1 BBC SAMANTHA, JOSE 12346 331.13 04/24/2009 PLACED No Show 1 BBC SAMANTHA, JOSE 12347 201.27 02/13/2009 PLACED No Show 2 BBC MARK, ROSS 12348 98.12 05/31/2009 PLACED Show 2 BBC MARK, ROSS 12349 121.00 06/25/2009 PLACED Show 2 BBC MARK, ROSS 12350 11.00 06/27/2009 CLOSED Show 3 BBC RAJ, MALIK 12351 89.00 12/31/2008 PLACED No Show 3 BBC RAJ, MALIK 12352 22.00 10/26/2008 PLACED No Show 4 BBC SHANE, WILLS 12353 443.00 06/07/2009 PLACED Show 5 BBC JANE, WALLACE 12354 74.00 01/17/2009 PLACED Show BBC ROSY, BETH 12355 124.00 03/21/2009 PLACED Show STAR TINA, WZWICK 22330 89.00 12/31/2008 PLACED Show STAR SARA, YUI 22352 443.00 06/07/2009 PLACED Show STAR MIKE, TROY 22453 74.00 01/17/2009 PLACED Show STAR YANA, KORVIN 27351 22.00 10/26/2008 PLACED Show
Note that the NULL acct_grp_id is a group. PARTITION BY acct_grp_id is of course necessary, but we must also, PARTITION BY ga_cd all non-BBC lines will be included in this group. In other words, we are unwilling reported as 'No Show', all ROSY just because TINA or JANA had an early app_dt.
-
Get the Parent for each record in the child
Dear Experts,
I have a table that contains the parent and child information. I need to make a request to get the parents of each book of the child table. I tried to write the query but does not get the expected results. Please help me.
Table: relationship
Parent of the child
102 101
103 102
104 103
106 105
107 106
109 108
110 109
Output:
Expected child
102 101
103 102; 101
104 103, 102, 101
106 105
107 106; 105
109 108
110 109
Thank you very much
Hello
MU * 443499 * TR wrote:
Dear Experts,
I have a table that contains the parent and child information. I need to make a request to get the parents of each book of the child table. I tried to write the query but does not get the expected results. Please help me.
Table: relationship
Parent of the child
102 101
103 102
104 103
106 105
107 106
109 108
110 109
Output:
Expected child
102 101
103 102; 101
104 103, 102, 101
106 105
107 106; 105
109 108
110 109
Thank you very much
Why do you want to
Expected child
----- ---------------
110 109
Instead of
Expected child
----- ---------------
110 109; 108
?
You may want something like this:
CONNECT_BY_ROOT SELECT AS children
SYS_CONNECT_BY_PATH (parent, ';') AS expected_output
FROM table_x
WHERE CONNECT_BY_ISLEAF = 1
CONNECT BY child = parent PRIOR
;
If you would care to post CREATE TABLE and INSERT statements for your sample data, and then I could test this.
Maybe you are looking for
-
Windows 8.1, just upgraded to iTunes 12.5.1.21 in order to then get iOS 10. After having launched iTunes backup all of the artist, photo thumbnails have been replaced by an icon generic microphone. The few artists that have a picture in place are tho
-
Cup of text when printing pages
The print preview page shows it a page will print on two pages. However, when she actually prints, there is text missing between page 1 and page 2. It seems that everything is supposed to print at the bottom 2 inches of the page is simply ignored. Th
-
Laptop HP Pavillion G7: problems of sound after upgrade to win 10
I have upgraded to Windows Windows 8.1 10 yesterday (August 1, 2015). The update went well. However, there is no sound on my computer. The sound in the tray icon has a red x and not said: "no speakers or headphones connected," when I pass the mouse
-
Gateway requirements referring to the part of Id from step 2
Hello After posting part1 http://forums.NI.com/T5/NI-TestStand/Requierements-gateway-referencing-to-step-s-ID/TD-p/2271796 I have a few questions on NIRG futher. The referenceing to NI TestStand works pretty well now, especially if the sequencefile h
-
read and sort the values present in the .ini file
Hi all I have an .ini file in which a set of modules with that execution order is mentioned. I want to get all these values sorted in a table, so that I can proceed with the execution of each one in the order given. The list of the module in the .ini