Analytical calcualtion
I have two tables
model_details
with model_details like)
Select 470123 model_id, to_date (April 22, 13 ') store_date, null, 300 back_inv, total_inv of the double null store_qty
Union of all the
Select 470123 model_id, to_date (April 29, 13 ') store_date, store_qty 100, back_inv null, null double total_inv
Union of all the
Select 470123 model_id, to_date (' 6 May 13') store_date, store_qty 100, back_inv null, null double total_inv
Union of all the
Select 470123 model_id, to_date (13 May 13 ') store_date, store_qty 150, back_inv null, null double total_inv
Union of all the
Select 470123 model_id, to_date (May 20, 13 ') store_date, store_qty 300, null, null total_inv double back_inv
Union of all the
Select 470123 model_id, to_date (May 27, 13 ') store_date, 200, null, null total_inv double back_inv store_qty
) select * from model_details
on_run_model
with on_run_model as
(
Select 470123 model_id, to_date (April 29, 13 ') store_date, 10 on_run_qty of the double
Union of all the
Select 470123 model_id, to_date (' 6 May 13') store_date, 20 on_run_qty of the double
Union of all the
Select 470123 model_id, to_date (13 May 13 ') store_date, 30 on_run_qty of the double
Union of all the
Select 470123 model_id, to_date (May 20, 13 ') store_date, 40 on_run_qty of double
Union of all the
Select 470123 model_id, to_date (May 27, 13 ') store_date, 20 on_run_qty of the double
)
Select * from on_run_model
I need to calculate the total_inv for each week (between 29 April 13 to May 27, 13)
who is
Calcullation for back_inv for the current week = previous week back_inv + on_run_qty of the current week (from on_run_model table)
total_inv calculation is = store_qty + back_inv of the previous week
output must be
model_details
Model | store_date | Store_qty | back_inv | total_inv |
up to 4/22/2103 | 300 | |||
470123 | 29 April 13 | 100 | 310 | 400 |
470123 | May 6, 13 |
100
330
410
470123
13 May 13
150
360
480
470123
May 20, 13
300
400
660
470123
27 May 13
200
420
600
on_run_model:
29/04/2013 | 10 |
06/05/2013 | 20 |
13/05/2013 | 30 |
20/05/2013 | 40 |
27/05/2013 | 20 |
Hello
Here's one way:
WITH got_back_inv AS
(
SELECT d.model_id
d.store_date
d.store_qty
r.on_run_qty
SUM (d.back_inv) OVER (PARTITION BY d.model_id)
+ NVL (SUM (r.on_run_qty) OVER (PARTITION BY r.model_id
ORDER BY r.store_date
)
0
) AS back_inv
OF model_details d
LEFT OUTER JOIN on_run_model r ON r.model_id = d.model_id
AND r.store_date = d.store_date
)
SELECT model_id, store_date, store_qty, back_inv
back_inv + store_qty - on_run_qty AS total_inv
OF got_back_inv
ORDER BY model_id
store_date
;
I'm just guessing in the role of model_id in this problem.
Always pass arguments at least 2 to TO_DATE. TO_DATE calling with 1 single argument has all the bad effects of not calling TO_DATE not at all, and it is more difficult to code.
Tags: Database
Similar Questions
-
Why Google analytic freezes up when I go on Kijiji?
I use a MiniMac with OS 10.4.11. It's an old 1.42 Ghz. Intel chip pre. I use Firefox 3.6.6 and when I try to go to Gumtree, for no reason, analytical Google appears at the bottom left of my screen, and the load bar shows approximately 0 of fact. And that's where it freezes COMPLETELY. The blue line on the load bar doesn't even have the worm turning, indicating that it works. Please correct, but whatever you do, don't tell me I have a worm or something. I don't know that it's just spyware of Google screwing.
URL of affected sites
I had the same problem, but using the Safari browser for Mac seems to be the solution for now.
-
Is there an analytical test for the wireless?
Does anyone know of an analytical test hardware wireless for a MacBook Pro? I'm having persistent problems with a periodic loss of binding and were able to verify that the router is not the problem, so I need to look at the MB Pro.
Wireless diagnosis
https://support.Apple.com/en-us/HT202663
https://support.Apple.com/kb/PH21677?viewlocale=en_US&locale=en_US
-
original title: google analytics popups
Ive been having problems with the Google analytic pop-up windows all of a sudden now pages break or redirected, I've ran Malware, Windows Defender, a direct care, Avira, Avast and F-secure, and nothing seems to have read on other forums to help, that his may be a Trojan horse: Trojan.osx.Dnschanger.B... ive also rebooted my router as suggested in some forums , but nothing seems to help?
Hi NicolaaTC,
See the links below and check if it works.
What is the browser hijacking?
http://www.Microsoft.com/protect/terms/hijacking.aspx
Difficulty of your web browser hijacked
http://www.Microsoft.com/security/spyware/browserhijacking.aspx
-
Google analytic API for Blackberry
Hello
I want to add Google analytic API on my Blackberry project. Please help me.
Thank you
To use the analytical Blackberry service, you can take the help of the development of analytical service guide.
-
with regard to the analytical Service
I want to use analytical service in my application, I have read the documentation, I'm new to BB please someone explain to me the following code.
Don't forget, our job is NOT to read your code, our job is to answer your questions. Validation code and saying: 'Please explain' are just too bad that the validation code and saying: "he doesn't." We have no idea of what you need to explain, and most importantly, what you already understand. So unless if we are ready to write a detailed explanation, then we don't answer questions such as "Please explain" because the question would take too long.
Take the time to write down the questions you have in detail, in this case, it seems to me that you don't understand the settings. Can you please tell us the settings do not understand, referring you to documentation and the words in the documentation that are not clear to you.
Sorry to go about this, but it is in your interest to do the research and explain your problem clearly and completely. You have actually lost 6 hours already on this issue because you expect people to do this work for you. Your job is to minimize the effort that the players must go, by being clear on your application early.
In this case, your original question could have been along the lines:
"I don't understand what are these parameters, can anyone point me to any documentation that could help me?
Alternatively, if you already found the documentation, the question should have been along the lines that I asked above.
This in the future, if you think that people respond. And to answer my above question (in bold) to get a response on this issue.
Ok?
-
Analytical universal use in apps
I want to know,
Can I use google universal analytical in my blackberry app?
I had a quick glance and I see no reason why you couldn't use it
-
WebWorks and analytical Services
Is there a way to get the job of service Analytics of burst in WebWorks app? I don't know what I'm going to lose on creating a Web application in the management console Flurry.
In fact, Flurry * just * launched a SDK MobileWeb (yesterday), then you can now use their analytical services in a WebWorks app:
http://support.flurry.com/index.php?title=Analytics/FAQ/MobileWeb
-
Analytical Playtomic game does not work on Playbook?
Hello
I created my Adobe AIR 3.1 application (ActionScript 3) and I used the analytical game provided by Playtomic.
While I tested the application during development, analytical data were sent & collected correctly.
However... after that I wrote the app in App World there is no new data gathered.
My question is: If the team review Blackberry blocked this feature and not told me? I really wish I could see my analytics ingame.
Okay, that was a problem of Playtomic.
- false URL needs like this Log.View (xxxx, "xxxxxx", "http://Playtomic.Test");
- remove these lines of Log.as in the playtomic package
Security.allowDomain ("http://g" + Log.GUID + ".api.playtomic.com/");
Security.allowInsecureDomain ("http://g" + Log.GUID + ".api.playtomic.com/");
-
Cannot use analytical functions such as lag/lead in odi components 12 c except in the expression
Hi I am a beginner of ODI 12 c
I'm trying to get the last two comments made on the product for a given product id. and load them into a target.
I have a source table something like
Product SR_NO comments LAST_UPDATED_TS
1 good car 2015/05/15 08:30:25
1 car average 2015/05/15 10:30:25
Jeep 2 super 2015/05/15 11:30:25
1 car bad 2015/05/15 11:30:25
Jeep 2 horrible 2015/05/15 09:30:25
Jeep 2 excellent 2015/05/15 12:30:25
I want a target table based on their last timestamp updated as (last two comments)
SR_NO Comment1 Comment2
1 bad average
2 super excellent
I used the logic below to get records in SQL Developer but in ODI 12 c, I'm not able to do this by mapping a source to the target table by applying analytical functions to the columns in the target table. Can someone help me solve this problem
SELECT * FROM)
SELECT SR_NO Comment1, LAG(Comment1,1,) ON Comment2 (SR_NO ORDER BY LAST_UPDATED_TS ASC PARTITION),
ROW_NUMBER() ON RN (SCORE FROM SR_NO ORDER BY LAST_UPDATED_TS DESC)
FROM Source_table
) M
WHERE RN = 1
;
UM, I'm afraid that ODI puts the filter too early in the request, if it generates:
SELECT * FROM)
SELECT SR_NO Comment1, LAG(Comment1,1,) ON Comment2 (SR_NO ORDER BY LAST_UPDATED_TS ASC PARTITION),
ROW_NUMBER() ON RN (SCORE FROM SR_NO ORDER BY LAST_UPDATED_TS DESC)
FROM Source_table
WHERE RN = 1
) M
;
Instead of:
SELECT * FROM)
SELECT SR_NO Comment1, LAG(Comment1,1,) ON Comment2 (SR_NO ORDER BY LAST_UPDATED_TS ASC PARTITION),
ROW_NUMBER() ON RN (SCORE FROM SR_NO ORDER BY LAST_UPDATED_TS DESC)
FROM Source_table
) M
WHERE RN = 1
;
Even by changing the 'run on Hint"of your component of the expression to get there on the source, the request will stay the same.
I think the easiest solution for you is to put everything before the filter in a reusable mapping with a signature of output. Then drag this reusable in your mapping as the new source and check the box "subselect enabled."
Your final mapping should look like this:
It will be useful.
Kind regards
JeromeFr
-
Any information the OAG analytical monitoring
I'm watching some REST API I configured in the oracle api gateway using oaganalytics, but I'm
The database currently contains no data.
Please check that the server is written in the database.
At the OAG Analytics UI. I think I have all controls enabled for monitoring at work, but I can't understand why it doesn't work
Any ideas?
Thanks in advance
Hello
You can check this link on the oracle support:
How to keep the real analytical data in a database on the OAG 11.1.2.4.0? (Doc ID 2105854.1)
Kind regards
Anshul
-
Which analytical function to use?
Hi gurus,DB - Oracle 11 g 2
I followed the examples of data in the table test_a.
col1 col2 col3
----- ------- --------
x y y
p q y
a b y
p q y
t r y
p q y
The col3 column is always 'y '. But here's the data p, q, there is repeated 3 times (duplicate) and if this is the case I want to update only the first recordings like "n" col3 it is to say p, q, n. rest will be as it is.
I am able to get the row_number() for it but not able to do this.
Select col1, clo2, clo3 row_number() over (partition by col2) arrested by col1 as test_a r_num
Would it be possible directly by any analytic function?
Thank you
SID
COL4 is logical...
Something like that?
with x as)
Select col1, col2 ' x' 'y', 'y' col3 col4 1 Union double all the
Select 'p' col1, col2 'q', 'y' col3 col4 2 Union double all the
Select 'a' col1, col2 'b', 'y' col3 col4 3 of all the double union
Select 'p' col1, col2 'q', 'y' col3 col4 4 Union double all the
Select 't' col1, col2 'r', 'y' col3, col4 5 Union double all the
Select 'p' col1, col2 'q', 'y' col3 col4 6 double
)
---
Select * from)
Select x.*,
ROW_NUMBER() on rn1 (score of col1, col2, col3 col4 sort),
ROW_NUMBER() on rn2 (partition by col1, col2, col3 col4 desc sorting)
x
)
where rn1 = 1 and rn2 <> 1;
Understand the logic and simply change SELECT a query to UPDATE...
-
How to calculate the top 100 in analytical report of obiee 11g?
Hello
I am creting report Analytics obiee 11g.
I plug 5 columns, balance, status of the loan, district loantype.
I want to display the data from the highest of 5 columns in the analytical report...
For this report, I would like to add customized lines...
My requiremt, I want to show the top 100 sales, the total amount outstanding
and I want to add personal calculation as (total of balances / top 100 outstanding balance) * 100
Please help me,
I tried, I don't get.
Please help me, how calculate these?...
Thank you and best regards,
A.Kavya
Hello Kayva,
First of all, must be defined, the grade you want, ask yourself, if you want to rank by period, branch etc, so you must use "RANK (according TO SIZE).
I made a sample with the similar columns you use, please give.
I've done 4 criteria using 'UNION' (not 'UNION ALL', not 'INTERSTECT', 'LESS'):
And my results are:
Check it out:
1st test:-J' have the sum 187 157 538.57 as the sum of the top 10 projects, the Company (Empresa) and period (Mesanodocum)
2dont criteria: -check the second line "SumaTotalProyectos" which is the sum total of society in Ene-2015 (January 2015) for all projects. Who is 211 249 318,42
3 criteria:-check the 187 157 538.57 which is the sum of the top 10 projects
4 criteria: -which is the percentage of it, 187 157 538.57 / 211 249 318,42 = 88.60%
How can you put?
1. allows you to check the criteria 1: the sum of the top 10 projects
Check the filter of RANK
2 to check the 2 criteria: total sum of society
3 to check the 3 criteria: ranking of the sum
4 to ensure criteria 4: percentage
Note:
As you can see I have two projects "columns", I need to get the sum of ranking, for example, you must do a ranking by branch and get the same, has twice this column to your criteria and after it allowed you to exclude.
Kind regards
-
Oracle 11g Release 2
I'm assuming that the best solution is the use of analytical functions.
create table test3 ( part_type_id varchar2(50) ,group_id number ,part_desc_id number ,part_cmt varchar2(50) ) / insert into test3 values( 'ABC123',1,10,'comment1'); insert into test3 values( 'ABC123',1,10,'comment2'); insert into test3 values( 'ABC123',2,15,'comment1'); insert into test3 values( 'ABC123',2,15,'comment2'); insert into test3 values( 'EFG123',25,75,'comment3'); insert into test3 values( 'EFG123',25,75,'comment4'); insert into test3 values( 'EFG123',25,75,'comment5'); insert into test3 values( 'XYZ123',1,10,'comment6'); insert into test3 values( 'XYZ123',2,15,'comment7'); commit; select * from test3; PART_TYPE_ID GROUP_ID PART_DESC_ID PART_CMT -------------------- ---------- ------------ -------------------- ABC123 1 10 comment1 ABC123 1 10 comment2 ABC123 2 15 comment1 ABC123 2 15 comment2 EDG123 25 75 comment3 EDG123 25 75 comment4 EDG123 25 75 comment5 XYZ123 1 10 comment6 XYZ123 2 15 comment7 9 rows selected. Desired output: PART_TYPE_ID GROUP_ID PART_DESC_ID PART_CMT -------------------- ---------- ------------ -------------------- ABC123 1 10 comment1 ABC123 2 15 comment1 XYZ123 1 10 comment1 XYZ123 2 15 comment2 RULE: where one part_type_id has multiple (2 or more distinct combinations) of group_id/part_desc_id NOTE: There are about 12 columns in the table, for brevity I only included 4.
Post edited by: orclrunner was updated desired output and rule
Hello
Here's one way:
WITH got_d_count AS
(
SELECT part_type_id, group_id, part_desc_id
MIN (part_cmt) AS min_part_cmt
COUNT AS d_count (*) OVER (PARTITION BY part_type_id)
OF test3
GROUP BY part_type_id, group_id, part_desc_id
)
SELECT DISTINCT
group_id, part_desc_id, part_type_id, min_part_cmt
OF got_d_count
WHERE d_count > 1
;
Output:
GROUP_ID PART_DESC_ID MIN_PART_CMT PART_TYPE_ID
------------ ---------- ------------ ------------
ABC123 1 10 comment1
ABC123 2 15 comment1
XYZ123 1 10 comment6
XYZ123 2 15 comment7
Analytical functions, such as the COUNTY and MIN, many global versions, in addition, it can give the same results. Use the analytical versions when each row of output corresponds to exactly 1 row of input and the aggregate and GROUP BY version when each line of output corresponds to a group of lines 1 or more input. In this issue, each line of output appears to be a group of input lines having the same group_id, part_type_id, and part_desc_id (I'm guessing just, this only has never stated), so I used GROUP BY to get 1 row of output for every input lines.
-
How to define the condition in the analytic function
Oracle 10g version
Hi all
I have the following data samples:
Examples of data
WITH DATA AS
(
SELECT 100 case_id, next_date, to_date('01-feb-2015','dd-mon-yyyy') UNION double, ALL crt_date to_date('01-jan-2015','dd-mon-yyyy')
SELECT 100 case_id, next_date, to_date('01-mar-2015','dd-mon-yyyy') UNION double, ALL crt_date to_date('01-feb-2015','dd-mon-yyyy')
SELECT 100 case_id, next_date, to_date('01-apr-2015','dd-mon-yyyy') UNION double, ALL crt_date to_date('01-may-2015','dd-mon-yyyy')
SELECT 100 case_id, to_date('01-jun-2015','dd-mon-yyyy') next_date, to_date('01-apr-2015','dd-mon-yyyy') crt_date FROM dual
)
SELECT wagneur, MIN (next_date) OVER (PARTITION BY case_id) min_dt_analytical
,(
SELECT MIN (next_date) DATA dd
WHERE dd.case_id = d.case_id
AND dd.next_date > crt_date
) min_dt_sub_query
DATA d
;
My question is that I get min_dt_sub_query using sub query but I want to use the analytical instead of query sub function so I created min_dt_analytical column, but I do not have how to give the condition that is AND dd.next_date > crt_date analytical so that I can get the same result as min_dt_sub_query data accordingly. Thanks in advance
Concerning
MIT
Do not know if I understood your needs... but... something like that?
WITH DATA AS (SELECT 100 case_id, next_date, to_date('01-feb-2015','dd-mon-yyyy') UNION double, ALL crt_date to_date('01-jan-2015','dd-mon-yyyy')
SELECT the 100 case_id, next_date, to_date('01-mar-2015','dd-mon-yyyy') UNION double, ALL crt_date to_date('01-feb-2015','dd-mon-yyyy')
SELECT the 100 case_id, next_date, to_date('01-apr-2015','dd-mon-yyyy') UNION double, ALL crt_date to_date('01-may-2015','dd-mon-yyyy')
SELECT 100 case_id, next_date, to_date('01-apr-2015','dd-mon-yyyy') double crt_date to_date('01-jun-2015','dd-mon-yyyy'))
SELECT d.
MIN (next_date) OVER (PARTITION BY case_id) min_dt_analytical
MIN(CASE WHEN next_date > crt_date THEN next_date ELSE NULL END) OVER (PARTITION BY case_id) AS min_dt_sub_query2
DATA d;
HTH
Maybe you are looking for
-
Script: chrome://tavgp/content/libs/include.js:595
-
XControl always locked when it is used in class - possible bug?
Hello It is no different in this issue. However, I think the question is slightly different and maybe a bug. If the following steps: Create a project, create an XControl create a class, Add an instance of the XControl to a class method You should see
-
Hello I have problem on doing "Image mask" in c#. I tried to use "Image mask of the KING" Assistant NI mink and create C code. In C code, it uses "imaqROIToMask()"; "imaqMask();" "imaqGetROIBoundingBox();" I find similar functions by using the comman
-
Hello I W520 with i7-2670QM and also, I also E530 with i7-3612 QM. I would like to know can I swap the processors in computers. Thank you
-
I can only connect to the network via a wired connection. Wireless does not connect.
Wireless does not work but internet will work when plugged into router direstly Wireless does not work but internet will work when plugged into router direstly I reset my router repeatedly and still will not work.