Calculate percentage column based on 2 other columns
I have 2 fact colums. Those two columns are column_a=count distinct of all records and
column_b = count distinct of subset of records based on specific condition.
I am trying to get column_3 as = (column_b/column_a )* 100
These 2 columns comes from same physical tables but two different logical tables (I have different where condition for each)
Result is correct (100) when column_a = column_b however I am getting 0 when they are different
col_a col_b Percent
8 7 0 why not 87.5
1 1 100
27 23 0 why not 85.2
Hello,
Check your datatypes in your phyiscal layer, I've found if they are INT then %'s tend to get rounded to whole numbers.
Try setting them to float and report back if it works (or not !)
Cheers
Alastair
Similar Messages
-
How can I delete a column of numbers that are referenced in another column without deleting the other column?
select the column to delect by click in the column header
select the contextual menu for that column by clicking (and holding) the down arrow:
select "Delete Column" to remove the column: -
How to add a new column in between two other columns
I need to add a new column in between two other existing columns. Does anyone know how to do that? The ALTER statement adds the column at the end. Can someone give an example.
Thanks
Murali
nullThere is no simpler way of doing this because it is not strictly necessary: you can always see your data in the order you want simply by going SELECT col1, col2, col98, col4, etc. Thus the column order only matters when you execute SELECT * FROM...
If that really is important enough to you you'll have to drop and re-create the table, for which there are a number of different strategies.
Your final comment suggests that you don't retain your database build scripts. If you did then rebuilding your constraints would be painless. There is a lesson there. The good news is that if you have TOAD (download from www.quest.com) you can generate DDL scripts from your existing schema.
HTH, APC -
Populating a report column(Popup lov) based on the other column.
I have a report where a column that is a Popup Lov(Query based LOV) needs to be populate based on another column in the same report.
For example, if the column1 has query based lov select statment "select a,b,c from tab where d= *<<col2>>* ".
I would like to have a sql query based on the values of second report column. Any ideas are appreciated.
Regards,
madhuYou can do that only if you use apex_item. See this example as a reference:
http://apex.oracle.com/pls/otn/f?p=31517:176
In this example the second select list query depends on the first select list column value.
Denes Kubicek
http://deneskubicek.blogspot.com/
http://www.opal-consulting.de/training
http://apex.oracle.com/pls/otn/f?p=31517:1
------------------------------------------------------------------- -
Tableview - column color disaply based on comparing other column on the tab
Hi,
Can any one give me some idea about how to compare two columns of table on IF_HTMLB_TABLEVIEW_ITERATORRENDER_CELL_START ?. I have to compare the column 3 with column 4 and display the color on column 3. I am trying to do that on IF_HTMLB_TABLEVIEW_ITERATORRENDER_CELL_START but this is not working out. Any suggestion ?.Hi,
in IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START you only have the actual row in P_ROW_DATA_REF.
Either you make the the availabe as iterator's attribute when instantiating or you collect the row P_ROW_DATA_REF when in RENDER_CELL_START to a class attribute.
Regards,
Sebastian -
Filling a column with value from other columns
Hello all!
Suppose i have the following table:
TableA(col_one int, col_two int, result int);I want to insert value to col_one and col_two, and result will be filled with the multiplication product of col_one and col_two.
ok firstly i know this is very redundant way of storing data and generally should not be used, but one case when this might come in handy is when we want to store a total payment amount of product price and quantity. this can be useful since product price can change overtime and we need to record the data as the transaction happens to avoid change in total payment over time (as the price drops or rises).
now with the problem:
I tried this in mysql and it works:
INSERT INTO TableA (col_one, col_two, result) VALUES (30, 20, col_one * col_two);but not in oracle, which output the following error:
>
ora 00984 column not allowed here
any idea on how to do it in oracle?
thank you very much :)
ps, thank you for the fast replies on my previous topic.If the insert is done inside PL/SQL you can return the primary key for the row (assuming the table has a primary key?!?) and then update based on that key, but this still introduces two statements where a single statement can suffice.
Why are you thinking so complicated? ;-)
If it is done in PL/SQL the you can do this:
create procedure addRow(p_value1 number,p_value2 number) is
p_result number;
begin
p_result:=p_value1*p_value2;
insert into table1 (col_one,col_two,result) values(p_value1,p_value2,p_result);
commit;
end;If you want to do this automatically when someone inserts a row (without providing the result) you have to use an insert trigger.
Dim -
Alert message in javascript if drop down in 1 column is blank and other column is not blank
What I’m trying to do is have a java window alert pop up if the PNR column is blank and the BOM column is not blank on each row. I also put a cold fusion If statement around this javascript that the CN_Entry column in the Items table has to be an “N”. This code all actually works, but it only works on the row with the latest or newest item with an “N” in the CN_Entry column. I would like this to work on every row, so that if someone does this on any row, or multiple rows, this alert box will keep popping up until all the conditions are satisfied. What do I need to change to make this javascript work? Thanks.
<cfif CN_Entry EQ "N">
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function verify() {
var themessage = "Please enter ";
if (EditItem.PNR_Approval_Initials#ItemID#.selectedIndex == 0 && EditItem.BOM_Approval_Initials#ItemID#.selectedIndex > 0)
alert("You must enter some PNR initials for ECO #ECID_SPEC# Part Number: #Part_Number#");
EditItem.PNR_Approval_Initials#ItemID#.focus();
return (false);
else
document.EditItem.submit();
// End -->
</script>
</cfif>
AndyThe first thing you have to do is to remove the ColdFusion conditional logic. ColdFusion runs on the server. JS runs on the client.
The next thing is to call the function from an event that happens on the web page. form onsubmit seems like a good choice. -
Range partitioning on virtual column based on binary xmltype column
Alright, our DBA finally got around to upgrading to 11.2.0.2. Now I'm running into another issue:
CREATE TABLE USER.DI_D2
ID NUMBER(19, 0) NOT NULL ,
XML SYS.XMLTYPE ,
PRIMARY KEY ( ID )
XMLTYPE XML STORE AS SECUREFILE BINARY XML
VIRTUAL COLUMNS
ts AS (TO_TIMESTAMP(extractvalue(xml,'/d:d/c:dHeader/c:creationTime',
'xmlns:d="http://www.example.com/m/d/schema/di"
xmlns:c="http://www.example.com/m/schema/common"'),'YYYY-MM-DD"T"HH24:MI:SS'))
PARTITION BY RANGE (ts)
PARTITION d_p2012_07 VALUES LESS THAN (TO_DATE('1-8-2012','DD-MM-YYYY')),
PARTITION d_px VALUES LESS THAN (MAXVALUE)
);On our old 11.2.0.1 install this command works fine (tho due to other issues 11.2.0.1 doesn't work for our search queries)
On our 11.2.0.2 install, I get the following error:
Error at Command Line:10 Column:37
Error report:
SQL Error: ORA-14513: Partitiekolom mag niet van het gegevenstype object zijn.
14513. 00000 - "partitioning column may not be of object datatype"
*Cause: Partitioning column specified by the user was an object datatype
(object, REF, nested table, array) which is illegal.
*Action: Ensure that no partitioning column is an object datatype.Anyone know what's up with that? What changed between the 2 DB versions that could cause this to fail?Alright, seems that's just a display issue then.
Looking in user_lobs like suggested above gives
TABLE_NAME COLUMN_NAME SECUREFILE
DI_D XMLDATA YES I was opening the table in SQL Developer and then looking in the tab SQL (12th tab); with a XmlType table it seems to always show Basicfile even if it's actually a Securefile.
I'd like to use the suggested xmlcast/xmlquery solution, however it doesn't seem to play well with our custom timestamp format.
"CREATION_TIME" AS (XMLCAST(XMLQUERY('declare default element namespace "http://www.example.com/m/d/schema/i";declare namespace c="http://www.example.com/m/schema/common";/d/c:dHeader/c:creationTime' PASSING OBJECT_VALUE RETURNING CONTENT) AS TIMESTAMP))
Error at Command Line:1 Column:0
Error report:
SQL Error: ORA-54002: In de uitdrukking van een virtuele kolom kunnen alleen zuivere functies worden opgegeven.
"CREATION_TIME" AS (TO_TIMESTAMP(XMLQUERY('declare default element namespace "http://www.example.com/m/d/schema/i";declare namespace c="http://www.example.com/m/schema/common";/d/c:dHeader/c:creationTime' PASSING OBJECT_VALUE RETURNING CONTENT),'YYYY-MM-DD"T"HH24:MI:SS'))
Error at Command Line:9 Column:45
Error report:
SQL Error: ORA-00932: inconsistente gegevenstypen: - verwacht, - gekregen
00932. 00000 - "inconsistent datatypes: expected %s got %s"
*Cause:
*Action:
"CREATION_TIME" AS (TO_TIMESTAMP(EXTRACTVALUE("OBJECT_VALUE",'/di:d/c:dHeader/c:creationTime','xmlns:di="http://www.example.com/m/d/schema/i" xmlns:c="http://www.example.com/m/schema/common"'),'YYYY-MM-DD"T"HH24:MI:SS'))
table "USER"."DI_D" created. -
How to set column value dependend on other column value?
I have a view that selects values from 2 tables with some simple additional joins. Now, i would like to add a column (boolean/bit or varchar2) that represents a flag and is dependen on the value of another column, e.g.
ID | Value | Flag
1 | 4711 | 1
2 | null | 0
So, the flag should be set to 1 if column 'Value' is not null and to 0 if column 'Value' is null. (In another case, i would like to test for specific values, not just null). How can i do this in ORACEL SQL?This statement will update two flag columns. FLAG1 is set to one or zero depending on whether COL1 is null. FLAG2 is set to one of a range of values depending on whether COL1 is a specific value; the default value is ZERO.
UPDATE your_table
SET flag1 = nvl2(col1, 1, 0)
, flag2 = decode(col1, 5677, 1, 2212, 2, 6276, 3, null, 4, 0)
/Cheers, APC -
Can not compute totals on a column based on a summary column
Hi. I'm new in Discoverer.
I have created a worksheet based on the following query:
SELECT O101158.COD_HACIENDA, O101158.NOMBRE, O101266.DESC_UNIDAD, SUM(( NVL(O101501.PESO_NETO,0)/1000 ))
FROM ASISTEN.SAT_HACIENDAS O101158, ASISTEN.SAT_UNIDADES O101266, ROMANA."BOLETO_CA#A" O101501
WHERE ( ( O101158.COD_UNIDAD_OPER = O101266.COD_UNIDAD ) AND ( O101501.COD_HACIENDA = O101158.COD_HACIENDA ) ) AND ( O101501.ZAFRA = '2004-2005' )
GROUP BY O101158.COD_HACIENDA, O101158.NOMBRE, O101266.DESC_UNIDAD
ORDER BY O101266.DESC_UNIDAD ASC
The expression SUM(( NVL(O101501.PESO_NETO,0)/1000 )) is defined in Discoverer as a calculated item.
I have created a total on the sum expression. The idea is to have it compute at the "DESC_UNIDAD".
The problem is that only the label "Sum" is printed at the right level. No total is calculated.
Is this a restriction on totals based on aggregation or am i missing somthing here?
Best regards, Luis ...!Hi Luis
There have been a number of questions concerning summations of totals in recent weeks.
Take a look at these threads:
Cell sum not working
Calculation shows Blank or NULL in Discoverer Viewer but not in Dis.Desktop
Do either of these help?
Best wishes
Michael -
View with columns based on function - problem with query
Hi,
I'm using Oracle 9i;
I've created a view which has columns based on a table columns (multiple columns from 1 table) and funtion (multiple columns based on 1 function).
The function takes ID as the first argument and name of the column to determine which value to return as the second one.
Here is a sample of such function (simplified):
FUNCTION my_function
(in_id IN NUMBER, in_col_name IN VARCHAR2)
RETURN VARCHAR2
IS
c_name VARCHAR2(100);
c_last_name VARCHAR2(100);
BEGIN
SELECT T.NAME, T.LAST_NAME
INTO c_name, c_last_name
FROM TABLE_1 T, TABLE_2 Z
WHERE T.PK = Z.FK
AND Z.ID = in_id;
IF in_col_name = 'NAME' THEN
RETURN c_name;
ELSIF in_col_name = 'LAST_NAME' THEN
RETURN c_last_name;
END IF;
END;
For simplicty I've restricted the number of columns.
CREATE OR REPLACE VIEW my_view
(ID, NAME, LAST_NAME)
AS
SELECT
T.ID ID
,CAST(my_function(T.ID,'NAME') AS VARCHAR2(100)) NAME
,CAST(my_function(T.ID,'LAST_NAME') AS VARCHAR2(100)) LAST_NAME
FROM TABLE T;
There is no problem with query:
SELECT * FROM my_view;
The problem arises when I query the view (regardles of '=' or 'LIKE'):
SELECT * FROM my_view
WHERE name LIKE '%some_part_of_name%'
The query returns rows for same names, for same it doesn't. If I put '=' and the whole name the query returns nothing, but when I put 'LIKE' and the first letter it returns rows in some cases.
I've tried to debug this situation and I've discovered that the function recives ID not in the proper order and not the same amount of times - in explicit:
for each ID in (1, 2, 3, 4, 5, 6, ... , 100) the function should be called twice for each ID and in the same order, but it does not.
I get 1, 1, 2, 3, 3, 6, 20, 20 and so on.
Help needed.
Greetings.The problem is more complicated than the solutions provided here.
The reason why I'm using the function is this:
the original view was constructed using multiple union all selects and the speed was terrible. I've created the index on the base table to obtain a proper sort. For retriving all records at once the view works perfectly, but if one wants to query by columns based on function the results are suprisng - sometimes there are, some times there are none, or if you serch with "like" and only a part of string there are results, but with "=" there are no results.
Here are real DDLs:
View:
CREATE OR REPLACE VIEW V_DOK_ARCH
(ID_ZDAR, TYP, STAN, DATE_CREATED, CREATED_BY,
DATE_MODIFIED, MODIFIED_BY, SPRA_ID_SPRA, PODM_ID_PODM, PODM_UMOW_ID_UMOW,
NR_WFS, WFS_NR_INTER, UWAGI_OPER, FUNDUSZ, NUMER,
DATA_PODPISANIA, RODZAJ, TYP_PRZY, TYP_UBEZ, NAZWISKO,
IMIE, IMIE_OJCA, NAZWA_FIRMY, NAZWA_FIRMY_SKR, DANE_KLIE)
AS
SELECT /*+ INDEX(Z ZDAR_DATE_CREATED_DESC_I) */
Z.ID_ZDAR ID_ZDAR
, Z.TYP TYP
, Z.STAN STAN
, Z.DATE_CREATED DATE_CREATED
, Z.CREATED_BY CREATED_BY
, Z.DATE_MODIFIED DATE_MODIFIED
, Z.MODIFIED_BY MODIFIED_BY
, Z.SPRA_ID_SPRA SPRA_ID_SPRA
, Z.PODM_ID_PODM PODM_ID_PODM
, Z.PODM_UMOW_ID_UMOW PODM_UMOW_ID_UMOW
, Z.NR_WFS NR_WFS
, Z.WFS_NR_INTER WFS_NR_INTER
, Z.UWAGI_OPER UWAGI_OPER
, Z.FUNDUSZ FUNDUSZ
, CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NUMER') AS VARCHAR2(30)) NUMER
, F_Rej_Zdar_Date(Z.ID_ZDAR, 'DATA_PODPISANIA') DATA_PODPISANIA
, CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'RODZAJ') AS VARCHAR2(4)) RODZAJ
, CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'TYP_PRZY') AS VARCHAR2(4)) TYP_PRZY
, CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'TYP_UBEZ') AS VARCHAR2(3)) TYP_UBEZ
, CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWISKO') AS VARCHAR2(30)) NAZWISKO
, CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'IMIE') AS VARCHAR2(30)) IMIE
, CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'IMIE_OJCA') AS VARCHAR2(30)) IMIE_OJCA
, CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY') AS VARCHAR2(300)) NAZWA_FIRMY
, CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY_SKR') AS VARCHAR2(100)) NAZWA_FIRMY_SKR
, CAST(LTRIM(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWISKO')||' '||F_Rej_Zdar_Char(Z.ID_ZDAR, 'IMIE')||' '||F_Rej_Zdar_Char(Z.ID_ZDAR, 'IMIE_OJCA')||F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY')||DECODE(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY'),NULL,F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY_SKR'),NULL)) AS VARCHAR2(492)) DANE_KLIE
FROM T_ZDARZENIA Z
WHERE F_Rej_Zdar_Char(Z.ID_ZDAR, 'JEST') = 'T';
and functions:
CREATE OR REPLACE FUNCTION F_Rej_Zdar_Char
(WE_ID_ZDAR IN NUMBER
,WE_KOLUMNA IN VARCHAR2
RETURN VARCHAR2
IS
c_numer T_PRZYSTAPIENIA.NUMER%TYPE;--VARCHAR2(30);
c_rodzaj T_KLIENCI.RODZAJ%TYPE;--VARCHAR2(1);
c_typ_przy T_PRZYSTAPIENIA.TYP_PRZY%TYPE;--VARCHAR2(1);
c_typ_ubez T_PRZYSTAPIENIA.TYP_UBEZ%TYPE;--VARCHAR2(3);
c_nazwisko T_KLIENCI.NAZWISKO%TYPE;--VARCHAR2(30);
c_imie T_KLIENCI.IMIE%TYPE;--VARCHAR2(30);
c_imie_ojca T_KLIENCI.IMIE_OJCA%TYPE;--VARCHAR2(30);
c_nazwa_firmy T_KLIENCI.NAZWA_FIRMY%TYPE;--VARCHAR2(300);
c_nazwa_firmy_skr T_KLIENCI.NAZWA_FIRMY%TYPE;--VARCHAR2(100);
c_jest VARCHAR2(1) := 'T';
c EXCEPTION;
BEGIN
--dbms_output.put_line('id zdar wykonania '||WE_ID_ZDAR);
BEGIN
SELECT p.NUMER, k.RODZAJ,p.TYP_PRZY,p.TYP_UBEZ,k.nazwisko, k.imie, k.imie_ojca, k.nazwa_firmy, k.nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_KLIENCI k, T_PRZYSTAPIENIA p, T_ZDARZENIA z, T_PODMIOTY D1, T_PODMIOTY D2
WHERE p.KLIE_ID_KLIE = k.ID_KLIE
AND z.PODM_ID_PODM = D1.ID_PODM
AND D1.KLIE_ID_KLIE = p.KLIE_ID_KLIE
AND Z.PODM_UMOW_ID_UMOW = D2.ID_PODM
AND D2.PRZY_ID_PRZY = P.ID_PRZY
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.NUMER, k.RODZAJ,p.TYP_PRZY,p.TYP_UBEZ,k.nazwisko, k.imie, k.imie_ojca, k.nazwa_firmy, k.nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_KLIENCI k, T_PRZYSTAPIENIA p, T_ZDARZENIA z, T_PODMIOTY D
WHERE z.PODM_UMOW_ID_UMOW IS NULL
AND z.PODM_ID_PODM = D.ID_PODM
AND D.KLIE_ID_KLIE = k.ID_KLIE
AND p.KLIE_ID_KLIE = k.ID_KLIE
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT NULL NUMER, NULL RODZAJ,NULL TYP_PRZY,NULL TYP_UBEZ, I.nazwisko, I.imie, I.imie_ojca, I.NAZWA NAZWA_FIRMY, I.NAZWA_SKR nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_ZDARZENIA z, T_INSTYTUCJE I
WHERE Z.TYP IN ('WFS526','WFS542','WFS553','WFS609','WFS611','WYP_KS','WYP_PO','WYP_SB','DI_ZAT')
AND z.PODM_UMOW_ID_UMOW IS NULL
AND Z.PODM_ID_PODM = I.ID_INST
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.NUMER NUMER, DECODE(a.TYP_AGENTA,'A','F','P') RODZAJ, DECODE(a.TYP_AGENTA,'P','R',a.TYP_AGENTA) TYP_PRZY,NULL TYP_UBEZ,a.nazwisko, a.imie, a.imie_ojca, a.nazwa_firmy, a.nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_AG_AGENCI a, T_AG_UMOWY p, T_ZDARZENIA z
WHERE a.ID_AGAG = p.AGAG_ID_AGAG
AND z.PODM_UMOW_ID_UMOW = p.ID_AGUM
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.NUMER NUMER, DECODE(a.TYP_AGENTA,'A','F','P') RODZAJ, DECODE(a.TYP_AGENTA,'P','R',a.TYP_AGENTA) TYP_PRZY,NULL TYP_UBEZ,a.nazwisko, a.imie, a.imie_ojca, a.nazwa_firmy, a.nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_AG_AGENCI a, T_AG_UMOWY p, T_ZDARZENIA z
WHERE a.ID_AGAG = p.AGAG_ID_AGAG
AND z.PODM_ID_PODM = a.ID_AGAG
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.NUMER_UMOWY NUMER, DECODE(p.TYP_AGENTA,'A','F','P') RODZAJ, DECODE(p.TYP_AGENTA,'P','R',p.TYP_AGENTA) TYP_PRZY,NULL TYP_UBEZ,p.nazwisko, p.imie_pierwsze, p.imie_ojca, p.nazwa_firmy, p.nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_AG_KANDYDACI a, T_AG_UMOWY_TAB p, T_ZDARZENIA z
WHERE a.ID_AGKAN = p.TECH_PODM_ID_PODM
AND z.PODM_UMOW_ID_UMOW = p.TECH_ID_AGUMT
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.NUMER_UMOWY NUMER, DECODE(p.TYP_AGENTA,'A','F','P') RODZAJ, DECODE(p.TYP_AGENTA,'P','R',p.TYP_AGENTA) TYP_PRZY,NULL TYP_UBEZ,p.nazwisko, p.imie_pierwsze, p.imie_ojca, p.nazwa_firmy, p.nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_AG_KANDYDACI a, T_AG_UMOWY_TAB p, T_ZDARZENIA z
WHERE a.ID_AGKAN = p.TECH_PODM_ID_PODM
AND z.PODM_ID_PODM = a.ID_AGKAN
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT k.NUMER_UMOWY NUMER, DECODE(k.TYP_PRZYSTAPIENIA,'P','F','P') RODZAJ,k.TYP_PRZYSTAPIENIA TYP_PRZY,'NPO' TYP_UBEZ, k.nazwisko, k.imie_pierwsze, k.imie_ojca, k.nazwa_firmy nazwa_firmy, k.nazwa_firmy_skr nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_WE_UM_NPO_TAB k, T_ZDARZENIA z
WHERE z.ID_ZDAR = k.TECH_ZDAR_ID_ZDAR
AND k.TYP_PRZYSTAPIENIA IN ('P','W')
AND z.PODM_ID_PODM IS NULL
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT k.NUMER_UMOWY NUMER, 'F' RODZAJ,'-' TYP_PRZY,'OPS' TYP_UBEZ, k.nazwisko, k.imie_pierwsze, k.imie_ojca, NULL nazwa_firmy, NULL nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_WE_UM_OPS_TAB k,T_ZDARZENIA z
WHERE z.ID_ZDAR = k.TECH_ZDAR_ID_ZDAR
AND z.PODM_ID_PODM IS NULL
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT NULL NUMER, NULL RODZAJ,NULL TYP_PRZY,NULL TYP_UBEZ, NULL nazwisko, NULL imie_pierwsze, NULL imie_ojca, NULL nazwa_firmy, NULL nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_ZDARZENIA z
WHERE z.TYP NOT IN ('UM_OPS','UM_NPO','NPO_OP','UZUP_U')
AND z.PODM_ID_PODM IS NULL
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
--dbms_output.put_line('id zdar wykonania '||WE_ID_ZDAR||' ostatni wyjatek');
NULL;
END;
END;
END;
END;
END;
END;
END;
END;
END;
END;
--raise c;
IF WE_KOLUMNA = 'NUMER' THEN
RETURN c_numer;
ELSIF WE_KOLUMNA = 'RODZAJ' THEN
RETURN c_rodzaj;
ELSIF WE_KOLUMNA = 'TYP_PRZY' THEN
RETURN c_typ_przy;
ELSIF WE_KOLUMNA = 'TYP_UBEZ' THEN
RETURN c_typ_ubez;
ELSIF WE_KOLUMNA = 'NAZWISKO' THEN
RETURN c_nazwisko;
ELSIF WE_KOLUMNA = 'IMIE' THEN
RETURN c_imie;
ELSIF WE_KOLUMNA = 'IMIE_OJCA' THEN
RETURN c_imie_ojca;
ELSIF WE_KOLUMNA = 'NAZWA_FIRMY' THEN
RETURN c_nazwa_firmy;
ELSIF WE_KOLUMNA = 'NAZWA_FIRMY_SKR' THEN
RETURN c_nazwa_firmy_skr;
ELSIF WE_KOLUMNA = 'JEST' THEN
RETURN c_jest;
END IF;
END;
CREATE OR REPLACE FUNCTION F_Rej_Zdar_Date
(WE_ID_ZDAR IN NUMBER
,WE_KOLUMNA IN VARCHAR2
RETURN DATE
IS
d_data DATE;
BEGIN
BEGIN
SELECT p.DATA_PODPISANIA
INTO d_data
FROM T_KLIENCI k, T_PRZYSTAPIENIA p, T_ZDARZENIA z, T_PODMIOTY D1, T_PODMIOTY D2
WHERE p.KLIE_ID_KLIE = k.ID_KLIE
AND z.PODM_ID_PODM = D1.ID_PODM
AND D1.KLIE_ID_KLIE = p.KLIE_ID_KLIE
AND Z.PODM_UMOW_ID_UMOW = D2.ID_PODM
AND D2.PRZY_ID_PRZY = P.ID_PRZY
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.DATA_PODPISANIA
INTO d_data
FROM T_KLIENCI k, T_PRZYSTAPIENIA p, T_ZDARZENIA z, T_PODMIOTY D
WHERE z.PODM_UMOW_ID_UMOW IS NULL
AND z.PODM_ID_PODM = D.ID_PODM
AND D.KLIE_ID_KLIE = k.ID_KLIE
AND p.KLIE_ID_KLIE = k.ID_KLIE
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT NULL DATA_PODPISANIA
INTO d_data
FROM T_ZDARZENIA z, T_INSTYTUCJE I
WHERE Z.TYP IN ('WFS526','WFS542','WFS553','WFS609','WFS611','WYP_KS','WYP_PO','WYP_SB','DI_ZAT')
AND z.PODM_UMOW_ID_UMOW IS NULL
AND Z.PODM_ID_PODM = I.ID_INST
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.DATA_PODPISANIA DATA_PODPISANIA
INTO d_data
FROM T_AG_AGENCI a, T_AG_UMOWY p, T_ZDARZENIA z
WHERE a.ID_AGAG = p.AGAG_ID_AGAG
AND z.PODM_UMOW_ID_UMOW = p.ID_AGUM
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.DATA_PODPISANIA DATA_PODPISANIA
INTO d_data
FROM T_AG_AGENCI a, T_AG_UMOWY p, T_ZDARZENIA z
WHERE a.ID_AGAG = p.AGAG_ID_AGAG
AND z.PODM_ID_PODM = a.ID_AGAG
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.DATA_PODPISU_AGENTA DATA_PODPISANIA
INTO d_data
FROM T_AG_KANDYDACI a, T_AG_UMOWY_TAB p, T_ZDARZENIA z
WHERE a.ID_AGKAN = p.TECH_PODM_ID_PODM
AND z.PODM_UMOW_ID_UMOW = p.TECH_ID_AGUMT
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.DATA_PODPISU_AGENTA DATA_PODPISANIA
INTO d_data
FROM T_AG_KANDYDACI a, T_AG_UMOWY_TAB p, T_ZDARZENIA z
WHERE a.ID_AGKAN = p.TECH_PODM_ID_PODM
AND z.PODM_ID_PODM = a.ID_AGKAN
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT k.DATA_PODPISANIA_UM DATA_PODPISANIA
INTO d_data
FROM T_WE_UM_NPO_TAB k, T_ZDARZENIA z
WHERE z.ID_ZDAR = k.TECH_ZDAR_ID_ZDAR
AND k.TYP_PRZYSTAPIENIA IN ('P','W')
AND z.PODM_ID_PODM IS NULL
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT k.DATA_PODPISANIA_UM DATA_PODPISANIA
INTO d_data
FROM T_WE_UM_OPS_TAB k,T_ZDARZENIA z
WHERE z.ID_ZDAR = k.TECH_ZDAR_ID_ZDAR
AND z.PODM_ID_PODM IS NULL
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT NULL DATA_PODPISANIA
INTO d_data
FROM T_ZDARZENIA z
WHERE z.TYP NOT IN ('UM_OPS','UM_NPO','NPO_OP','UZUP_U')
AND z.PODM_ID_PODM IS NULL
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
d_data := NULL;
END;
END;
END;
END;
END;
END;
END;
END;
END;
END;
IF WE_KOLUMNA = 'DATA_PODPISANIA' THEN
RETURN d_data;
END IF;
END; -
How to create new calculated column based on filtered columns?
Dear All,
I'm using Oracle Analysis.
I have two column, each one have different formula.
My Formula based on filter.
Column1
FILTER("DW"."SUM_PLAN_MONTH_AMOUNT" USING ("DW"."PLAN_YEAR" BETWEEN YEAR(DATE'@{P_BEGIN_DATE}') and YEAR(DATE'@{P_END_DATE}')))Column2
FILTER("PAYMENTS"."SUM_PAY_AMOUNT" / 1000 USING ("PAYMENTS"."PAY_DATE_PAID" BETWEEN DATE'@{P_BEGIN_DATE}' AND DATE'@{P_END_DATE}'))How to add new calculated column based on those two column?
For example:
Column1 | Column2 | NewColumn
5 | 10 | 10 / 5 * 100
7 | 12 | 12 / 7 * 100
Regards,
Eba
Edited by: Erdenebayar on Apr 19, 2012 1:42 PM
Edited by: Erdenebayar on Apr 19, 2012 3:37 PMHello MK,
I have a tried following formula. It is working, but result is not filtered.
I filtered "PAYMENTS"."SUM_PAY_AMOUNT" and "DW"."SUM_PLAN_MONTH_AMOUNT" columns.
"PAYMENTS"."SUM_PAY_AMOUNT" / "DW"."SUM_PLAN_MONTH_AMOUNT" * 100Can you share me some tutorial?
BR,
Eba
Edited by: Erdenebayar on Apr 19, 2012 3:43 PM
Edited by: Erdenebayar on Apr 19, 2012 3:43 PM
Edited by: Erdenebayar on Apr 19, 2012 3:43 PM -
Conditional column display in report using column substitution string
Hi everone,
I was wondering if it's possible to display a column conditionally, based on a values in another column of the same report.
Can you use the column substitution strings or does the condition strictly require SQL, PL/SQL
or page item values?
kind regards,
CleoI dont think we can add a condition to display the column in a report based on the other column of the same report,
Just add a (CASE WHEN <your condition satisfies> THEN column ELSE null END) in your report source for the column you want to display conditionally.
--Mahesh -
I am looking to see if anyone has figured out, from their iPad in Numbers how to calculate percentages or sums totalling other columns or rows?
The issue is I bought the G4 from my buddy a few months ago... the machine has been abused to say the least, both inside and out. It is almost falling apart and has a BUNCH of programs loaded on it. I have always used a PC and am still familiarizing myself with Macs, I need to clean out the machine and dump all the excess applications and files that are causing problems.
I think this is why I am having some trouble. Sometimes it works just fine, but I am only working with a few simultaneous tracks at a time. I am using the virtual instruments at this time but will be running guitars and bass through an external sound card soon. Similar to what you are doing it sounds like.
Anyway, wanted to give you some more insight. Last night it seemed to work alright, I am not going to rush into buying anything until I absolutely have to but want to get some direction as far as what I should be looking at.
Any further input is appreciated, thanks. -
How to insert into date column based on other columns?
Hi
I have four columns in a table called game named as
R_Day - Type - Number
R_Month - Type - Number
R_Year - Type - Number
R_Date - Type - Date
I have around 1000 records and i want to fill R_Date column based on the data in the R_Day,R_Month,R_Year.
How to write a query to fill the R_Date column based on other three columns.
Thanks
srinivasselect
to_date(R_Day||'-'||R_Month||'-'||R_Year,'DD-MM-YYYY')
dt from (select 23 R_Day,07 R_Month,2007 R_Year from
dual);
Hi,
Update <Table Name> set R_Date=select
to_date(R_Day||'-'||R_Month||'-'||R_Year,'DD-MM-YYYY')
from <Table Name>
Regds.
Nirmal
SQL> select * from test;
R_DAY R_MONTH R_YEAR R_DATE
1 1 2007
21 11 2007
SQL> update test
2 set r_date = select to_date(R_Day||'-'||R_Month||'-'||R_Year,'DD-MM-YYYY')
3 from test;
set r_date = select to_date(R_Day||'-'||R_Month||'-'||R_Year,'DD-MM-YYYY')
ERROR at line 2:
ORA-00936: missing expression
SQL> update test
2 set r_date = to_date(r_day||'-'||r_month||'-'||r_year,'dd-mm-yyyy');
2 rows updated.
SQL> select * from test;
R_DAY R_MONTH R_YEAR R_DATE
1 1 2007 01-JAN-07
21 11 2007 21-NOV-07
NB:Please test before posting..
Maybe you are looking for
-
Configuration automatic interest calculation on Accounts Receivable (AR)
HI Guru's Any one can send me documents for :.. Configuration automatic interest calculation on Accounts Receivable (AR) open invoices for AR module based on aging of the customer i.e. different ageing different percentage. Configuraton of automatic
-
I updated as I was asked. The computer was on for a while and then turned off. Now, it won't open firefox at all. A big red 'x' and an error message pops up. Message says: The procedure entry point XRE_GetFileFromPath could not be located in the dyna
-
Custom tag losing onchange value when page is refreshed
Hi all, I'm still using JSF 1.1 and I have an issue with a custom tag. When my page is first displayed, the onchange attribute contains my script but, when I refresh the page it's not there anymore. The custom tag if an input for dates. It can have o
-
Problem while activating table
Hi, The system I am using was upgraded from 4.7 to ECC 6.0 I have a table ZABCD. When i try to activate this table, i get the following warning message Enhancement category for table missing Enhancement category for include or subtype missing Table Z
-
Forms 6i to FOrms 10g I am working on upgrading Oracle forms 6i deployed using listener servlet architecture on 9iAS Release 1 and want to upgrade to Oracle 10g. I had tried with few of the form but all of them are giving the same error. I tried to o