Choose a group with the special value
I have table below. Each client has a few accounts with different interest rates.
customer | account | interestRate | Balance |
one | 1 | 28 | 100 |
one | 2 | 24 | 200 |
one | 3 | 20 |
50
b
4
19
60
b
5
20
90
c
6
24
150
d
7
19
20
d
8
24
70
d
9
24
10
d
10
15
30
I want to select customers with interestRate = 24 and the balance of their accounts, as it the sum
one | 100 + 200 + 50 |
c
150
d
20 + 70 + 10 + 30
I can do this with nested query, but I'm looking to recover these data with a query with minimum cost
The global version
Thanks for the borrowed data
with cust as
(
Select 'a' customer, '1' account, '28' rate, 100' ball of all the double union
Select 'a' customer, '2' account, '24' rate, 200' dance of all the double union
Select 'a' customer, '3' account, '20' rate, 50' dance of all the double union
customer select 'b', '4' account '19', 60' dance of all the double union
customer select 'b', '5' account '20', 90' dance of all the double union
Select customer 'c', "6", rate '24', '150' ball of all the double union
Select ' client '7' account, rate ' 19', 20' dance of all the double union
Select ' client '8' account, rate ' 24', 70' dance of all the double union
Select ' client '9' account, rate ' 24', 10' ball of all the double union
Select ' client '10' account, rate ' 15', 30' double ball
)
Select customer, sum (bal) sum_bal
the cust
Customer group
having count (case rates when '24' then 1 end) > 0
order by customer
CUSTOMER | SUM_BAL |
---|---|
one | 350 |
c | 150 |
d | 130 |
Concerning
Etbin
Tags: Database
Similar Questions
-
I have a column with two values, separated by a space, in each line. How do I create 2 new columns with the first value in one column and the second value in another column?
Add two new columns after than the original with space separated values column.
Select cell B1 and type (or copy and paste it here) the formula:
= IF (Len (a1) > 0, LEFT (A1, FIND ("", A1) −1), ' ')
shortcut for this is:
B1 = if (Len (a1) > 0, LEFT (A1, FIND ("", A1) −1), ' ')
C1 = if (Len (a1) > 0, Member SUBSTITUTE (A1, B1 & "", ""), "")
or
the formula of the C1 could also be:
= IF (Len (a1) > 0, RIGHT (A1, LEN (A1) −FIND ("", A1)), "")
Select cells B1 and C1, copy
Select cells B1 at the end of the C column, paste
-
When I delete the "screensaverissecure" with the registry value, it reappears again in the registry after I stop and start the system the next day. Help, please
use widows xpHello
- Have you tried to Hibernate for ever in the power settings option?
To resolve this problem, you can follow the steps below.(a) click and start(b) type power Option in the start search bar.(c) now select click Change plan for the current plan of the selected power.(d) now click on advanced power settings.(e) scroll down and click on the sign more next to sleep.(f) now click on allow the eve hybrid and turn it off.(g) click on the option put into hibernation after and set it to never. -
Updated with the hash values column
Hi all
I have a requirement to add a column to a table and fill it with the hash values. The table contains an xml column and hash value of this column need to be filled to newly added column. I think that the ora_hash function will not support the xml type column. Just tested with the following script and it works.
update TBL_COMPONENT_XSL set hash_val = ora_hash((SELECT TCX.COMPONENT_XSL.getStringVal() FROM TBL_COMPONENT_XSL TCX where rownum =1));
can you please suggest me how to fill the column with the hash values.
SQL> desc TBL_COMPONENT_XSL Name Null? Type ----------------------------------------- -------- ---------------------------- COMPONENT_XSL_ID NOT NULL NUMBER(18) LINE_OF_BUSINESS NOT NULL VARCHAR2(30) ORDER_SOURCE NOT NULL VARCHAR2(10) COMPONENT_NAME NOT NULL VARCHAR2(30) COMPONENT_SCHEMA_VERSION NOT NULL NUMBER(9) ACCESS_LEVEL NOT NULL VARCHAR2(30) COMPONENT_XSL NOT NULL SYS.XMLTYPE STORAGE BINARY DESCRIPTION NOT NULL VARCHAR2(200) HASH_VAL NUMBER
HASH_VAL is the newly added column.
Thank you
Mani
What happens if you try with:
update of TCX TBL_COMPONENT_XSL set hash_val = ora_hash (TCX.COMPONENT_XSL.getStringVal ());
update of TCX TBL_COMPONENT_XSL set hash_val = ora_hash (TCX.COMPONENT_XSL.getClobVal ());
Index: http://www.orafaq.com/forum/t/70829/
Concerning
Girish Sharma
-
Parameters of the obsolete system with the specified values:
Hello
I'm in the alerts log below:
Parameters of the obsolete system with the specified values:
REMOTE_OS_AUTHENT
It IS this setting is suppotable in 11G and also how can I remove it from SP. with bounce of the instance.
Thank you...(1) it is frowned upon in 11 g such as er your alert log message. http://docs.Oracle.com/CD/B28359_01/server.111/b28320/initparams199.htm
(2) define it in your spfile false who will return to the default value. This cannot be changed dynamically and you will need to restart your instance.
alter system set remote_os_authent=false scope=spfile;
-
How to compare the new values with the old values in triggers.
Dear all,
Please tell me how to compare the new values with the old values in triggers.Hi, the employee example is in the document. You'd better read yourself.
CREATE OR REPLACE TRIGGER Print_salary_changes BEFORE DELETE OR INSERT OR UPDATE ON Emp_tab FOR EACH ROW WHEN (new.Empno > 0) DECLARE sal_diff number; BEGIN sal_diff := :new.sal - :old.sal; dbms_output.put('Old salary: ' || :old.sal); dbms_output.put(' New salary: ' || :new.sal); dbms_output.put_line(' Difference ' || sal_diff); END; /
-
update to column values (false) in a copy of the same table with the correct values
Database is 10gr 2 - had a situation last night where someone changed inadvertently values of column on a couple of hundred thousand records with an incorrect value first thing in the morning and never let me know later in the day. My undo retention was not large enough to create a copy of the table as it was 7 hours comes back with a "insert in table_2 select * from table_1 to timestamp...» "query, so I restored the backup previous nights to another machine and it picked up at 07:00 (just before the hour, he made the change), created a dblink since the production database and created a copy of the table of the restored database.
My first thought was to simply update the table of production with the correct values of the correct copy, using something like this:
Update mnt.workorders
Set approvalstat = (select b.approvalstat
mnt.workorders a, mnt.workorders_copy b
where a.workordersoi = b.workordersoi)
where exists (select *)
mnt.workorders a, mnt.workorders_copy b
where a.workordersoi = b.workordersoi)
It wasn't the exact syntax, but you get the idea, I wanted to put the incorrect values in x columns in the tables of production with the correct values of the copy of the table of the restored backup. Anyway, it was (or seem to) works, but I look at the process through OEM it was estimated 100 + hours with full table scans, so I killed him. I found myself just inserting (copy) the lines added to the production since the table copy by doing a select statement of the production table where < col_with_datestamp > is > = 07:00, truncate the table of production, then re insert the rows from now to correct the copy.
Do a post-mortem today, I replay the scenario on the copy that I restored, trying to figure out a cleaner, a quicker way to do it, if the need arise again. I went and randomly changed some values in a column number (called "comappstat") in a copy of the table of production, and then thought that I would try the following resets the values of the correct table:
Update (select a.comappstat, b.comappstat
mnt.workorders a, mnt.workorders_copy b
where a.workordersoi = b.workordersoi - this is a PK column
and a.comappstat! = b.comappstat)
Set b.comappstat = a.comappstat
Although I thought that the syntax is correct, I get an "ORA-00904: 'A'. '. ' COMAPPSTAT': invalid identifier ' to run this, I was trying to guess where the syntax was wrong here, then thought that perhaps having the subquery returns a single line would be cleaner and faster anyway, so I gave up on that and instead tried this:
Update mnt.workorders_copy
Set comappstat = (select distinct)
a.comappstat
mnt.workorders a, mnt.workorders_copy b
where a.workordersoi = b.workordersoi
and a.comappstat! = b.comappstat)
where a.comappstat! = b.comappstat
and a.workordersoi = b.workordersoi
The subquery executed on its own returns a single value 9, which is the correct value of the column in the table of the prod, and I want to replace the incorrect a '12' (I've updated the copy to change the value of the column comappstat to 12 everywhere where it was 9) However when I run the query again I get this error :
ERROR on line 8:
ORA-00904: "B". "" WORKORDERSOI ": invalid identifier
First of all, I don't see why the update statement does not work (it's probably obvious, but I'm not)
Secondly, it is the best approach for updating a column (or columns) that are incorrect, with the columns in the same table which are correct, or is there a better way?
I would sooner update the table rather than delete or truncate then re insert, as it was a trigger for insert/update I had to disable it on the notice re and truncate the table unusable a demand so I was re insert.
Thank youHello
First of all, after post 79, you need to know how to format your code.
Your last request reads as follows:
UPDATE mnt.workorders_copy SET comappstat = ( SELECT DISTINCT a.comappstat FROM mnt.workorders a , mnt.workorders_copy b WHERE a.workordersoi = b.workordersoi AND a.comappstat != b.comappstat ) WHERE a.comappstat != b.comappstat AND a.workordersoi = b.workordersoi
This will not work for several reasons:
The sub query allows you to define a and b and outside the breakets you can't refer to a or b.
There is no link between the mnt.workorders_copy and the the update and the request of void.If you do this you should have something like this:
UPDATE mnt.workorders A -- THIS IS THE TABLE YOU WANT TO UPDATE SET A.comappstat = ( SELECT B.comappstat FROM mnt.workorders_copy B -- THIS IS THE TABLE WITH THE CORRECT (OLD) VALUES WHERE a.workordersoi = b.workordersoi -- THIS MUST BE THE KEY AND a.comappstat != b.comappstat ) WHERE EXISTS ( SELECT B.comappstat FROM mnt.workorders_copy B WHERE a.workordersoi = b.workordersoi -- THIS MUST BE THE KEY AND a.comappstat != b.comappstat )
Speed is not so good that you run the query to sub for each row in mnt.workorders
Note it is condition in where. You need other wise, you will update the unchanged to null values.I wouold do it like this:
UPDATE ( SELECT A.workordersoi ,A.comappstat ,B.comappstat comappstat_OLD FROM mnt.workorders A -- THIS IS THE TABLE YOU WANT TO UPDATE ,mnt.workorders_copy B -- THIS IS THE TABLE WITH THE CORRECT (OLD) VALUES WHERE a.workordersoi = b.workordersoi -- THIS MUST BE THE KEY AND a.comappstat != b.comappstat ) C SET C.comappstat = comappstat_OLD ;
This way you can test the subquery first and know exectly what will be updated.
This was not a sub query that is executed for each line preformance should be better.Kind regards
Peter
-
An update on an index column with the same value generates an index to the top
An update on an index column with the same value generates an update of the index?
Thank youIn addition to my previous answer, see also
http://orainternals.WordPress.com/2010/11/04/does-an-update-statement-modify-the-row-if-the-update-modifies-the-column-to-same-value/
Riyaj Shamsudeen has this to say:
"+ We have an index on this column v1 and we update this column indexed too." Oracle was updating the indexed column? N ° if the values match the level of the indexed column, then the code of RDBMS isn't up-to-date index, a feature for optimization again. Only the row of table is updated, and the index is not updated. + "Hemant K Collette
-
compare the value of previous line with the current value
I need to compare the previous value with the current value. All Oracle functions could there be to do?
Something similar as a result.
If previous (Amt {}) > Current (({Amt}) then 0 Else Null.)Something like that?
SQL> WITH test_data AS 2 ( 3 SELECT 107019 AS ID, 1583 AS AMT FROM DUAL UNION ALL 4 SELECT 107019 AS ID, 1572 AS AMT FROM DUAL UNION ALL 5 SELECT 107019 AS ID, 1572 AS AMT FROM DUAL 6 ) 7 -- END SAMPLE DATA 8 SELECT ID 9 , (CASE 10 WHEN LAG(AMT,1) OVER (PARTITION BY ID ORDER BY ID) = AMT THEN NULL 11 ELSE AMT 12 END) AS AMT 13 FROM test_data; ID AMT ---------- ---------- 107019 1583 107019 1572 107019
-
Grouping of consecutive rows with the same value?
Hello
I have a table in which are three columns:
ROWID is a primary key with a unique ID columnROWID SHOPNAME 1 SHOP_C 2 SHOP_A 3 SHOP_C 4 SHOP_C 5 SHOP_A 6 SHOP_A 7 SHOP_C 8 SHOP_B 9 SHOP_B 10 SHOP_E 11 SHOP_A 12 SHOP_D 13 SHOP_D 14 SHOP_F 15 SHOP_G 16 SHOP_F 17 SHOP_C 18 SHOP_C 19 SHOP_C 20 SHOP_C
Shopname is varchar2 column
I want to make groupings of each value 'shopname""order by ROWID"such that when there are consecutive lines of the same group shopname remains same and as soon as there is a different value in shopname column for the next line changes to"group ".
My desired output is with the 3rd column of groups as follows:
I want be done via Analytics, so that I can partition by clause for different stores in different citiesROWID SHOPNAME Groups 1 SHOP_C 1 2 SHOP_A 2 3 SHOP_C 3 ------> same grouping because Shop name is same 4 SHOP_C 3 ------> same grouping because shop name is same 5 SHOP_A 4 ----> different shopname so group changed. 6 SHOP_A 4 ----> same group as above because shopname is same 7 SHOP_C 5 8 SHOP_B 6 9 SHOP_B 6 10 SHOP_E 7 11 SHOP_A 8 12 SHOP_D 9 13 SHOP_D 9 14 SHOP_F 10 15 SHOP_G 11 16 SHOP_F 12 17 SHOP_C 13 18 SHOP_C 13 19 SHOP_C 13 20 SHOP_C 13
concerning
Ramis.with data(row_id, shop) as ( select 1, 'SHOP_C' from dual union all select 2, 'SHOP_A' from dual union all select 3, 'SHOP_C' from dual union all select 4, 'SHOP_C' from dual union all select 5, 'SHOP_A' from dual union all select 6, 'SHOP_A' from dual union all select 7, 'SHOP_C' from dual union all select 8, 'SHOP_B' from dual union all select 9, 'SHOP_B' from dual union all select 10, 'SHOP_E' from dual union all select 11, 'SHOP_A' from dual union all select 12, 'SHOP_D' from dual union all select 13, 'SHOP_D' from dual union all select 14, 'SHOP_F' from dual union all select 15, 'SHOP_G' from dual union all select 16, 'SHOP_F' from dual union all select 17, 'SHOP_C' from dual union all select 18, 'SHOP_C' from dual union all select 19, 'SHOP_C' from dual union all select 20, 'SHOP_C' from dual ), get_data as ( select row_id, shop, lag(shop) over (order by row_id) prev_shop from data ) select row_id, shop, sum(case when shop = prev_shop then 0 else 1 end ) over (order by row_id) grps from get_data; ROW_ID SHOP GRPS ------ ------ ---- 1 SHOP_C 1 2 SHOP_A 2 3 SHOP_C 3 4 SHOP_C 3 5 SHOP_A 4 6 SHOP_A 4 7 SHOP_C 5 8 SHOP_B 6 9 SHOP_B 6 10 SHOP_E 7 11 SHOP_A 8 12 SHOP_D 9 13 SHOP_D 9 14 SHOP_F 10 15 SHOP_G 11 16 SHOP_F 12 17 SHOP_C 13 18 SHOP_C 13 19 SHOP_C 13 20 SHOP_C 13 20 rows selected
-
Fill area of the screen with the first value in the record group
Hi guys, what the title essentially says. I have a display element that is populated by the by selecting the appropriate option in a LOV. Is there a method that I can put in when a new instance of the form or something else to fill the screen with the first item in the record group used to fill the lov to ensure when the load form display area is not empty. I know I have to hard just in code, but I would have the value come from the record group.
Thank you
Published by: user13390506 on August 25, 2010 05:39This works very well for me:
Created a record group (RG1) with the following order of selection:
select table_name, table_name from user_tables order by 1
Created a button on the Web that are running the following:
PROCEDURE pop IS rg_id RecordGroup; gc_id GroupColumn; col_val VARCHAR2(1000); n number ; BEGIN rg_id := Find_Group( 'rg1' ); IF Id_Null(rg_id) THEN Message('Record Group rg1 does not exist.'); RAISE form_trigger_failure; END IF; n := Populate_Group( rg_id) ; gc_id := Find_Column( 'RG1.TABLE_NAME' ); IF Not Id_Null(gc_id) THEN col_val := GET_GROUP_CHAR_CELL( gc_id, 1 ); message(col_val); End if ; End;
I guess the record_name.column_name at the top of case...
François
-
List of SelectOneChoice with a special value which allows another element of input text
Hello
My clients needs a page with a selectOneChoice component and a special value in it ('other'), which should allow another piece of text.
What is the best practice for whom?
I use Jdev 12.1.2
Thanks experts!
Hi Jose,
If you have added the 'other' value in the table, then all you need to do is the following:
The area you want to hide, should be with the property visible as #{bindings.mylov.attributeValue eq 'other'}. Now you SelectOne | Choice must be with autosubmit-> true, and finally, the area you want to hide must have a partialTrigger pointing to the SelectOneChoice.
In this way, if you select 'other' the autosubmit updates the model, this expression bindings.mylov.attributeValue eq 'other' will be set to true, and you will make a PPR in the hidden component that will appear.
Concerning
-
Photos with the same values of position...
I have a picture with the edited/customized position values (scale, rotation, inclination, perspective, disort, warp)... I have some photos that will be on the different layers and I want that they have the same values as the first (it's stupid to do the same thing with 10 photos...) I tried to duplicate the layers and replacement is contained, but values are lost, so the photos appear in the normal position...
So how can guys, I do this?
For this to work properly, all images must be of the same size and resolution.
- Integrate the file of the first image.
- Layer > Smart object > convert to smart object
- Edit > free transform and establish the size, position and orientation... .OK
- Cmd + J to create a layer of dupe
- Layer > Smart Object > replace content
- Choose the following image > replace
Repeat steps 4-6
-
date fill in the dimension with the correct values
Hi all
I have a 'simple' problem, but can't get it resolved! The calculations of the CDA in the cube not 'reset' at the right moment in time (they should 'reset' on the exercise, but it actually seems to happen on the normal calendar year).
Our dimensions and cubes are MOLAP. There is a relational table that contains columns with values for both a calendar hierarchy as well as a hierarchy of exercise. This table tells the date dimension (only the tax hierarchy as MOLAP, we have just a fiscal hierarchy). The result seems correct in the data viewer.
The cube is filled with both relational sources. A perspective provides the measurement values and CODE (distinctive signs of business) values for each dimension involved. In the case of the date dimension, it provides the code for the involved level value in which we cube (months).
I made a very simple testcase with only 1 dimension (date) and 1 small cube. The cube uses only the dimesion of date (to load the cube on the fiscal hierarchy at the month level) and has 1 base measure that is loaded with a simple number and 1 calculated measure that calculates the value of the CDA for this basic measure. The calculated measure is added to the cube designer OWB by using the button 'generate calculated measures' and choosing the function 'Year to Date'.
When complete the cube and using the data viewer to verify the results, CDA values don't 'reset' at the end of the year. They seem to reset at the end of the normal calendar year!
After some tests, I have concluded that this has to do with the values I provide to fill the date dimension, but I can't figure out what should be the change, and I can't find examples anywhere.
Someone out there a calculation for a YEAR of work in MOLAP?
Any help much appreciated.
Kind regards
Ed
Hi Ed
It can be an inherent behavior of the time dimension in the AWs where the CDA on financial is not supported out of the box, see the OLAP thread below. Have you tried just build your simple case in AWM recreate? If you can get around using a custom expression, you should be able to define this custom OWB and still keep the design you have.
Calculated against calendar CDA CDA tax measure
See you soon
David -
How re - initialize an array with the new values at run time?
Hello
In this application of particluar I want to change the value of a particular index (Ex: 4th move in a 1 d table) and store the changed value (Inremented) in the same index position.
I wrote a program, can someone tell what I am doing wrong?
LabVIEW version: 8.6
Screenshot kindly updated instead of .vi
Two things.
First of all:
You must initialize the table (via the feedback loop).
Click with the right button on the wire of the array and create constant. Move the index of item 99. Initialize element 0. This thread up to the lower part of the feedback node.
Second:
You use an Insert in the table VI, but it's not describe what you try to do. While he places an element in the position shown is also increases the size of the table.
This change to a subset of table replace VI.
Maybe you are looking for
-
Problems on iPad after updating iOS 10, departure lack &; no ID of TOUCH!
I use and iPad 2 and just put Air updated to iOS 10 a few moments ago. Two problems: (1) when I start my iPad, the screen displays the logo of apple for a good 3-4 minutes, then it goes to lock the screen massive lag! (2) my iPad does not recognize t
-
Can't boot from USB/dvd drive on Satellite Pro M10
Hello the broken internal dvd drive, an external USB disk is used. Now I need to reinstall windows on a new hard drive. How can I boot from the external hard drive? (I don't have a floppy drive, but I can't find the right drivers) Thank you Luke
-
HP Pavilion 23-b026in: upgrade Windows 10
I had upgraded my HP Pavilion 23-b026in to Win 8.1 to win 10 2 months ago. Everything worked perfectly for about 3 weeks. But 3 weeks after the upgrade, the PC wouldn't start (black screen). The motherboard has been changed by a HP technician under w
-
Will there be strikes hotkey or quick drop to quickly get a VI documentation?
Hi all: Is there a way to quickly access property of a VI Documentation (perhaps using a keyboard shortcut) so that it saves time to make use of the usual click through a few menus? This would save me a lot of time in the documentation I have much V
-
Program running as an administrator in Win Server 2012
Hello I installed Win Server 2012 on my hyper-v virtual machine. I installed the trial version of Statistica software there. When you run the trial version, should be the admin right otherwise, he asks for the license. When I run the program in Win 7