calculate the value of the query help
Hi allFollowing the script nicely:
CREATE TABLE ACCOUNT_LOOCKUP
(
SERIAL_ID NUMBER,
ACCOUNT_ID NUMBER,
ACCOUNT_RATE NUMBER,
ACCOUNT_MAX NUMBER
)
ALTER TABLE ACCOUNT_LOOCKUP ADD (
CONSTRAINT PK_ACCOUNT_LOOCKUP
PRIMARY KEY
(SERIAL_ID, ACCOUNT_ID));
Insert into ACCOUNT_LOOCKUP
(SERIAL_ID, ACCOUNT_ID, ACCOUNT_RATE, ACCOUNT_MAX)
Values
(1, 1, 10, 200);
Insert into ACCOUNT_LOOCKUP
(SERIAL_ID, ACCOUNT_ID, ACCOUNT_RATE, ACCOUNT_MAX)
Values
(2, 1, 12, 150);
Insert into ACCOUNT_LOOCKUP
(SERIAL_ID, ACCOUNT_ID, ACCOUNT_RATE, ACCOUNT_MAX)
Values
(3, 1, 8, 400);
Insert into ACCOUNT_LOOCKUP
(SERIAL_ID, ACCOUNT_ID, ACCOUNT_RATE, ACCOUNT_MAX)
Values
(1, 2, 7, 100);
Insert into ACCOUNT_LOOCKUP
(SERIAL_ID, ACCOUNT_ID, ACCOUNT_RATE, ACCOUNT_MAX)
Values
(2, 2, 5, 200);
COMMIT;
SELECT * FROM ACCOUNT_LOOCKUP
SERIAL_ID ACCOUNT_ID ACCOUNT_RATE ACCOUNT_MAX
---------- ---------- ------------ -----------
1 1 10 200
2 1 12 150
3 1 8 400
1 2 7 100
2 2 5 200
CREATE TABLE ACCOUNT_AMOUNT(
ACCOUNT_ID NUMBER(10),
ACCOUNT_AMNT NUMBER(10))
Insert into ACCOUNT_AMOUNT
(ACCOUNT_ID, ACCOUNT_AMNT)
Values
(1, 9);
Insert into ACCOUNT_AMOUNT
(ACCOUNT_ID, ACCOUNT_AMNT)
Values
(1, 35);
COMMIT;
SELECT * FROM ACCOUNT_AMOUNT
ACCOUNT_ID ACCOUNT_AMNT
---------- ---------------
1 9
1 35
I want by select query calculte ACCOUNT_TOTAL every ACCOUNT_ID exists in table ACCOUNT_AMOUNT as below ,
1. every ACCOUNT_ID have SERIAL_ID and ACCOUNT_RATE and ACCOUNT_MAX in table ACCOUNT_LOOCKUP,
2. to calculte ACCOUNT_TOTAL every ACCOUNT_ID :
- order ascending SERIAL_ID exists in table ACCOUNT_LOOCKUP to every ACCOUNT_ID exists in table ACCOUNT_AMOUNT ,
- make sum ACCOUNT_AMNT every ACCOUNT_ID in table ACCOUNT_AMOUNT,
- then, copmare result (sum ACCOUNT_AMNT) with first record after ascending SERIAL_ID,
- product (sum ACCOUNT_AMNT) * ACCOUNT_RATE result as ACCOUNT_TOTAL,(in ex: sum ACCOUNT_AMNT = 44 ) ,
- if ACCOUNT_TOTAL > ACCOUNT_MAX then
* ACCOUNT_TOTAL = ACCOUNT_MAX for first record(in ex SERIAL_ID = 1 ) ,
* Goto the second record by ascending (in ex SERIAL_ID = 2 ) ,
make ( ACCOUNT_TOTAL / ACCOUNT_RATE ) for first record ,
( 200 / 10 ) result 20 >>
* calculate Remainder ACCOUNT_AMNT = the sum ACCOUNT_AMNT 44 - 20 = 24
*Goto the second record by ascending (in ex SERIAL_ID = 2 ) ,
Remainder ACCOUNT_AMNT 24 * (12) ACCOUNT_RATE for second record = 288 as ACCOUNT_TOTAL
-if ACCOUNT_TOTAL > ACCOUNT_MAX then
* ACCOUNT_TOTAL = ACCOUNT_MAX for second record(in ex SERIAL_ID = 2 ) ,
* Goto the third record by ascending (in ex SERIAL_ID = 3 ) ,
make ( ACCOUNT_TOTAL / ACCOUNT_RATE ) for second record ,
( 150 / 12 ) result 12.5
* calculate Remainder ACCOUNT_AMNT = the sum ACCOUNT_AMNT 24 - 12.5 = 11.5
Remainder ACCOUNT_AMNT 9.5 * (12) ACCOUNT_RATE for third record = 92 result as ACCOUNT_TOTAL
if result <= ACCOUNT_MAX then
ACCOUNT_TOTAL = 92
except result
------------
SERIAL_ID ACCOUNT_ID ACCOUNT_RATE ACCOUNT_MAX ACCOUNT_TOTAL ** explain **
---------- ---------- ------------ ----------- ------------- ***** sum ACCOUNT_AMNT = 44 for ACCOUNT_ID = 1from table ACCOUNT_AMOUNT ******
1 1 10 200 200 >> (44 * 10 ) = 440 >> 200 /10 rate = 20 >> 44 - 20 = 24 Remainder ACCOUNT_AMNT
2 1 12 150 150 >> (22 * 12 ) = 288 >> 150 /12 rate = 12.5 >> 24 - 12.5 = 11.5 Remainder ACCOUNT_AMNT
3 1 8 400 92 >> (11.5 * 8) = 92 And so on ....
another insert
Insert into ACCOUNT_AMOUNT
(ACCOUNT_ID, ACCOUNT_AMNT)
Values
(2, 10);
SELECT * FROM ACCOUNT_AMOUNT
ACCOUNT_ID ACCOUNT_AMNT
---------- ---------------
1 9
1 35
2 10
except result
------------
SERIAL_ID ACCOUNT_ID ACCOUNT_RATE ACCOUNT_MAX ACCOUNT_TOTAL ** explain **
---------- ---------- ------------ ----------- ------------- ***** sum ACCOUNT_AMNT = 10 for ACCOUNT_ID = 2 from table ACCOUNT_AMOUNT ******
1 1 10 200 200
2 1 12 150 150
3 1 8 400 92
1 2 7 100 70 10 * 7 = 70
Help me pleaseThanks in advance
Published by: 900510 on December 5, 2011 08:05
900510 wrote:
Hi allFirst I want to apologize for my English, this isn't flunet.
Following the script nicely:
CREATE OR REPLACE VIEW V_ACCOUNT (ACCOUNT_ID,ID,ACCOUNT_RATE,ACCOUNT_MAX,ACCOUNT_TOTAL) AS SELECT 1, 2, 10 ,200 , 0 FROM DUAL UNION SELECT 1, 5, 12 ,150 , 0 FROM DUAL UNION SELECT 1, 9, 8 ,400 , 0 FROM DUAL UNION SELECT 2 ,1, 7 ,100 , 0 FROM DUAL UNION SELECT 2 ,3 ,5 ,200 , 0 FROM DUAL ORDER BY 1,2 ACCOUNT_ID ID ACCOUNT_RATE ACCOUNT_MAX ACCOUNT_TOTAL ---------- ---------- ------------ ----------- ------------- 1 2 10 200 0 1 5 12 150 0 1 9 8 400 0 2 1 7 100 0 2 3 5 200 0
I must be missing something... in your opinion, by definition does only selected literals 5 double. How you expect what you do for any other table to change those returned by the view?
Published by: EdStevens on December 5, 2011 08:51
Tags: Database
Similar Questions
-
Hello
I'm new to the development of Oracle.
Oracle 10 g 2
My original query:
SELECT APP, count (*)
TRANSACTION
WHERE TYPE in ('ShipmentConfirmPR', 'ShipmentConfirm', 'ShipConfirm')
and the APP ("SAPPI", "SAPPI", "SAPR3") and INTERVENE ('9320 ', '9332','1208 ')
GROUP BY APP TYPE
order of the APP
the result of this query:
SAPPI 100
SAPPI 600
SAPR3 440
My requirement
And I want to have something like output
LDCS 100
TSW 600
PDC 440
IE.the APPP and STEP combinations. Must return the specified values
SAPPI & 9320-> LOC (here SAPPI IE APP is the same for both... but it's a coincidence IE APP can be sliced also)
SAPPI & 9332-> tsw
SAPR3 & 1208-> pdc
Options, I tried:
Query provided by one of the Forum members...
SELECT THE CHECK BOX
WHEN APP = "SAPP1" THEN DECODE (step, '9320', 'LSW', '9332', "TSW")
WHEN APP = "SAPR3" step = '1208' AND 'PDC '.
END app
COUNT (*)
TRANSACTION
WHERE TYPE in ('ShipmentConfirmPR', 'ShipmentConfirm', 'ShipConfirm')
AND THE APP ("SAPPI", "SAPPI", "SAPR3")
AND STEP IN ('9320', '9332', ' 1208')
GROUP BY APP, STEP
ORDER OF THE APP.
EXECUTION PLAN
| ID | Operation | Name |
------------------------------------------------------------------------
| 0 | SELECT STATEMENT |
| 1. GROUP SORT BY |
| 2. INLIST ITERATOR.
| 3. TABLE ACCESS BY INDEX ROWID | TRANSACTION |
| 4. INDEX RANGE SCAN | TRANSACTION_IDX |
The output of the query (as above) must partially match the following query (a particular combination of CLO)
SELECT count (1)
TIBCO. TRANSACTION_HISTORY
WHERE TYPE = 'ShipmentConfirm '.
and APP in ("SAPPI") and INTERVENE ('9332')
My Questions:
1.*There are indexes on all 3 APP passes it's IE, STEP and TYPE *. I don't want a FULL table Scan (as one would use the index). Can change us the query / use of indices, etc. to make it faster?
2. is the right to approach? Would the use of the concat operator in the function decode work better for my needs?
Something like
Select decode (APP |) STEP, 'SAPP9332', 'X') of TRANSACTION_HISTORY where < COND >
If Yes can you please provide the query?
3. ANY other approach / request for my requirement.
Thanks in advance.Hello
user13517642 wrote:
... EXECUTION PLAN| ID | Operation | Name |
------------------------------------------------------------------------
| 0 | SELECT STATEMENT |
| 1. GROUP SORT BY |
| 2. INLIST ITERATOR.
| 3. TABLE ACCESS BY INDEX ROWID | TRANSACTION |
| 4. INDEX RANGE SCAN | TRANSACTION_IDX |The output of the query (as above) must partially match the following query (a particular combination of CLO)
SELECT count (1)
TIBCO. TRANSACTION_HISTORY
WHERE TYPE = 'ShipmentConfirm '.
and APP in ("SAPPI") and INTERVENE ('9332')My Questions:
1.*There are indexes on all 3 APP passes it's IE, STEP and TYPE *. I don't want a FULL table Scan (as one would use the index). Can change us the query / use of indices, etc. to make it faster?
A full table scan might be the fastest way to get results. Do you have any reason to think that it would be faster to go through the index? How selective are the clues? In other words, what is the percentage of rows in the table correspond to each of the values in the WHERE clause?
2. is the right to approach?
It depends on what you're trying to do, which is not at all clear to me.
Would the use of the concat operator in the function decode work better for my needs?
Something likeSelect decode (APP |) STEP, 'SAPP9332', 'X') of TRANSACTION_HISTORY where
If you use this approach, look out for the problem Ab asse crevit . For example, if you have these 4 rows and 2 columns:
str1 str2 ---- ---- (NULL) FOO F OO FO O FOO (NULL)
There are 4 values of distict of str1 (counting NULL) and 4 separate values of str2, str1 but | str2 is the same for each of them. In the above example, it there is no way to know, just by looking at the concatenated string, including str1 and str2 ends begins. Maybe it's not the case for your specific data (for example, if the application is still exactly 5 characters long). otherwise, you may need to add some kind of delimiter, like this
app || '+' || step
where you know that '+' never occurs in one of these columns.
3. ANY other approach / request for my requirement.
CASES, as I mentioned in your previous message:
Decode the help function
and as you have used above.In this thread, you said "I have to use the decode function. Why? It is a competition of school Etudieeo DECODE is explicitly required? Why you don't want in the best way, what that turns out to be?
Your WHERE clause:
AND APP IN ('SAPPI', 'SAPPI', 'SAPR3') AND STEP IN ('9320', '9332', '1208')
admits 6 possible combinations of APA and step:
app step ----- ---- SAPP1 9320 SAPP1 9332 SAPP1 1208 SAPP3 9320 SAPP3 9332 SAPP3 1208
but you are looking for only 3 of these combinations in DECODE it or the expression BOX. (Have 2 copies of 'SAPP1' e list won't do any good, but it does hurt real, either.)
By the way, is "SAPPI" app with the letter 'I' at the end, or "SAPP1", with the number '1' at the end?Published by: Frank Kulash, March 24, 2011 19:44
-
Dear Experts,
Need to convert several lines in a row
CREATE TABLE TESTING_PIVOT
(
IDENTIFICATION NUMBER,
NUMBER OF PRICE_AMOUNT
NUMBER OF RATE_PERCENT
);
INSERT INTO TESTING_PIVOT VALUES (1,100,55);
INSERT INTO TESTING_PIVOT VALUES (1,200,85);
INSERT INTO TESTING_PIVOT VALUES (1,300,64);
INSERT INTO TESTING_PIVOT VALUES (2,400,94);
INSERT INTO TESTING_PIVOT VALUES (2,500,59);
INSERT INTO TESTING_PIVOT VALUES (2,600,49);
COMMIT;
SELECT * FROM TESTING_PIVOT;
DESIREE OUTPUT
ID PRICE_AMOUNT_1 PRICE_AMOUNT_1 PRICE_AMOUNT_1 RATE_PERCENT_1 RATE_PERCENT_2 RATE_PERCENT_3
1 100 200 300 55 85 64
2 400 500 600 94 59 49
Help, please
Try this
Select
ID,
MAX (CASE WHEN RN = 1 THEN PRICE_AMOUNT END) PRICE_AMOUNT1,.
MAX (CASE WHEN RN = 2 THEN PRICE_AMOUNT END) PRICE_AMOUNT2,.
MAX (CASE WHEN RN = 3 THEN PRICE_AMOUNT END) PRICE_AMOUNT3,.
MAX (CASE WHEN RN = 1 THEN RATE_PERCENT END) RATE_PERCENT1,.
MAX (CASE WHEN RN = 2 THEN RATE_PERCENT END) RATE_PERCENT2,.
MAX (CASE WHEN RN = 3 THEN RATE_PERCENT END) RATE_PERCENT3
Of
(select id, PRICE_AMOUNT, RATE_PERCENT, ROW_NUMBER() over (PARTITION BY ORDER of the ROWNUM ID) RN OF TESTING_PIVOT)
Group by id;
-
query to calculate the value and produce new lines
QUARTER CUSTOMER PRODUCT RETAIL_SALES_AMT WHOLESALE_AMT
01/01/2006 ABC VACUUM CLEANER 454234,00 65633456.00
01/04/2006 ABC VACUUM CLEANER 324562,00 45333234.00
01/07/2006 ABC VACUUM CLEANER 67845423.00 NULL
01/10/2006 ABC VACUUM CLEANER 67453453.00 NULL
01/01/2007 ABC VACUUM CLEANER 56754633.00 NULL
01/04/2007 ABC VACUUM CLEANER 45423434.00 NULL
Hi guys,.
It's a situation where I have to produce a few new lines with projections based on Q4 RETAIL_SALES_AMT
RETAIL_SALES_AMOUNT and fourth ' rs following WHOLESALE_AMT. As you can see from the sample data for a specific customer,
product I have populated only until 01/04/2006 retail_sales_amt but WHOLE_SALE amt for the same product and customer
are there up to 01/04/2007.
I have to produce a PROJECTED RETAIL_SALES_AMT and it must be inserted in a new line with an indicator to identify
a proposed line. Here, in this case I have to produce a new line of projection from 07/01/2006,10/01/2006 and 01/01/2007
the RETAIL_SALES_AMT. The method of calculation is provided for in:
retail_sales_amt scheduled for 07/01/2006=.345+ ((01/07/2006 whole_sales-01/04/2006 whole_sales) / (01/04/2006 whole_sale)))
* 01/04/2006 RETAIL_SALES_AMT and move forward to subsequent quarters.
Is it possible that I can use a query to produce these new lines by calculating the RETAIL_SALES_AMT on the fly, or any other
How to procedure.
Please help as it seems a little complicated.
Concerning
Published by: user626688 on October 27, 2009 11:26
Published by: user626688 on October 27, 2009 11:26
Published by: user626688 on October 27, 2009 11:27
Published by: user626688 on October 27, 2009 11:28
Published by: user626688 on October 27, 2009 11:31
Published by: user626688 on October 27, 2009 11:32Hello
As far as I can tell, that's what you asked for:
WITH got_prev AS ( SELECT table_x.* , LAG (wholesale_amt) OVER ( PARTITION BY customer , product ORDER BY quarter ) AS prev_wholesale_amt FROM table_x -- WHERE ... -- Any filtering goes here ) , tree AS ( SELECT got_prev.* , SYS_CONNECT_BY_PATH ( CASE WHEN LEVEL = 1 THEN retail_sales_amt ELSE ( .345 + wholesale_amt - prev_wholesale_amt ) / prev_wholesale_amt END , '*' ) AS path FROM got_prev START WITH retail_sales_amt IS NOT NULL CONNECT BY retail_sales_amt IS NULL AND quarter = ADD_MONTHS (PRIOR quarter, 3) AND customer = PRIOR customer AND product = PRIOR product ) SELECT quarter , customer , product , COALESCE ( retail_sales_amt , eval_number ( LTRIM ( path , '*' ) ) ) AS retail_sales_amt , wholesale_amt , NVL2 ( retail_sales_amt , 'F' , 'T' ) AS projected_flag FROM tree ORDER BY customer , product , quarter ;
I posted earlier the eval_number function.
In this query, a group of consecutive quarters, where the first group a retail_sales_num and the rest of the members of the group are not, is treated as a hierarchy. The retail_sales_amt of all members (except the first) will be based on the previous, as well as the wholesale_amts past and present.
Say that a tree is 5 points of time (as in your examples of data). We can calculate the 2nd point in several ways: using analytical functions, for example. But we cannot use the same formula to calculate the 3rd point, because the calculation of section 2 must be completed before we can calculate the 3rd. It goes the same for the 4th and 5th.
This is CONNECT BY arrives. CONNECT BY is one thing in Oracle SQL that can be recursively; children may find themselves once their parents are found, in the same way we want to calculate the nth retail_sales_amt once the amount of the n-minus-1 has been calculated. To do this, we use SYS_CONNECT_BY_PATH, where the first element in the path is the retail_sales_amt given, and all others are the factor to multiply this number to get the next amount.
SYS_CONNECT_BY_PATH produces a string like ' * 324562 *. 4965935 *-. 0057739', which should be interpreted as a number. TO_NUMBER won't: TO_NUMBER cannot convert only a single numeric literal. Instead, we have a function defined by the user who put this string dynamically in the SELECT clause of a query, where it is interpreted as a numeric expression. -
Help with the query to return the last possible value
Can someone please help me to create a query for the situation below?
Table: TABLEA
Columns:
FACID VARCHAR2 (10),
DEPTID VARCHAR2 (10),
CHARGENUMBER NUMBER (10)
I have the following data:
A, B, 1
A, B, 2
C, D, 3
C, D, 4
I will return the following:
A, B, 2
C, D, 4
In other words, I would return the last possible CHARGENUMBER for FACID and DEPTID.
The table has no index, and it is responsible for a worksheet in that order.
Thank you very much!Hello
If you have a TIMESTAMP column, called entry_dt, you can use a Top - N query like this to find the last x entries.
WITH got_rnum AS ( SELECT my_table.* , RANK () OVER (ORDER BY entry_dt DESC) AS rnum FROM my_table ) SELECT * -- or list all columns except rnum FROM got_rnum WHERE rnum <= x ;
It is very common to have a trigger to ensure that columns like entry_dt are met.
If you have only one statement that inserts with hundreds of lines, they can all have the same entry_dt. (The value of SYSTIMESTAMP is constant throughout a statement, even if it takes a few seconds).
The above query uses RANK, so if you tell him you want the last 10 entries, it can return more than 10, because it includes all lines with exactly the same entry_dt as the 10th. If you want to exactly 10 rows returned, even if there is a tie for 10th place, then use ROW_NUMBER instead of RANK; the rest of the query is the same. -
Need help to write the query to extract the value of the previous row - Lag not help
HelloI created follwing table.
Create table test
(number of fi,
number of fo_fv
number of jup_fv
action varchar2 (10)
);
insert into TEST(1,1,1,'LOAD');
Insert into TEST (2, NULL, 2, "ROLL");
insert into TEST(3,,3,'ROLL');
insert into TEST(4,,4,ROLL);
insert into TEST (5,2,5,LOAD);
I want the result of the query as below:
FI FO_FV JUP_FV ACTION
-------------------------------------------------------------------
1 1 1 LOAD
2 1 2 ROLL
3 1 3 ROLL
4 1 4 ROLL
5 2 5 LOAD
Help, please.
Thank you!
SQL > select fi
2, max (fo_fv) on fo_fv (fi control)
3, jup_fv
4, action
5 of the test;FI FO_FV JUP_FV ACTION
---------- ---------- ---------- ----------
1 1 1 LOAD
ROLL OF 2 1 2
3 1 3 ROLL
4 1 4 ROLL
5 2 5 LOADOR
SQL > select *.
2 test
model 3
Dimension 4 by (fi)
5 measures (fo_fv, jup_fv, action)
6 rules
7 (
8 fo_fv [any] = case when fo_fv [cv ()] is null
9. can fo_fv [cv () - 1]
10 fo_fv [cv () else]
11 end
(12);FI FO_FV JUP_FV ACTION
---------- ---------- ---------- ----------
1 1 1 LOAD
ROLL OF 2 1 2
3 1 3 ROLL
4 1 4 ROLL
5 2 5 LOAD -
Help: How do I calculate the duration between 2 dates, when these dates on 2 rows?
Hello
We are 11g.
We have a table with times recorded in a column. Then, each line as a different date value.
There is no pb to order the query on this date column (obviously)
Now, we need to calculate the period of time between 2 successive rows.
I first thought to use a cursor, the cursor loop, compute and update the "duration" column
It's the basic option
Now, I would like to know if, by using a single query, I couldn't directly the calculation I want?
Here is my example:
Ideally, that's what I would get (if my math is correct)WITH t AS ( SELECT 'aaa' col1, to_date( '20100201 09:23:50', 'YYYYMMDD HH24:MI:SS') date1 FROM dual UNION SELECT 'aaa' col1, to_date( '20100201 13:14:33', 'YYYYMMDD HH24:MI:SS') date1 FROM dual UNION SELECT 'aaa' col1, to_date( '20100207 13:14:33', 'YYYYMMDD HH24:MI:SS') date1 FROM dual UNION SELECT 'bbb' col1, to_date( '20100202 09:21:10', 'YYYYMMDD HH24:MI:SS') date1 FROM dual UNION SELECT 'bbb' col1, to_date( '20100203 08:11:06', 'YYYYMMDD HH24:MI:SS') date1 FROM dual UNION SELECT 'bbb' col1, to_date( '20100203 15:13:55', 'YYYYMMDD HH24:MI:SS') date1 FROM dual UNION SELECT 'bbb' col1, to_date( '20100210 10:14:27', 'YYYYMMDD HH24:MI:SS') date1 FROM dual ) SELECT col1, to_char( date1,'YYYYMMDD HH24:MI:SS') date1 FROM t ORDER BY col1, date1;
I hope I'm clear!COL DATE1 DURATION --- ----------------- ---------- aaa 20100201 09:23:50 0 aaa 20100201 13:14:33 13843 aaa 20100207 13:14:33 518400 bbb 20100202 09:21:10 0 bbb 20100203 10:11:06 89396 bbb 20100203 15:13:55 18169 bbb 20100210 17:14:27 612032
Thanks a lot in advance for your help
OlivierOf course; It's easy with the use of the function analytic lag:
WITH t AS (SELECT 'aaa' col1, to_date( '20100201 09:23:50', 'YYYYMMDD HH24:MI:SS') date1 FROM dual UNION ALL SELECT 'aaa' col1, to_date( '20100201 13:14:33', 'YYYYMMDD HH24:MI:SS') date1 FROM dual UNION ALL SELECT 'aaa' col1, to_date( '20100207 13:14:33', 'YYYYMMDD HH24:MI:SS') date1 FROM dual UNION ALL SELECT 'bbb' col1, to_date( '20100202 09:21:10', 'YYYYMMDD HH24:MI:SS') date1 FROM dual UNION ALL SELECT 'bbb' col1, to_date( '20100203 08:11:06', 'YYYYMMDD HH24:MI:SS') date1 FROM dual UNION ALL SELECT 'bbb' col1, to_date( '20100203 15:13:55', 'YYYYMMDD HH24:MI:SS') date1 FROM dual UNION ALL SELECT 'bbb' col1, to_date( '20100210 10:14:27', 'YYYYMMDD HH24:MI:SS') date1 FROM dual), t_diff as (SELECT col1, to_char( date1,'YYYYMMDD HH24:MI:SS') date1, (date1 - lag(date1, 1, date1) over (partition by col1 order by date1))*24*60*60 date_diff FROM t) select col1, date1, sum(date_diff) over (partition by col1 order by date1) duration from t_diff ORDER BY col1, date1;
Published by: Boneist on February 15, 2010 16:39
(I can't read; initially gave the cumulative total of the period. Oh!)ETA2: Take note of the additional parameters, I used in the lag() - the third parameterd manages what should be the value in the field if there is no previous rank, so there is no need to use nvl elsewhere in the application to handle this situation.
Published by: Boneist on February 15, 2010 16:42
-
The query on record is missing help
Thanks in advance
create the table TABLE_AA1
(
A NUMBER,
PLEASE THE NUMBER,
NUMBER OF END,
NUMBER OF TEACHER,
AVERAGE NUMBER,
THE REGION NUMBER
)
;
insert into TABLE_AA1 (A, START, END, TEACHER, MEDIUM, REGION)
values (1, 0,.1, 159, 159, 1);
insert into TABLE_AA1 (A, START, END, TEACHER, MEDIUM, REGION)
values (159, 168, 1 2,.1,.2,);
insert into TABLE_AA1 (A, START, END, TEACHER, MEDIUM, REGION)
values (3,.2,.3, 179, 159, 1);
insert into TABLE_AA1 (A, START, END, TEACHER, MEDIUM, REGION)
values (4,.1,.2,, 250, 300, 1);
insert into TABLE_AA1 (A, START, END, TEACHER, MEDIUM, REGION)
values (5,.2,.3, 320, 250, 1);
insert into TABLE_AA1 (A, START, END, TEACHER, MEDIUM, REGION)
values (6,.3,.4,, 250, 380, 1);
insert into TABLE_AA1 (A, START, END, TEACHER, MEDIUM, REGION)
values (7,.2,.3, 388, 379, 1);
insert into TABLE_AA1 (A, START, END, TEACHER, MEDIUM, REGION)
values (8,.3,.4,, 379, 388, 1);
insert into TABLE_AA1 (A, START, END, TEACHER, MEDIUM, REGION)
values (9,.4,.5, 388, 400, 1);
insert into TABLE_AA1 (A, START, END, TEACHER, MEDIUM, REGION)
values (10, 499, 500, 1 1.5,.6,);
insert into TABLE_AA1 (A, START, END, TEACHER, MEDIUM, REGION)
values (11,.5,.6, 420, 448, 1);
insert into TABLE_AA1 (A, START, END, TEACHER, MEDIUM, REGION)
values (12,.6,.7, 520, 530, 1);
insert into TABLE_AA1 (A, START, END, TEACHER, MEDIUM, REGION)
values (13,.7,.8, 540, 550, 1);
insert into TABLE_AA1 (A, START, END, TEACHER, MEDIUM, REGION)
values (14,.9, 1, 560, 570, 1);
commit;
I have a situation like below
(1) following query will display the calculation for the first 3 lines - works fine
(2) if the user pass parameter to eliminate the A = 2 & R_SQUARE = 0.95 and to calculate for the first 3 lines - works fine
(3) I have a problemn is so user pass the parameter for A = 2
I want to display eliminate an A = 2 & and R_SQUARE = 0.95 in the second query (as a part of the first 3 rows)
(No idea or help is appreciated)
I want the results of the query as below
(1) first query works FineA BEG END PROF AVERAGE REGION RN RN_DESC R_SQUARE R_SQUARE_VAL RANK 1 0 0.1 159 159 1 1 13 0.956274596 2 *2 0.1 0.2 159 168 1 3 0.2 0.3 179 159 1 2 12 0.956274596 2 4 0.1 0.2 250 300 1 3 11 0.956274596 0.956274596 2 5 0.2 0.3 320 250 1 4 10 0.018818382 1 6 0.3 0.4 250 380 1 5 9 0.018818382 1 7 0.2 0.3 388 379 1 6 8 0.018818382 0.018818382 1
SELECT d.*,DENSE_RANK() OVER (/*PARTITION BY r_square_val*10*/ ORDER BY R_SQUARE_VAL) RANK FROM (SELECT c.*, last_value(r_square ignore nulls) over (order by rn_desc) r_square_val FROM (SELECT a.*, REGR_R2 (average, prof) OVER (ORDER BY rn ROWS BETWEEN CASE WHEN MOD (rn, 3) = 0 THEN 3 WHEN rn_desc = 1 THEN MOD (rn, 3) ELSE 0 END PRECEDING AND CURRENT ROW) AS r_square FROM (select b.*, row_number() over (partition by region order by b.a) rn, row_number() over (partition by region order by b.a desc) rn_desc from table_aa1 b /*where b.a != 2*/ ) a) c) d /*where trunc(r_square_val, 2) = 0.01*/ ORDER BY d.region asc ,d.a asc;
(2) request works very wellA BEG END PROF AVERAGE REGION RN RN_DESC R_SQUARE R_SQUARE_VAL RANK ------------------------------------------------------------------------------------------------------- 1 0 0.1 159 159 1 1 14 0.25 3 2 0.1 0.2 159 168 1 2 13 0.25 3 3 0.2 0.3 179 159 1 3 12 0.25 0.25 3 4 0.1 0.2 250 300 1 4 11 0.164520715 1 5 0.2 0.3 320 250 1 5 10 0.164520715 1 6 0.3 0.4 250 380 1 6 9 0.164520715 0.164520715 1 7 0.2 0.3 388 379 1 7 8 0.218256852 2 8 0.3 0.4 379 388 1 8 7 0.218256852 2 9 0.4 0.5 388 400 1 9 6 0.218256852 0.218256852 2 10 1.5 0.6 499 500 1 10 5 0.973538061 4 11 0.5 0.6 420 448 1 11 4 0.973538061 4 12 0.6 0.7 520 530 1 12 3 0.973538061 0.973538061 4 13 0.7 0.8 540 550 1 13 2 1 5 14 0.9 1 560 570 1 14 1 1 1 5
If the user pass parameter to remove the A = 2 and R_SQUARE = 0.95 calculate for the first 3 lines - works fine
SELECT d.*,DENSE_RANK() OVER (/*PARTITION BY r_square_val*10*/ ORDER BY R_SQUARE_VAL) RANK FROM (SELECT c.*, last_value(r_square ignore nulls) over (order by rn_desc) r_square_val FROM (SELECT a.*, REGR_R2 (average, prof) OVER (ORDER BY rn ROWS BETWEEN CASE WHEN MOD (rn, 3) = 0 THEN 3 WHEN rn_desc = 1 THEN MOD (rn, 3) ELSE 0 END PRECEDING AND CURRENT ROW) AS r_square FROM (select b.*, row_number() over (partition by region order by b.a) rn, row_number() over (partition by region order by b.a desc) rn_desc from table_aa1 b where b.a != 2 ) a) c) d where trunc(r_square_val, 2) <= 0.95 ORDER BY d.region asc ,d.a asc;
Published by: user1849 on September 8, 2009 09:02A BEG END PROF AVERAGE REGION RN RN_DESC R_SQUARE R_SQUARE_VAL RANK 1 0 0.1 159 159 1 1 13 0.956274596 2 3 0.2 0.3 179 159 1 2 12 0.956274596 2 4 0.1 0.2 250 300 1 3 11 0.956274596 0.956274596 2 5 0.2 0.3 320 250 1 4 10 0.018818382 1 6 0.3 0.4 250 380 1 5 9 0.018818382 1 7 0.2 0.3 388 379 1 6 8 0.018818382 0.018818382 1
Published by: user1849 on September 8, 2009 09:14
Published by: user1849 on September 8, 2009 09:17You don't think the my last request everything works very well for your needs:
Look carefully
with req_data as ( SELECT d.* , DENSE_RANK() OVER (ORDER BY R_SQUARE_VAL) RANK FROM (SELECT c.* , last_value(r_square ignore nulls) over (order by rn_desc) r_square_val FROM (SELECT a.* , REGR_R2 (average, prof) OVER (ORDER BY rn ROWS BETWEEN CASE WHEN MOD (rn, 3) = 0 THEN 3 WHEN rn_desc = 1 THEN MOD (rn, 3) ELSE 0 END PRECEDING AND CURRENT ROW) AS r_square FROM (select b.* , row_number() over (partition by region order by b.a) rn , row_number() over (partition by region order by b.a desc) rn_desc from table_aa1 b where b.a not in (select d.a from table_aa1 d where d.a in(2,6))) a ) c ) d where trunc(r_square_val, 2) <= 0.49 ) select * from ( select * from req_data union all select m.* , to_number(null) r_square , to_number(null) r_square_val , to_number(null) RANK from ( select b.* , row_number() over (partition by region order by b.a) rn , row_number() over (partition by region order by b.a desc) rn_desc from table_aa1 b ) m where m.a in (2, 6) and exists (select 1 from (select max(r.a) mx , min(r.a) mn from req_data r ) where m.a between mn and mx ) ) x ORDER BY x.region asc , x.a asc;
As a result of output product
5 0.2 0.3 320 250 1 4 9 0.496965785 1 6 0.3 0.4 250 380 1 7 0.2 0.3 388 379 1 5 8 0.496965785 1 8 0.3 0.4 379 388 1 6 7 0.496965785 0.496965785 1
Kind regards
Amit -
I have two 1 d arrays that contain cyclical information (a bit like a sine wave). One that contains information about the position in degrees and another that contains the couple. I would like to calculate the value of maximum torque whenever the station is within a certain range (for example, 30 to 80 degrees). The beaches are repeated - that is why it is cyclical. I use the function "in the range", a structure of the case and the shift records to build a new table with the values that are included in the beach I said - that was easy part (see attached VI). I'm struggling with a way to calculate a maximum value for each sub-table formed when the values are 'in range '. Your help is very appreciated.
vt92 solution worked! I agree that there should be a simpler solution, but your to works fine. Thank you very much.
-
the data that I measured changed quickly, so I want to get the average value of the data
Don't tell me to use mean.vi, I already know.
and I got an idea that is to add data in a table every time, then the sum of all value data and take the line of result by the number of items
but I don't know how to do this, anyone can build a simple vi to show me? Thank you
I enclose my vi that uses mean.vi to the average value of calc, you can remove it and help in your path, thank you!
Do not add your data in a table that grows forever. What a waste of RAM. To calculate the average, you only need to sum and N.
Here is a simple code to accumulate the sum of the values in a shift register and divide by the number of add operations.
-
calculate the difference of unique column values
I tried the info and the website to learn how to perform a "calculation difference" function on a single column (channel) of data. For example if my data channel is a period of time to say the following: 100, 101, 99, 102, 100, 99... I would like to calculate 100-101 101 - 99 then then 99-102 and so on for all the values. How can I do this?
Hi ranger,
Looks like you're looking for the standard function "Calculate the disparity" ANALYSIS > basic math.
Hope this helps,
Ralf -
Calculate the number of days remaining until the next anniversary. Help, please!
Hi guys,.
I'm new to the forum and to the development of BB. So please do not judge harshly if the answer to my question seems obvious.
I need to calculate the number of days until the next birthday (taking into account any valid birth date)
After looking at the API and the forum search, I realized that I could
calculate the difference between two dates in milliseconds and then divide the delta of the value of a day in milliseconds. That is to say:
birthdayCalendar.set (Calendar.YEAR, those);
Date1 = birthdayCalendar.getTime () .getTime ();
date2 = System.currentTimeMillis ();
Delta = date1 - date2
numOfDays = delta\DateTimeUtilities.ONEDAY
Here's my question. How do I create a valid date1 what about leap years?
Maybe there's a better way to solve this problem?
Any help is greatly appreciated.
I agree that the determination of the number of days between today and Feb. 29 could be a little difficult, if it is not a leap year. I suspect that the calendar has a certain built-in mechanism to compensate for this, but your solution to choose a date is better.
DST has a role to play, and Yes, the calendar makes up for it. Let us take two dates, for example (before DST) March 1 and June 1 (after the DST). If you take a calendar and set the same hour, minute, etc., they are all the same except for dates, then subtract one from the other, and then divide by the number of milliseconds in 1 hour, you calculate the number of hours between the same time on two different days. You will find that it is not a multiple of 24 hours - because there is actually an hour less than the number of days since the clocks move forward (in the northern hemisphere anyway...),
In your case, you are not calculating the number of hours, you calculate the number of days. But you will be dividing by [24 * (time in an hour)]. If you take [23 * (time in an hour)] and divide it by [24 * (time in an hour)], using arithmetic on integers, you will end up 0. The easiest to get around this, who also works for the end of the DST too, is to simply add one hour to the date before the division.
Hope that makes sense...
-
How to store the query string value in the scope of the session in webcenter spaces?
Hello
I want to store the query string value (which is given from URL) in the sessionScope variable. According to the value of sessionScope beacause I went some components inside my taskflow. Can someone help me how to store this value in the scope of the session. I use webcenter spaces for my application development.
Thank you
Ashok.
Please see the article below
How to pass a parameter of argument the query URL to a parameter input workflow? (Doc ID 1545808.1).
-
Need help to understand the query result
Hi gurus
I was reading one of the question here in this forum and its link is below:
I had some confusion related to this code and don't understand the logic of the out put, see query below:
Query
with sub_services as
(
Select su_seq 12323, 'HLR1' so_id, 1 seq Union double all the
Select su_seq 12323, "HLR2' so_id, seq 2 Union double all the
Select su_seq 12323, "A09" so_id, seq 3 of all the double union
Select su_seq 12333, "MO1" so_id, seq 4 Union double all the
Select su_seq 12333, "MO2' so_id, seq 5 Union double all the
Select su_seq 12333, "A09" so_id, 6 seq in union double all the
Select su_seq 12333, 'M0CR' so_id, seq 7 Union double all the
Select su_seq 12999, "LOL1' so_id, seq 8 Union double all the
Select su_seq 12999, "LOL2' so_id, seq 9 double
)
Select *.
of sub_services b
where exists (select 1 from sub_services
where su_seq = b.su_seq
and so_id = 'A09.
)
order by 2;
The query result
12323 A09 3
12333 6 A09
12323 HLR1 1
12323 HLR2 2
12333 M0CR 7
12333 4 MO1
12333 5 MO2
According to my understanding, the above query should return records in red only because of her is below command
It exists (select 1 from sub_services
where su_seq = b.su_seq
and so_id = 'A09.
but don't know why he's back 7 files, can someone help me understand the result...
It is query is functionally identical to the PL/SQL block, but much more effective.
declare
number of l_res;
Start
for line (select *)
sub_services) loop
Start
Select 1 from l_res
of sub_services
where su_seq = row.su_seq and
so_id = "A09" and
rownum = 1;
Essentially every row in the outer query are tested against him exists query. Given the correlation between two requests is based only on su_seq each line with a su_seq value returned by him is returned in the output.
Another way to think he uses instead a join condition. This query is equivalent to the query to exist
Select the main
of main sub_services
Join select (separate su_seq
of sub_services
where so_id = "A09") cond
We main.su_seq = cond.su_seq;
John
-
Need help with the query. Help, please
Hey everyone, need your help. Thank you in advance. In my view, there is function Pivot. Just do not know how to use this function. I have the query that works. The result is:
11-111-1111 Vlad 16505 01/04/2013 5 August 13 dental plan pre-tax amount 29,65
11-111-1111 Vlad 16505 01/04/2013 dental pre-tax 5 August 13 Plan level EE + SP
11-111-1111 16505 Vlad 01/04/2013 5 August 13 pre-tax Option TOP dental plan
11-111-1111 Vlad 16505 01/04/2013 5 August 13 pre-tax dental care plan pay the value
11-111-1111 16505 Vlad 01/04/2013 dental pre-tax 5 August 13 Plan period Type
11-111-1111 Vlad 16505 01/04/2013 amount pre-tax medical Plan of 5 August 13 149
11-111-1111 Vlad 16505 01/04/2013 5 August 13 pre-tax Medical Plan level EE + SP
11-111-1111 Vlad 16505 01/04/2013 5 August 13 pre-tax Plan medical Option MED
11-111-1111 Vlad 16505 01/04/2013 5 August 13 plan pre-tax pay value
11-111-1111 16505 Vlad 01/04/2013 5 August 13 pre-tax Medical Plan period Type
11-111-1111 Vlad 16505 01/04/2013 5 August 13 pre-tax Plan PPO medical Plan
11-111-1111 Vlad 16505 01/04/2013 5 August 13 Vision Plan amount 5.94 pre-tax
But I need the result to be
Amount of SSN ID name item level Option PayValue period Type
11-111-1111 Vlad 16505 01/04/2013 null null high of 5 August 13 pre-tax Dental Plan 29,65 EE + SP
11-111-1111 Vlad 16505 01/04/2013 null null MED 5 August 13 149 medical plan pre-tax EE + SP
11-111-1111 Vlad 16505 01/04/2013 Vision Plan before taxes of 5 August 13
Select distinct
' 11-111-1111 "as ssn,
WOMEN'S WEAR. Employee_number,
"Vlad" as EMPLOYEE_FULL_NAME,
TO_CHAR (papf.start_date, "MM/DD/YYYY") as Date_Of_Hire
a.effective_start_date,
PETF.element_name,
pivf. Name,
peevf.screen_entry_valueOf
PER_all_PEOPLE_F women's wear
per_assignments_f A
pay_element_types_f petf
pay_element_links_f pelf
PAY_ELEMENT_ENTRIES_F penf
PAY_ELEMENT_ENTRY_VALUES_F peevf
pay_input_values_f pivf
WHERE
PETF.element_name ('Dental Plan before taxes', 'Medical Plan before taxes', "Vision Plan before taxes")
and petf. ELEMENT_TYPE_ID = pelf. ELEMENT_TYPE_ID
and (trunc (sysdate) BETWEEN pelf. EFFECTIVE_START_DATE AND pelf. EFFECTIVE_END_DATE)
and (pelf. ELEMENT_LINK_ID = penf. ELEMENT_LINK_ID and a.assignment_id = penf. ASSIGNMENT_ID)
and (trunc (sysdate) BETWEEN penf. EFFECTIVE_START_DATE AND penf. EFFECTIVE_END_DATE)
and penf. ELEMENT_ENTRY_ID = peevf. ELEMENT_ENTRY_ID
and peevf. INPUT_VALUE_ID = pivf. INPUT_VALUE_ID
AND papf.employee_number IS NOT NULL
AND A.assignment_type = 'E '.
AND A.person_id = papf.person_id
and papf.effective_end_date > sysdate
and a.effective_end_date > sysdate
and (trunc (sysdate) BETWEEN women's wear. EFFECTIVE_START_DATE AND women's wear. EFFECTIVE_END_DATE)
and a.effective_start_date = (select MAX (effective_start_date) from PER_ASSIGNMENTS_f where assignment_id = a.assignment_id)
and a.assignment_id = 42643
and a.assignment_status_type_id = '1'
order of petf.element_name;Change with your query
SELECT * FROM (select distinct)
' 11-111-1111 "as ssn,
WOMEN'S WEAR. Employee_number,
"Vlad" as employee_full_name,
TO_CHAR (papf.start_date, "MM/DD/YYYY") as date_of_hire
a.effective_start_date,
PETF.element_name,
pivf. Name,
peevf.screen_entry_value
Of
PER_all_PEOPLE_F women's wear
per_assignments_f A
pay_element_types_f petf
pay_element_links_f pelf
PAY_ELEMENT_ENTRIES_F penf
PAY_ELEMENT_ENTRY_VALUES_F peevf
pay_input_values_f pivf
WHERE
PETF.element_name ('Dental Plan before taxes', 'Medical Plan before taxes', "Vision Plan before taxes")
and petf. ELEMENT_TYPE_ID = pelf. ELEMENT_TYPE_ID
and (trunc (sysdate) BETWEEN pelf. EFFECTIVE_START_DATE AND pelf. EFFECTIVE_END_DATE)
and (pelf. ELEMENT_LINK_ID = penf. ELEMENT_LINK_ID and a.assignment_id = penf. ASSIGNMENT_ID)
and (trunc (sysdate) BETWEEN penf. EFFECTIVE_START_DATE AND penf. EFFECTIVE_END_DATE)
and penf. ELEMENT_ENTRY_ID = peevf. ELEMENT_ENTRY_ID
and peevf. INPUT_VALUE_ID = pivf. INPUT_VALUE_ID
AND papf.employee_number IS NOT NULL
AND A.assignment_type = 'E '.
AND A.person_id = papf.person_id
and papf.effective_end_date > sysdate
and a.effective_end_date > sysdate
and (trunc (sysdate) BETWEEN women's wear. EFFECTIVE_START_DATE AND women's wear. EFFECTIVE_END_DATE)
and a.effective_start_date = (select MAX (effective_start_date) from PER_ASSIGNMENTS_f where assignment_id = a.assignment_id)
and a.assignment_id = 42643
and a.assignment_status_type_id = '1')
PIVOT (MAX (screen_entry_value) FOR (name) TO ("Amount" AS 'Amount', 'level' AS 'level', 'Option High' AS 'High Option', 'Pay the value' AS 'Value to pay', 'Period of Type' AS 'Type period'))
order by element_name;
(GOLD)
SELECT ssn,
Employee_number,
employee_full_name,
date_of_hire,
effective_start_date,
element_name,
Max (decode (Name, 'Amount', screen_entry_value)) 'amount. "
Max (decode (Name, 'Level', screen_entry_value)) 'level ',.
MAX (DECODE (name, "High Option", screen_entry_value)) "High Option",
MAX (DECODE (name, 'Value of pay', screen_entry_value)) 'value of pay. "
MAX (DECODE (name, 'Period Type', screen_entry_value)) 'period of Type '.
FROM (select distinct)
' 11-111-1111 "as ssn,
WOMEN'S WEAR. Employee_number,
"Vlad" as employee_full_name,
TO_CHAR (papf.start_date, "MM/DD/YYYY") as date_of_hire
a.effective_start_date,
PETF.element_name,
pivf. Name,
peevf.screen_entry_value
Of
PER_all_PEOPLE_F women's wear
per_assignments_f A
pay_element_types_f petf
pay_element_links_f pelf
PAY_ELEMENT_ENTRIES_F penf
PAY_ELEMENT_ENTRY_VALUES_F peevf
pay_input_values_f pivf
WHERE
PETF.element_name ('Dental Plan before taxes', 'Medical Plan before taxes', "Vision Plan before taxes")
and petf. ELEMENT_TYPE_ID = pelf. ELEMENT_TYPE_ID
and (trunc (sysdate) BETWEEN pelf. EFFECTIVE_START_DATE AND pelf. EFFECTIVE_END_DATE)
and (pelf. ELEMENT_LINK_ID = penf. ELEMENT_LINK_ID and a.assignment_id = penf. ASSIGNMENT_ID)
and (trunc (sysdate) BETWEEN penf. EFFECTIVE_START_DATE AND penf. EFFECTIVE_END_DATE)
and penf. ELEMENT_ENTRY_ID = peevf. ELEMENT_ENTRY_ID
and peevf. INPUT_VALUE_ID = pivf. INPUT_VALUE_ID
AND papf.employee_number IS NOT NULL
AND A.assignment_type = 'E '.
AND A.person_id = papf.person_id
and papf.effective_end_date > sysdate
and a.effective_end_date > sysdate
and (trunc (sysdate) BETWEEN women's wear. EFFECTIVE_START_DATE AND women's wear. EFFECTIVE_END_DATE)
and a.effective_start_date = (select MAX (effective_start_date) from PER_ASSIGNMENTS_f where assignment_id = a.assignment_id)
and a.assignment_id = 42643
and a.assignment_status_type_id = '1')
GROUP BY ssn, employee_number, employee_full_name, date_of_hire, effective_start_date, NOM_ELEMENT
order by element_name;
Maybe you are looking for
-
Color LaserJet Enterprise M577: How to check OXPD 1.6 or 1.7 version
Hello Could someone please tell me how to check OXPD 1.6 or 1.7 on HP M577 version? Thank you.
-
3110CT: BIOS recognizes the new 20 GB HARD drive
Just installed a P002608, in a protected 3110CT 20 GB hard drive, now, the BIOS will not recogize the new hard drive.
-
Full Professional upgrade fails.
Update 8.5 to 8.6 Professional, I get the following error; ERROR: a file, directory or other data element is not found (error code = - 32) The installation/update fails. What is this error?
-
I have to press hard on the touchpad and it works
I have to press hard on the touchpad to make it work. Can I do to solve this problem? Thank you.
-
My windows 7 sp 1 is not active. Will I get windows 10 and how.