help on the clause type
I have a query as belowSelect empno, deptno, sum (sal) on tot_sal (partition deptno) from scott.emp;
will give the result like this
EMPNO DEPTNO TOT_SAL
---------- ---------- ----------
7934 10 8750
7782 10 8750
7839 10 8750
7902 20 10875
7876 20 10875
7566 20 10875
7369 20 10875
7788 20 10875
8 selected lines.
but as you can see the total sal and deptno repeats, what I want is wise dept total salary as shown below
EMPNO DEPTNO TOT_SAL
---------- ---------- ----------
7934
7782
7839
Total for deptno 10 = 8750
7902
7876
7566
7369
7788
Total for deptno = 20 10875
I want to use the type clause and get the above result
970426 wrote:
Karthik repliedPublished by: 970426 on January 24, 2013 04:13
You are not yet able to determine good projection on your own?
select
nvl(to_char(empno),'Total for deptno '||deptno||': '||sal)
empno
from emp
model
partition by (deptno)
dimension by (row_number() over(
partition by deptno
order by empno) rn)
measures (sal, empno)
rules(
sal[0]=sum(sal) [any]
)
order by
deptno, empno
Katrick solution uses my idea of deptno [0]. It has a useless subquery, a useless measure, two unnecessary rules.
Please don't give any of my points.
Jiust learn a thing about it.
Introduction to thinking on your own.
Tags: Database
Similar Questions
-
I have a temp table as below
LOC X CNT
20 20 C
80 20 N
60 30 C
40 30 N
100 40 N
the rule is for each column of the LOC, there are 2 records of C, N and sum (NTC) must be = 100. If there is no value for C for a LOC (LOC = 40) then the value of the CNT corresponding to C should appear as null or 0 if the value of N is > 0.
I need a model clause to do this, see below,
LOC X CNT
20 20 C
80 20 N
60 30 C
40 30 N
100 40 N
0 TO 40 C
Why why why? I am not able to understand the model clause. How did you learn model clause?
-
SQL query help needed in the Clause type
Hello
I'm currently learning Clause type. How can I write in the clause type to get the result below:
I have a table like this
DEPTNO ENAME
------- ------
20 SMITH
CELINE 10
BOND 20
ALLEN 30
WARD 30
20 JONES
30 MARTIN
30 BLAKE
10 CLARK
SCOTT 20
10 KING
30 TURNER
20 ADAMS
30 JAMES
20 FORD
10 MILLER
I want the output should look like this
DEPTNO ENAME
------ -----
CELINE 10, CLARK, KING, MILLER
20 JONES, ADAMS, BOND, FORD, SCOTT, SMITH
30 MARTIN, JAMES BLAKE, WARD, TURNER, ALLEN
Hear is the script I am currently working on.
with emp_group as
(
Select 20 deptno, ename 'SMITH' Union double all the
choose 10, 'CÉLINE' from dual union all
Select 20, "BOND" of all the double union
Select 30, 'ALLEN' from dual union all
Select 30, 'WARD' of all the double union
Select 20, "JONES' from dual union all
Select 30, 'MARTIN' from dual union all
Select 30, "BLAKE" from dual union all
choose 10, 'CLARK' from dual union all
Select 20, 'SCOTT' from dual union all
choose 10, 'KING' of the dual union all
Select 30, 'TURNER' from dual union all
Select 20, 'ADAMS' from dual union all
Select 30, 'JAMES' of the dual union all
Select 20, 'FORD' Union double all the
choose 10, 'MILLER' from dual
)
Select
DEPTNO
A1
of emp_group
model
ignore the nav
partition (deptno)
dimension (ROW_NUMBER() over (PARTITION BY deptno ORDER BY ename DESC) rn)
measures (ename, LPAD(' ', 100) A1)
rules)
A1 [rn > 0] = ename [cv ()],
A1 [0] = ename [cv ()]
)
order by deptno
;
your help is very appreciated.
Thank you in advance.
Try this.
Select
*
Of
(
with emp_group as
(
Select 20 deptno, ename 'SMITH' Union double all the
choose 10, 'CÉLINE' from dual union all
Select 20, "BOND" of all the double union
Select 30, 'ALLEN' from dual union all
Select 30, 'WARD' of all the double union
Select 20, "JONES' from dual union all
Select 30, 'MARTIN' from dual union all
Select 30, "BLAKE" from dual union all
choose 10, 'CLARK' from dual union all
Select 20, 'SCOTT' from dual union all
choose 10, 'KING' of the dual union all
Select 30, 'TURNER' from dual union all
Select 20, 'ADAMS' from dual union all
Select 30, 'JAMES' of the dual union all
Select 20, 'FORD' Union double all the
choose 10, 'MILLER' from dual
)
Select
DEPTNO
names
rn
of emp_group
model
ignore the nav
partition (deptno)
dimension of)
ROW_NUMBER() over (PARTITION BY deptno ORDER BY ename) rn
)
measures (ename, cast (null as names of varchar2 (40)))
rules
(
names [any] order by desc = ename [cv ()] rn | «, » || names [cv () + 1]
)
order by deptno
)
where rn = 1
Best regards, Andrei
-
How to use the clause type conditionally create new lines
This question is just for learning - no object other than to start real world to create versions of some queries known to learn how to measure the performance of the MODEL clause clause of the MODEL versions.
The question is: How can you write a STANDARD clause that pivots (updates) ONLY the lines that actually need to rotate and do NOT change the lines that have no value and cannot be rotated.
I found a good site that has about two dozen example articles on different pieces. This first link is the beginning of the series.
SQL features tutorials - Clause TYPE
http://www.sqlsnippets.com/en/topic-11663.html
This link is to a clause of FAQ of BluShadow MODEL version "how to convert rows to columns."
Line - MODEL method string
http://www.sqlsnippets.com/en/topic-11987.html
The solution to this link uses this line of source:
POSITION KEY VAL
--- ---------- ----------
R08 0 v1, v2, v3,.
and this result set:
POSITION KEY VAL
--- ---------- ----------
R08 1 v1
R08 2 v2
R08 3 v3
The reason why it produces that result set is this clause of the statement of MODEL
RETURN THE UPDATED LINES
If you comment on this article, you will see that the original lines are all in position 0. This means that the solution reproduced EACH SOURCE LINE even if there is only one item in the list of values.
Thus, even a line source with a single value (for example, the r01 'a') will be updated and updated this line is returned.
For a large number of data sources with only a few lines that actually need to rotate it would be a great performance of infringement.
This is the sample data source
with t as (button 1, 'a' value 'abc' col2, col3 'def' of the double
Select Union all 2, 'b', 'ghi', 'jkl' from dual
Union all select 3, 'c, d, e, 'mno', 'pqr' from dual.
Union all select 4, 'f', 'stu', 'vwx' from dual
)
Select the key, value, col2, col3
tKEY, VALUE, COL2, COL3
1, a, abc, def
2, b, GHI, jkl
3, "c, d, e, mno, pqr.
4, f, stu, vwxLines 1, 2 and 4 only have a value of (a, b, c respectively.
Only line 3 must rotate. It contains "c, d, e" and which must become 3 lines in the result set
Value of the key, col2 col3
1 an abc def
2B ghi jkl
3 c mno, pqr
3 d mno, pqr
3 e mno, pqr
4 f stu vwxThe nut of the problem is that if the clause 'RETURN UPDATED ROWS' is used, then the lines 1, 2 and 4 must be updated in order to be returned in the result set. And if this clause is NOT used, then line 3 must be updated by 'c', d, e 'c' and two new product lines: one line for a ' and one for 'e '.
How can you do this with the TYPE clause without the help of the clause "Return LINES UPDATE"? I don't have a solution to sample showing what I tried because I can't understand what it takes to even try.
I have a solution that uses "RETURN UPDATED ROWS" but I want to compare this performance to the exercise, when this clause is NOT used.
We ask BluShadow to add the solution of MODEL clause to this FAQ with other similar solutions.
Like this?
SQL > with t as
() 2
3 select the 1 key, 'a' val, 'abc' col2, col3 'def' of the double
Select 4 Union all 2, 'b', 'ghi', 'jkl' from dual
5 union all select 3, 'c, d, e, 'mno', 'pqr' from dual.
Select 6 Union all the 4 'f', 'stu', 'vwx' from dual
7)
8. Select the key
9, key_1
10, val
11, regexp_substr (val, ' [^,] +', 1, key_1) val_new
12, col2
13, col3
14 t
model 15
16 partition by (key)
dimension (1 key_1) 17
18 measures (val, col2, col3, (length (val) - length (replace (val, ",")) + 1) as len)
19 rules
(20)
21 val [for 1 to increment of len key_1 [1] 1] = val [1]
22, col2 [for 1 to increment of len key_1 [1] 1] = col2 [1]
23, col3 [for 1 to increment of len key_1 [1] 1] = col3 [1]
24)
25 order
26 by key
27, key_1;KEY KEY_1 VAL VAL_N NECK NECK
---------- ---------- ----- ----- --- ---
1 1 has an abc def
2 b 1 b ghi jkl
3 1 c, d, e c mno pqr
3 2 c, d, e d mno pqr
3 3 c, d, e e mno pqr
4 1 f f stu vwx6 selected lines.
-
Hi all
I read some documents oracle and and some examples
I understand that this model is used to create the table multidimensional and for the prediction of the future.
but I am not able to write the query using the type clause.
Please someone help me to understand the clause type base.
I want everything clause type to start from scratch.
Please guide me.Links: http://rwijk.blogspot.in/2007/10/sql-model-clause-tutorial-part-one.html.
http://rwijk.blogspot.in/2007/10/SQL-model-clause-tutorial-part-two.htmlThere is a post over here in the OTN forum. Please do a search.
Concerning
BijuEdited by: biju2012 1 Sep 2012 16:02
(The link for part 2 is provided)Published by: biju2012 on Sep 2, 2012 02:45
-
Help with the clause of "default".
Hi all
I have a scenario where there is a table with 75 columns. out of the 75 columns, 30 are varchar and 30 are digital. The remaining columns are other types of data when creating the table, that I forgot to mention the default values to varchar and numeric columns.
Now, approximately 20,000 records are inserted into the table where some records contain NULL varchar and numeric. Now, I want to replace the null with varchar values and digital default values respectively.
I can change the columns by adding the clause by default now and update the lines of NULL for the default values accordingly. But this process could be very heavy.
Is there a better way to do this. Please help me.
Thanks in advance,
RambeauI want to know that is it possible to set the default values for all columns of type varchar, both using a single SQL statement. Then you can update all the values NULL with default values.
You are looking for something like this?
SQL> create table t (empno default 1, ename default 'x') as select cast(null as integer) empno, cast(null as varchar2(10)) ename from emp where rownum <= 4 / Table created. SQL> select * from t / EMPNO ENAME ---------- ---------- 4 rows selected. SQL> update t set empno = default, ename=default / 4 rows updated. SQL> select * from t / EMPNO ENAME ---------- ---------- 1 x 1 x 1 x 1 x 4 rows selected.
-
Cell in the clause type assignments
Hello
I have a table TEST_DATA with the YEAR, FIELD VALUE, in the form of columns.
Value1, value2, VALUE 3 columns are determined based on field values. If the data is as follows
THE YEAR FIELD VALUE
------------------------------------------
11111 1 2010
22222 2 2010
33333 3 2010
. . .
. . .
. . .
Can I get the following output using clause type.
YEAR VALUE1 VALUE2 VALUE3
------ ----------- ----------- -----------
2010 11111 222222 333333
2009 23243 533635 343434
2008--34343 364653 343434
2007 34345 789879 343434
I don't want to use pivot, because I have to do some calculations on columns of value above. So I tried the following query using the type clause
and value1, value2, value3 to come in 3 different lines.
How can I write cell assignments for the value 1, a value of 2, the value 3 in the same line?
SELECT YEAR, VALUE OF 1, THE VALUE 2, VALUE 3
OF TEST_FIN_DATA
MODEL
RETURN THE UPDATED LINES
Single KEY
PARTITION OF (YEAR)
DIMENSION BY (FIELD)
MEASURES (VALUE1, VALUE VALUE2, VALUE3 VALUE VALUE)
RULES
(value1 ['1'] = value1 ['1'],)
value [('2 '] = value ['2'],
value ['3'] = value ['3']);Here is an example that you might find interesting:
http://technology.AMIS.nl/2004/12/16/pivoting-in-SQL-using-the-10G-model-clause/ -
Oracle version 8i (we will migrate the db to 12 c in the next few months)
This is defination and data table:
create table sales
(
prod_id varchar2 (10),
PROD_NAME varchar2 (30),
salesman_id varchar2 (10),
salesman_name varchar2 (30),
commission_per varchar2 (10),
commission_amt varchar2 (10)
)
/
Insert in the value of sales ('prd1',' 1 ', ' 1', 'sm1' ", '10');
Insert in the value of sales ('prd1',' 1 ', ' 2', 'sm2' ", '10');
Insert in the value of sales ('prd1',' 1 ', ' 3', 'sm3' ", '10');
Insert in the value of sales ('2 ', 'prd2', '1', 'sm1', '10.00' ");
Insert in the value of sales ('2 ', 'prd2', '2', 'sm2', '10.00' ");
Insert in the value of sales ('3 ', 'prd3', '2', 'sm2', '10.00' ");
Insert in the value of sales ('3 ', 'prd3', '1', 'sm1', '15,00' ");
Insert in the value of sales ('3 ', 'prd3', '3', 'sm3', '10.00' ");
Insert in the value of sales ('4 ', 'prd4', '1', 'sm1', '10.00' ");
Insert in the value of sales ('4', 'prd4', ' 2 ', 'sm2' ", '15');
Insert in the value of sales ('5', 'prd5', ' 1 ', 'sm1' ", '15');
Insert in the value of sales ('6', 'prd6', ' 1 ', 'sm1' ", '15');
Insert in the value of sales ('6', 'prd6', ' 2 ', 'sm2' ", '15');
Insert in the value of sales ('6', 'prd6', ' 3 ',' sm3 ', 15', ");
Insert in the value of sales ('6', 'prd6', ' 4 ',' sm4 ', 15', ");
Insert in the value of sales ('7', 'prd7', ' 1 ', 'sm1' ", '15');
Insert in the value of sales ('7', 'prd7', ' 2 ', 'sm2' ", '15');
Insert in the value of sales ('7', 'prd7', ' 3 ', 'sm3' ", '15');
Insert in the value of sales ('7', 'prd7', ' 4 ', 'sm4' ", '15');
Insert in the value of sales ('7', 'prd7', ' 7 ', 'sm7' ", '15');
Insert in the value of sales ('7', 'prd7', ' 5 ', 'sm1' ", '10');
Insert in the value of sales ('7', 'prd7', ' 6 ', 'sm6' ", '15');
Dress uniform please:
Unique Commision Amount/Commission Percentage: PROD_ID PROD_NAME SALESMAN_I SALESMAN_NAME COMMISSION COMMISSION ---------- ------------------------------ ---------- ------------------------------ ---------- ---------- 1 prd1 1 sm1 10 2 prd2 1 sm1 10.00 5 prd5 1 sm1 15
Means, we must identify the product ID for the business that gives the same percentage of commission sales amount or commission. Percentage of different Commission amount and the Commission:
Different Commision Amount/Commission Percentage: PROD_ID PROD_NAME SALESMAN_I SALESMAN_NAME COMMISSION COMMISSION ---------- ------------------------------ ---------- ------------------------------ ---------- ---------- 3 prd3 2 sm2 10.00 3 prd3 1 sm1 15.00 3 prd3 3 sm3 10.00 4 prd4 1 sm1 10.00 4 prd4 2 sm2 15 6 prd6 1 sm1 15 6 prd6 2 sm2 15 6 prd6 3 sm3 15 6 prd6 4 sm4 15 7 prd7 1 sm1 15 7 prd7 2 sm2 15 7 prd7 3 sm3 15 7 prd7 4 sm4 15 7 prd7 7 sm7 15 7 prd7 5 sm1 10 7 prd7 6 sm6 15
Means, for the highest of the product ID, assigned amount/percentage of different sales commission to sellers; that is for a product id, there is same amount/percentage of commission which would come at the first exit, if these lines of product codes should be in the second output. Kindly help me, since we use very old version, so I think that we cannot use analytics or new SQL functions. So, please help me in a simple sql. Thank you.
I hope that this works in version 8i.
SQL > select prod_id
2, prod_name
3, salesman_id
4, salesman_name
5, commission_per
6, commission_amt
7 of)
8. Select s.*
9, mod (nvl (sum (commission_per) on (prod_id partition), 0), count (*) on (prod_id partition)) +.
10 mod (nvl (sum (commission_amt) on (prod_id partition), 0), count (*) on (prod_id partition)) val
11, row_number() over (partition by prod_id arrested by salesman_id) rno
12 s sale
13 )
14 where val = 0
15 and rno = 1;PROD_ID PROD_NAME SALESMAN_I SALESMAN_NAME COMMISSION COMMISSION
---------- ------------------------------ ---------- ------------------------------ ---------- ----------
1 prd1 1 sm1 10
2 prd2 1 sm1 10.00
5 prd5 1 sm1 15SQL > select prod_id
2, prod_name
3, salesman_id
4, salesman_name
5, commission_per
6, commission_amt
7 of)
8. Select s.*
9, mod (nvl (sum (commission_per) on (prod_id partition), 0), count (*) on (prod_id partition)) +.
10 mod (nvl (sum (commission_amt) on (prod_id partition), 0), count (*) on (prod_id partition)) val
11, row_number() over (partition by prod_id arrested by salesman_id) rno
12 s sale
13 )
14 where val! = 0 ;PROD_ID PROD_NAME SALESMAN_I SALESMAN_NAME COMMISSION COMMISSION
---------- ------------------------------ ---------- ------------------------------ ---------- ----------
3 prd3 2 sm2 10.00
3 prd3 1 sm1 15.00
3 prd3 3 sm3 10.00
4 prd4 1 sm1 10.00
4 prd4 2 sm2 15
6 prd6 2 sm2 15
6 prd6 1 sm1 15
6 prd6 4 sm4 15
6 prd6 3 sm3 15
7 prd7 7 sm7 15
7 prd7 5 sm1 10
7 prd7 4 sm4 15
7 prd7 3 sm3 15
7 prd7 6 sm6 15
7 prd7 1 sm1 15
7 prd7 2 sm2 1516 selected lines.
SQL >
-
With the help of the clause...
Hello
I try to use the With clause to preset some values in the table - as temporary structures. Currently, I need to create two of these tables called Param1 and Param2. I want this is to select than a Params array and make it have 2 fields. I get an error of parenthesis wrong however...
Work with two "tables".
-------------------
with param1 as
(select sum (stm.qty_rec) inco
stock stm
WHERE pnm_auto_key = 1
GROUP BY pnm_auto_key
ORDER BY pnm_auto_key),
param2 as
(select Select sum (saj.qty_adj)
of stock_adjust saj
join in-house stock stm on saj.stm_auto_key = stm.stm_auto_key
parts_master MFN on stm.pnm_auto_key = pnm.pnm_auto_key inner join
where pnm_auto_key = 1
Group of pnm_auto_key)
Select (INCO + SELECT) in param1, param2
-------------------
Does not not (with params), select (...)-> invalid table name
----------------
with params as
(select sum (stm.qty_rec) INCO
stock stm
WHERE pnm_auto_key = 1
GROUP BY pnm_auto_key
ORDER BY pnm_auto_key),
(select sum (saj.qty_adj) SELECT
of stock_adjust saj
join in-house stock stm on saj.stm_auto_key = stm.stm_auto_key
parts_master MFN on stm.pnm_auto_key = pnm.pnm_auto_key inner join
where pnm_auto_key = 1
Group of pnm_auto_key)
Select params (INCO + SELECT)
-----------------
Does not (with params (select), (double) select...)-> lack of right parenthesis
-------------------
with params as
(select (select sum (stm.qty_rec)
stock stm
WHERE pnm_auto_key = 1
GROUP BY pnm_auto_key
ORDER BY pnm_auto_key) INCO.
(select sum (saj.qty_adj)
of stock_adjust saj
join in-house stock stm on saj.stm_auto_key = stm.stm_auto_key
parts_master MFN on stm.pnm_auto_key = pnm.pnm_auto_key inner join
where pnm_auto_key = 1
(Pnm_auto_key group) SELECT DOUBLE)
Select params (INCO + SELECT)
-------------------for example
with params as (select (select sum(stm.qty_rec) from stock stm WHERE pnm_auto_key = 1) INCO, (select sum(saj.qty_adj) from stock_adjust saj inner join stock stm on saj.stm_auto_key = stm.stm_auto_key inner join parts_master pnm on stm.pnm_auto_key = pnm.pnm_auto_key where pnm_auto_key = 1) OUTG FROM dual ) select (INCO + OUTG) from params
-
How to use the clause type without hard-coding the values inside?
Query
Select acct_no,
gl_code,
CASE
WHEN entry_type_label ("earned INCOME") THEN
"Recipes".
ON THE OTHER
"Deferred income of credit."
END as entry_type_label,
CASE
WHEN entry_type_label IN ("opening balance") THEN
"Opening balance".
WHEN entry_type_label ("deferred revenue CREDIT") THEN
"The amount of the invoice.
WHEN entry_type_label ("earned INCOME") THEN
"Recipes".
WHEN entry_type_label IN ('closing balance") THEN
"Closing balance.
ON THE OTHER
"Deferred income of credit."
END tag as,
entry_type_no,
orig_chg_start_date,
period_no,
-amt as amt
of revrec_test
WHERE acct_no = 1788562
AND IN (2, 4) entry_type_no (acct_no model dimension,
gl_code,
entry_type_label,
entry_type_no,
orig_chg_start_date,
period_no) measures (amt) rules upsert
all (amt 1788562,
' NON-10011561',
"Opening balance"
2,
2 OCTOBER 17 08.30.00 AM'.
190 = 0,
AMT 1788562,
' NON-10011561',
"Closing balance."
2,
2 OCTOBER 17 08.30.00 AM'.
190 = amt 1788562,
' NON-10011561',
"Deferred income of credit."
2,
2 OCTOBER 17 08.30.00 AM'.
190 - amt 1788562,
"WON-10011561',
"Revenue."
4,
2 OCTOBER 17 08.30.00 AM'.
190,
AMT 1788562,
' NON-10011561',
"Opening balance"
2,
2 OCTOBER 17 08.30.00 AM'.
191 = amt 1788562,
' NON-10011561',
"Closing balance."
2,
2 OCTOBER 17 08.30.00 AM'.
190,
AMT 1788562,
' NON-10011561',
"Deferred income of credit."
2,
2 OCTOBER 17 08.30.00 AM'.
191 = 0,
AMT 1788562,
' NON-10011561',
"Closing balance."
2,
2 OCTOBER 17 08.30.00 AM'.
191 =.
(amt 1788562, "UNEARNED-10011561',"Opening balance", 2,")
2 October 17 08.30.00 AM', 191 + amt 1788562, "UNEARNED-10011561',
("'Revenue deferred credit', 2, 08.30.00 October 2, 17 h", 191)-amt
1788562,
"WON-10011561',
"Revenue."
4,
2 OCTOBER 17 08.30.00 AM'.
191,
AMT 1788562,
' NON-10011561',
"Opening balance"
2,
2 OCTOBER 17 08.30.00 AM'.
192 = amt 1788562,
' NON-10011561',
"Closing balance."
2,
2 OCTOBER 17 08.30.00 AM'.
191,
AMT 1788562,
' NON-10011561',
"Deferred income of credit."
2,
2 OCTOBER 17 08.30.00 AM'.
192 = 0,
AMT 1788562,
' NON-10011561',
"Closing balance."
2,
2 OCTOBER 17 08.30.00 AM'.
192 =.
(amt 1788562, "UNEARNED-10011561',"Opening balance", 2,")
2 October 17 08.30.00 AM', 192 + amt 1788562, "UNEARNED-10011561',
"Revenue deferred credit", 2, 08.30.00 2 October 17: "(, 192)-amt"
1788562,
"WON-10011561',
"Revenue."
4,
2 OCTOBER 17 08.30.00 AM'.
192,
AMT 1788562,
' NON-10011561',
"Opening balance"
2,
2 OCTOBER 17 08.30.00 AM'.
193 = amt 1788562,
' NON-10011561',
"Closing balance."
2,
2 OCTOBER 17 08.30.00 AM'.
192,
AMT 1788562,
' NON-10011561',
"Deferred income of credit."
2,
2 OCTOBER 17 08.30.00 AM'.
193 = 0,
AMT 1788562,
' NON-10011561',
"Closing balance."
2,
2 OCTOBER 17 08.30.00 AM'.
193 =.
(amt 1788562, "UNEARNED-10011561',"Opening balance", 2,")
2 October 17 08.30.00 AM', 193 + amt 1788562, "UNEARNED-10011561',
("Revenue deferred credit", 2, 08.30.00 2 October 17: ', 193)-amt
1788562,
"WON-10011561',
"Revenue."
4,
2 OCTOBER 17 08.30.00 AM'.
193)
ORDER BY period_no, entry_type_no;
The query above works fine. But I hardcoded the values. I want to do the same operation for the other account number which will have different non periodical. How can I reach it?
Thanks in advance.
And why do you need a model for that? If I understand the reqs OK:
with t as)
Select acct_no,
"U-11561' gl_code,
"Deferred income credit ' entry_type_label,.
2 entry_type_no,
orig_chg_start_date,
period_no,
Max)
case entry_type_no
When 2 then - amt
0 otherwise
end
) amt,.
Description of the "invoice."
2 weight
from table_one
Acct_no group,
orig_chg_start_date,
period_no
Union of all the
Select acct_no,
gl_code,
entry_type_label,
entry_type_no,
orig_chg_start_date,
period_no,
-amt,
Description "paid the Bill."
3 weight
from table_one
where entry_type_no = 4
Union of all the
Select acct_no,
"U-11561' gl_code,
"Deferred income credit ' entry_type_label,.
2 entry_type_no,
orig_chg_start_date,
period_no,
AMT 0,.
case lvl
When 1 then 'account opening. "
of other "close account."
description of the end,
case lvl
When 1 then 1
another 99
end weight
from table_one,.
(select level lvl from dual connect by level<=>=>
Acct_no group,
orig_chg_start_date,
period_no,
LVL
)
Select acct_no,
gl_code,
entry_type_label,
entry_type_no,
orig_chg_start_date,
period_no,
case
what weight (sum) (1.99) can
case weight
When 2 then amt
When 3 then - amt
0 otherwise
end
)
During)
acct_no partition
order of period_no,
weight
)
AMT else
AMT of end,
Description
t
order of acct_no,
period_no,
weight
/
ACCT_NO GL_CODE ENTRY_TYPE_LABEL ENTRY_TYPE_NO ORIG_CHG_START_DATE PERIOD_NO AMT DESCRIPTION
------- ---------------------------- ----------------------- ------------- --------------------- --------- ---------- ---------------
1001 U-11561 deferred revenue credit 2 2 October 17 08.30.00 AM 100 0 opening account
1001 U-11561 deferred revenue credit 2 Bill October 2, 17 08.30.00 AM 100 44
E-11561 1001 recipes 4 08.30.00 2 October 17: 100 13.87 paid invoice1001 U-11561 deferred revenue credit 2 2 October 17 08.30.00 AM 100 30.13 closing account
1001 U-11561 deferred revenue credit 2 2 October 17 08.30.00 AM 101 30.13 opening account
1001 U-11561 deferred revenue credit 2 2 October 17 08.30.00 AM 101 0 Bill
E-11561 1001 recipes 4 08.30.00 2 October 17: 101 14,35 paid invoice1001 U-11561 deferred revenue credit 2 2 October 17 08.30.00 AM 101 15.78 closing account
1001 U-11561 deferred revenue credit 2 2 October 17 08.30.00 AM 102 15.78 opening account
1001 U-11561 deferred revenue credit 2 2 October 17 08.30.00 AM 102 Bill 0
E-11561 1001 recipes 4 08.30.00 2 October 17: 102 14.83 invoice paid1001 U-11561 deferred revenue credit 2 2 October 17 08.30.00 AM 102.95 close account
1001 U-11561 deferred revenue credit 2 2 October 17 08.30.00 AM 103.95 opening account
1001 U-11561 deferred revenue credit 2 2 October 17 08.30.00 AM 103 Bill 0
E-11561 1001 recipes 4 08.30.00 2 October 17: 103.95 invoice paid1001 U-11561 deferred revenue credit 2 2 October 17 08.30.00 AM 103 0 closing account
1002 U-11561 deferred revenue credit 2 17 November 13 09.30.00 AM 104 0 opening account
1002 U-11561 deferred revenue credit 2 17 November 13 09.30.00 AM 60 104 Bill
1002 fixed costs recurring revenue COA Code 4 09.30.00 November 17, 13 h 104 9.13 invoice paid1002 U-11561 deferred revenue credit 2 17 November 13 09.30.00 AM 104 50.87 closing account
1002 U-11561 deferred revenue credit 2 17 November 13 09.30.00 AM 105 50.87 opening account
1002 U-11561 deferred revenue credit 2 December 20, 13 09.30.00 AM 105 50.87 opening account
1002 U-11561 deferred revenue credit 2 09.30.00 December 20, 13 h 105 19.24 invoice
1002 U-11561 deferred revenue credit 2 17 November 13 09.30.00 AM 105 0 Bill
1002 fixed costs recurring revenue COA Code 4 09.30.00 November 17, 13 h 105 44,91 paid invoice1002 fixed costs recurring revenue COA Code 4 December 20, 13 09.30.00 AM 105 - 7.82 Bill paid
1002 fixed costs recurring revenue COA Code 4 09.30.00 December 20, 13 h 105 3.93 invoice paid
1002 U-11561 deferred revenue credit 2 17 November 13 09.30.00 AM 105 29.09 closing account
1002 U-11561 deferred revenue credit 2 December 20, 13 09.30.00 AM 105 29.09 closing account
1002 U-11561 deferred revenue credit 2 17 November 13 09.30.00 AM 106 29.09 opening account
1002 U-11561 deferred revenue credit 2 December 20, 13 09.30.00 AM 106 29.09 opening account
1002 U-11561 deferred revenue credit 2 December 20, 13 09.30.00 AM 106 0 Bill
1002 U-11561 deferred revenue credit 2 17 November 13 09.30.00 AM 106 0 Bill
1002 fixed costs recurring revenue COA Code 4 09.30.00 November 17, 13 h 106 44,91 paid invoice1002 fixed costs recurring revenue COA Code 4 09.30.00 December 20, 13 h 106 11.75 invoice paid
1002 fixed costs recurring revenue COA Code 4 December 20, 13 09.30.00 AM - 23.47 106 paid
1002 U-11561 deferred revenue credit 2 17 November 13 09.30.00 AM 106-4.1 closing account
1002 U-11561 deferred revenue credit 2 December 20, 13 09.30.00 AM 106-4.1 closing account
1002 U-11561 deferred revenue credit 2 December 20, 13 09.30.00 AM 107 - 4.1 opening account
1002 U-11561 deferred revenue credit 2 17 November 13 09.30.00 AM 107 - 4.1 opening account
1002 U-11561 deferred revenue credit 2 17 November 13 09.30.00 AM 107 Bill 0
1002 U-11561 deferred revenue credit 2 December 20, 13 09.30.00 AM 107 Bill 0
1002 fixed costs recurring revenue COA Code 4 December 20, 13 09.30.00 AM - 13.69 107 paid invoice1002 fixed costs recurring revenue COA Code 4 November 17, 13 09.30.00 AM 107 35.91 invoice paid
1002 fixed costs recurring revenue COA Code 4 09.30.00 20 December 13 AM 107 6,86 invoice paid
1002 U-11561 deferred revenue credit 2 17 November 13 09.30.00 AM 107 - 33.18 closing account
1002 U-11561 deferred revenue credit 2 December 20, 13 09.30.00 AM 107 - 33.18 closing account47 selected lines.
SQL >
SY.
-
Clause type SQL how can the others cannot?
Hi all
I met a topic called the type Clause when I was reading Pro Oracle SQL by Karen Morton, Kerry Osborne, Robyn SandsRiyaj Ntanguand Jared still. I just read the chapter and did some practice on my local machine. It is obvious that it is a very powerful feature. And I also reachered on the web and found out that it is used for spreadsheets (excel etc.). Can someone please give me a simple example which, in which case one must use the clauses types SQL Analytic Functions or group Advanced functions cannot cure?
Either said by the way, I recommend strongly Pro SQL Oracle book to all who want to learn the knowledge of SQL.
Thanks in advance
Hello
In short Yes, the TYPE clause allows you to perform calculations of "spreadsheet-like". With the help of the clause TYPE is quite rare. Now with the introduction of the WITH recursive clause in 11g 2, you can almost everything in SQL, do not even talk about the pattern match feature introduced in 12 c.
You can probably do now with analytical functions / recursive clause the clause of MODEL can do. And I must say that it is a shame that the TYPE clause has never been improved since its introduction in 10g.
In my view, the clause TYPE can come in handy when you need cross reference calculations (typically dealing with periods such as dates, years, weeks). For example, I personally used a MODEL clause for an analysis of sales time, where I watch the sales of previous years to find a pattern for the current. References of cells in a MODEL clause allows to easily, something like [my_year, my_week] model = local_pattern [(y ENTRE CV()-2 ET CV) (-1, w BETWEEN (CV-2) RESUME AND () + 2)]
-
Include as the value of the clause in the list of results
I have several similar terms on the same column in my query. Is it possible to include the value of the clause type in the result set?
For example
SELECT * ADDR ADDRESS WHERE
addr. Line LIKE '% 1% '.
OR addr.line LIKE '% 2 '.
OR addr.line LIKE '% 3% '.
OR addr.line LIKE '% 4% ';
The result set contains all the addresses including ONE, TWO, THREE, FOUR. Now, I would like to see the result defined as
Address1ONE | ONE
Address2TWO | TWO
THREEaddr | THREE
any clue?
R
Use CASE:
SELECT addr.line,
CASE
WHEN addr.line LIKE '% 1% ' THEN 'ONE '.
WHEN addr.line LIKE '% 2% ', THEN 'TWO '.
WHEN addr.line LIKE '% 3% ' THEN 'THREE '.
ELSE 'FOUR '.
END
The ADDRESS ADDR
WHERE addr.line LIKE '% 1% '.
OR addr.line LIKE '% 2 '.
OR addr.line LIKE '% 3% '.
OR addr.line LIKE '% 4% '.
/
SY.
-
Clause type and its Alternative to Oracle 10 g
Hello
I went through a few examples on the clause type in oracle 10g, but not very clear on this subject. can someone please explain it to me in detail and when to use it.
Also, how can we create the same performance as that of the model clause by using other means.[http://stanford.edu/dept/itss/docs/oracle/10g/server.101/b10736/sqlmodel.htm#i1006326]
Reference Models In addition to the multi-dimensional array on which rules operate, which is called the main model, one or more read-only multi-dimensional arrays, called reference models, can be created and referenced in the MODEL clause to act as look-up tables. Like the main model, a reference model is defined over a query block and has DIMENSION BY and MEASURES clauses to indicate its dimensions and measures respectively. A reference model is created by the following subclause: REFERENCE model_name ON (query) DIMENSION BY (cols) MEASURES (cols) [reference options] Like the main model, a multi-dimensional array for the reference model is built before evaluating the rules. But, unlike the main model, reference models are read-only in that their cells cannot be updated and no new cells can be inserted after they are built. Thus, the rules in the main model can access cells of a reference model, but they cannot update or insert new cells into the reference model. References to the cells of a reference model can only appear on the right side of rules. You can view reference models as look-up tables on which the rules of the main model perform look-ups to obtain cell values. The following is an example using a currency conversion table as a reference model: CREATE TABLE dollar_conv_tbl(country VARCHAR2(30), exchange_rate NUMBER); INSERT INTO dollar_conv_tbl VALUES('Poland', 0.25); INSERT INTO dollar_conv_tbl VALUES('France', 0.14); ... Now, to convert the projected sales of Poland and France for 2003 to the US dollar, you can use the dollar conversion table as a reference model as in the following: SELECT country, year, sales, dollar_sales FROM sales_view GROUP BY country, year MODEL REFERENCE conv_ref ON (SELECT country, exchange_rate FROM dollar_conv_tbl) DIMENSION BY (country) MEASURES (exchange_rate) IGNORE NAV MAIN conversion DIMENSION BY (country, year) MEASURES (SUM(sales) sales, SUM(sales) dollar_sales) IGNORE NAV RULES (dollar_sales['France', 2003] = sales[CV(country), 2002] * 1.02 * conv_ref.exchange_rate['France'], dollar_sales['Poland', 2003] = sales['Poland', 2002] * 1.05 * exchange_rate['Poland']); Observe in this example that: A one dimensional reference model named conv_ref is created on rows from the table dollar_conv_tbl and that its measure exchange_rate has been referenced in the rules of the main model. The main model (called conversion) has two dimensions, country and year, whereas the reference model conv_ref has one dimension, country. Different styles of accessing the exchange_rate measure of the reference model. For France, it is rather explicit with model_name.measure_name notation conv_ref.exchange_rate, whereas for Poland, it is a simple measure_name reference exchange_rate. The former notation needs to be used to resolve any ambiguities in column names across main and reference models. Growth rates, in this example, are hard coded in the rules. The growth rate for France is 2% and that of Poland is 5%. But they could come from a separate table and you can have a reference model defined on top of that. Assume that you have a growth_rate(country, year, rate) table defined as the following: CREATE TABLE growth_rate_tbl(country VARCHAR2(30), year NUMBER, growth_rate NUMBER); INSERT INTO growth_rate_tbl VALUES('Poland', 2002, 2.5); INSERT INTO growth_rate_tbl VALUES('Poland', 2003, 5); ... INSERT INTO growth_rate_tbl VALUES('France', 2002, 3); INSERT INTO growth_rate_tbl VALUES('France', 2003, 2.5); Then the following query computes the projected sales in dollars for 2003 for all countries: SELECT country, year, sales, dollar_sales FROM sales_view GROUP BY country, year MODEL REFERENCE conv_ref ON (SELECT country, exchange_rate FROM dollar_conv_tbl) DIMENSION BY (country c) MEASURES (exchange_rate) IGNORE NAV REFERENCE growth_ref ON (SELECT country, year, growth_rate FROM growth_rate_tbl) DIMENSION BY (country c, year y) MEASURES (growth_rate) IGNORE NAV MAIN projection DIMENSION BY (country, year) MEASURES (SUM(sales) sales, 0 dollar_sales) IGNORE NAV RULES (dollar_sales[ANY, 2003] = sales[CV(country), 2002] * growth_rate[CV(country), CV(year)] * exchange_rate[CV(country)]);
-
Need HELP to change the NAT type to open on Linksys E2000.
I was wondering if anyone could tell me how to change my nat from moderate to open so I can play xbox without any problems. But the strange thing is my nat was open, but it changed to moderate and I recently bought the linksys e2000 and it was open at first, but no more. If anyone can help me?
Follow the below mentioned settings, then check.
Open an Internet Explorer browser on your computer (desktop) wired page. In the address bar type - 192.168.1.1 and press ENTER...
Let the empty user name & password use admin lowercase...
On the Configuration tab change the size of the MTU to 1365, then click on save settings...
Click the 'Administration' tab and disable the UPnP option and click on save settings...
Click on the tab "Games and Applications" and then click the sub-tab "Port Range Forwarding"...
(1) on the first line in the box, type Application in ABC, in the start box, type in 53 and type in 3074 service box, leave the Protocol as and under type 192.168.1.20 ip address and check the box to enable, click on save settings once it's been...
(2) once you return to the game to the top page, click the Security tab and uncheck block anonymous Internet requests and click on save settings...
(3) click on the status tab, and then note the DNS1 and DNS2 addresses...
(4) address IP, Goto settings XBox network settings and assign the following on your Xbox and select manual IP settings
IP address:-192.168.1.20, subnet mask:-255.255.255.0 default gateway:-192.168.1.1...
(5) also assign addresses DNS on Xbox
Use DNS1 and DNS2 addresses you took note of the primary router as secondary DNS & DNS status tab for the xbox...
(6) turn off your modem, router and Xbox... Wait a minute...
(7) plug the power to the modem first, wait a minute and plug the router power cable, wait another minute and turn on the Xbox and... test it connects...
IP address: part 192.168.X. [last intellectual property in your device] for example if static ip given to the unit's 192.168.X.10 get the last part and put it in the empty box. -
AT THE OPENING OF THE DIFFERENT TYPES OF FILES WINDOWS MEDIA PLAYER OPENS INDICATING NOT TO SUPPORT THE TYPE OF FILE OR CODEC. WHY? Help, please!
If you try new types of files that WMP is not pregnant then it will warn you that they only peuvent malfunction.
I got when I started to use video files to .ts format - he warned me, and then I told him to go ahead & try anyway, so he did and they worked.
If say you your WMP to try to use the format, then you can include the results in your response to the request of zig - zag for more info - make sure to specify what types of files they are. Note the messages you get from WMP because it will give more information that just what file extension are files - video files can be, for example, the extensions of files .ts taking video & audio formats of all kinds such as mpeg2 or mpeg4 & mp3 or ac3.
Maybe you are looking for
-
I was in the middle of some downloads from the Internet and all of a sudden I had little Russian search boxes which appeared in and basically it seems that I loaded a program Russian Yandex. It seems to be a browser. I got rid of everything that was
-
Satellite U - restarts and restarts so that the installer of Windows 7
I just bought my new laptop Toshiba from Harvey Norman. When I try to put in place, it just restarts again and again and I can't do anything to stop it. It says installation configuration. Harvey Norman is trying to tell me that it will take hours fo
-
What is the problem with my Windows Photo Gallery Previewer?
The preview tool does not work normally. This shows just everything in the bottom of the screen on that I was previously. For example, this the forum web page is in the background if I switch on at the Gallery of photo this time when the Viewer is op
-
Hello. I have a BB of Q10. I did a cleanup of security and after doing this, I got an error on the screen (www.bberror.com/bb10-0015) I tried to reload my software from the link of blackberry, now I have a blank screen with a red led will blink twice
-
Problems with the windows troubleshooting utility. Error code: 0 x 80070002
Original title: Problems with the windows troubleshooting tool Whenever I run the Troubleshooting Guide for things like a problem of wireless network I get this error An error occurred during troubleshooting: An unexpected error has occurred. The Tro