using the query, add multiple, logically divide
query
create table dummy ( a number , b number); insert into dummy values (78,16); insert into dummy values (102,16); insert into dummy values (40,45); insert into dummy values (87,19);
I want to build a query only, which should result as below:
col1 | col2 | COL3 |
---|---|---|
78 | 16 | 0 |
100 | 0 | 16 |
40 | 45 | 0 |
87 | 13 | 6 |
explanation
1. 78 + 16 = 94
2. 102 + 16 = 118, baseline is 100, 100 = col1, col2 = 0, number more than 100 should fill col3
3 87 19 plus 106, 87 = col1, col2 = 13 while col1 and col2 = 100 and more col3 > 100 complete with 6
SQL > select col1 least (a 100).
case 2
3 when a + b > 100 then 0
4 least (b 100) else
5 end col2,
case 6
7 when a + b > 100 then least(a,100) + least (b 100) - 100
8 0 otherwise
end 9 col3
model 10
11.
COL1 COL2 COL3
---------- ---------- ----------
78 16 0
100 0 16
40 45 0
87 0 6
SQL >
SY.
Tags: Database
Similar Questions
-
Using the index of multiple values
Hi guys,.
Trying to assess the benefits of the addition of index of multiple values, a quick question on the index of multiple values:
Here's my content from the cache:
Key (EmpID), value [employee (age int, double salary, Department of String)]
(1, new employee (25, 35000.0, "Admin"));
(2, new employee (22, 30000.0, "Admin"));
(3, new employee (34, 40000.0, 'Communications'));
(4, new employee (36, 41000.0, "Admin"));
(5, new employee (36, 42000.0, "HR"));
(6, new employee (29, 30000.0, "HR"));
(7, new employee (51, 50000.0, "BackOffice"));
(8, new employee (36, 35000.0, "HR"));
(9, new employee (46, 45000.0, "Admin"));
(10, new employee (48, 47000.0, "HR"));
If I still want to find all employees in the 'Human resources' Department and whose salary is more than 35000.
Eventually, I would like to do the following:
ValueExtractor salExtractor = new PofExtractor (Integer.class, 2);
ValueExtractor depExtractor = new PofExtractor (String.class, 3);
cache.addIndex (salExtractor, false, null);
cache.addIndex (depExtractor, false, null);
EqualsFilter departmentFilter = new EqualsFilter (depExtractor, 'HR');
GreaterFilter salFilter = new GreaterFilter (salExtractor, 35000);
Filter allFilter = new AllFilter (new filter [] {departmentFilter, salFilter});
Employees value = cache.entrySet (allFilter));
For my usecase above how can I use the indexing of multiple values to the same query?
ValueExtractor salExtractor = new PofExtractor (Integer.class, 2);
ValueExtractor depExtractor = new PofExtractor (String.class, 3);
MultiExtractor mExtractor is new MultiExtractor (new ValueExtractor [] {salExtractor, depExtractor});.
cache.addIndex (mExtractor, false, null);
But how can I use the extractor to create multivalued filter queries for employees in the Department of human resources with greater than 35000 salary? Any ideas are much appreciated.
Thank youD wrote:
Hi guys,.Trying to assess the benefits of the addition of index of multiple values, a quick question on the index of multiple values:
Here's my content from the cache:
Key (EmpID), value [employee (age int, double salary, Department of String)]
(1, new employee (25, 35000.0, "Admin"));
(2, new employee (22, 30000.0, "Admin"));
(3, new employee (34, 40000.0, 'Communications'));
(4, new employee (36, 41000.0, "Admin"));
(5, new employee (36, 42000.0, "HR"));
(6, new employee (29, 30000.0, "HR"));
(7, new employee (51, 50000.0, "BackOffice"));
(8, new employee (36, 35000.0, "HR"));
(9, new employee (46, 45000.0, "Admin"));
(10, new employee (48, 47000.0, "HR"));If I still want to find all employees in the 'Human resources' Department and whose salary is more than 35000.
Eventually, I would like to do the following:
ValueExtractor salExtractor = new PofExtractor (Integer.class, 2);
ValueExtractor depExtractor = new PofExtractor (String.class, 3);
cache.addIndex (salExtractor, false, null);
cache.addIndex (depExtractor, false, null);EqualsFilter departmentFilter = new EqualsFilter (depExtractor, 'HR');
GreaterFilter salFilter = new GreaterFilter (salExtractor, 35000);
Filter allFilter = new AllFilter (new filter [] {departmentFilter, salFilter});
Employees value = cache.entrySet (allFilter));For my usecase above how can I use the indexing of multiple values to the same query?
ValueExtractor salExtractor = new PofExtractor (Integer.class, 2);
ValueExtractor depExtractor = new PofExtractor (String.class, 3);
MultiExtractor mExtractor is new MultiExtractor (new ValueExtractor [] {salExtractor, depExtractor});.
cache.addIndex (mExtractor, false, null);But how can I use the extractor to create multivalued filter queries for employees in the Department of human resources with greater than 35000 salary? Any ideas are much appreciated.
Thank you
I remember, values multiple index refers to a different concept: a multivalued index means that you can retrieve a collection of values of similar role of an attribute on which you can do Contains, ContainsAll filtering, and ContainsAny.
In this case to fully the lever consistency of querying capabilities, you would
- either add a sorted index with a custom comparator that compares the tables containing a salary and a Department on a first salary so the base of the Department and add a filter custom which is able to take advantage of the index for the request for the salary and also able to filter on the element of the array of index service
-Add two independent indices (a sorted index of wages and a unsorted for the Department), in which case you can leverage all existing (GreaterThanFilter, EqualsFilter and AndFilter) codeBest regards
Robert
-
Using the QUERY parameter in exp/expdp
Hi, I've faced a nite last question.
IM currently using Oracle 10 g (10.2.0.4) OS - MS Windows Server 2003
I want a dump of tables to export multiple schemas. say (acb.m1, pqr.b2, xyz.b1)
Each table has a minimum lines of 2,000,000,
And I want to just the initials 10 rows in each table of export
Is it possible that I can do this...
Please answer.
Thanks in advanceExport tables in multiple schemas is not supported in Data Pump until 11.1.0.7. So if you're on 10g, you will need to run multiple commands expdp. For only 10 lines of each table, use the query parameter
Query = "where rownum"<>
This will apply to all the tables you export.
I hope this helps.
Dean
Published by: Dean WINS January 30, 2012 08:42
-
I'm traying to add a route using the route add command, the command response is "the requested operation requires a rise."
Command: route add 10.1.1.0 mask 192.168.31.3 192.168.31.33
Whay can I do, because I had tried in many cases
original title: route command
In response to a previous and similar thread...
You can watch using the PowerShell...
http://TechNet.Microsoft.com/en-us/library/bb978526.aspx
http://TechNet.Microsoft.com/en-us/scriptcenter/dd742419.aspx
.. .and post this question on the forum of Windows PowerShell...
http://social.technet.Microsoft.com/forums/en/winserverpowershell/threads
-
Inserting data by using the query
Hello
In a book, I read the Sub statement:
Inserting data by using the query (DML)
If the user wants to transfer data from a table to another table in the insert statement are used independently of data that can be processed or not processed form.
Can someone clarify what is the significance of this (processed or unprocessed form).
Thank you.
Why don't you ask the author of the book.
How can we know what the author means when you take a quote out of context and don't provide any reference so that we can see exactly what is shown to you.
I can only imagine that they are referring to data that are queried directly, "like what", another table, or who was interrogated and manipulated before be inserted.
-
the search for empty cells by using the query designer
Hello
I'm trying to exclude empty cells in a field (by using the Query Builder), and I did:
xDocumentSource < match > "CDL".
< AND >
< NOT > (xRelatedMsgid < match > "" "")
but it does not work. I tried "NULL", but it does not work either. Could someone tell me how to do it (or where I can find examples of queries).
Kind regards
Iwona
https://blogs.Oracle.com/Kyle/entry/searching_for_null_values_ucm
-
List of virtual machines in TIME using the query service
Someone been able to use the query service to produce a range of virtual machines in a paralytic? I don't see all the attributes on the VclQueryadminVMField that reference the vApp.
I log in the org of system.
Any help would be appreciated.
Name of the action: getVAppVms
Entry: VAPP (vCloud:VApp)
Output: Array / vCloud:VM
Script:
var vcdHost = vApp.getHost(); var vms = new Array(); var queryService = vcdHost.getQueryService(); expression = new VclExpression(VclQueryVMField.CONTAINER, vApp.getReference().href, VclExpressionType.EQUALS); filter = new VclFilter(expression); params = new VclQueryParams(); params.setFilter(filter); var resultSet = queryService.queryRecords(VclQueryRecordType.VM, params); while (resultSet != null) { var records = resultSet.getRecords(new VclQueryResultVMRecord()); System.log(records.length + " VM records found"); for each (var record in records) { var vmRef = new VclReference(); vmRef.href = record.href; vmRef.name = record.name; vmRef.type = record.type; vms.push(vcdHost.getEntityByReference(VclEntityType.VM, vmRef)); } resultSet = resultSet.getNextPage(); } return vms;
This is what made our team (more precisely - Christophe)
-
Not able to change the password by using the query.
Select APPS.fnd_web_sec.change_password ('username', 'password') 'RES' double;
Can someone tell why and what privileges and subsidies have flexibility to the user non-apps while it can change the password using fnd_web_sec.change_password.
Concerningthe information above does not solve my problem, I get the message
Because you do not have permission on all objects that are referenced by the API (see below).
Select FND_WEB_SEC. CHANGE_PASSWORD ('MARSHAD', 'mohammad @123') "RES" of the double
*
ERROR on line 1:
ORA-00942: table or view does not exist
ORA-06512: at the 'APPS '. FND_CORE_LOG', line 25
ORA-06512: at the 'APPS '. FND_CORE_LOG', line 432
ORA-06512: at the 'APPS '. FND_PROFILE', line 110
ORA-06512: at the 'APPS '. FND_SSO_MANAGER", line 227
ORA-06512: at the 'APPS '. FND_WEB_SEC', line 1425
ORA-06512: at line 1...
can you please list me what are the grants and other Jules Destrooper I should give to a user so that he can change password.
I don't have the list of objects and you should get yourself by consulting the site code and eTRM API.
by changing the DDT in the user non-apps after the grant, will, it may be able to change the password.please tell this syntax is correct or not.
Select applications. FND_WEB_SEC. CHANGE_PASSWORD ('user', 'pwd') "RES" of the doubleWhat is the point of using 'FND_WEB_SEC. CHANGE_PASSWORD' and not FNDCPASS or FND_USER_PKG API?
Thank you
Hussein -
DataPump import by using the query
Hello
I need to import data by filtering using the query. can anyone help?
Thank youHello
example ofexpdp HR/hr = emp QUERY:'"WHERE dept_id > 10 AND sal > 10000"' NOLOGFILE = y DIRECTORY = dpump_dir1 DUMPFILE = exp1.dmp
Impdp HR/hr DIRECTORY = dpump_dir1 DUMPFILE = expfull.dmp QUERY = departments:'WHERE department_id «»< 120"'="" nologfile="">
See this link
http://download.Oracle.com/docs/CD/B13789_01/server.101/b10825/dp_import.htm
-
IMPDP | Possible using the query option
HI PPL,
I wanted to know if IMPDP is possible by using the query option, as I took full expdp dump of the mentioned table and want to import only select lines.
Impdp arup/arup directory = demo_dir dumpfile = employees.dmp
Query = employees:------"" where salary\ > 10000\ order of salary "tables used ="
version: 10 gr 2
platform: UNIX
concerningObviously, it will be slow if you are using the query option, because IMPDP must import only the data that meets the criteria; It of why we export only limited data (one or two tables as needed) and import them completely.
Concerning
Girish Sharma -
Problem in the export using the QUERY functionality
Problem in the export using the QUERY functionality
I'm trying to export some rows in a table using the query functionality
and I have some errors... I'm using the syntax is
system@orcl QUERY = scott.emp expdp: '"WHERE emp_no = 123455" '
DIRECTORY = data_pump_dir DUMPFILE = data_pump.dmp
LOGFILE = data_pump_12345.log INDEX = n
Can someone tell me please the problem with that statement
I also tried to use the simple export
exp file system@orcl = orcl_export.dmp log = orcl_export.log
tables = Scott.EMP index = QUERY = n------"WHERE emp_no\ = 123455\"
and this error
EXP-00008: ORACLE error 904
ORA-00904: identify invalid
My os is Solaris
Please let me know what the problemHello
Try to create parfile and use that, otherwise, you will need to escape each clause correctly to run exp or expdp successfully.
test.par
tables=emp query="WHERE emp_no=123455" or tables=myobjects query="WHERE owner='SYS'" $> exp username/password parfile=test.par Export: Release 10.2.0.1.0 - Production on Thu Mar 19 10:17:48 2009 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining Scoring Engine options Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set About to export specified tables via Conventional Path ... . . exporting table MYOBJECTS 22650 rows exported Export terminated successfully without warnings.
Concerning
Published by: OrionNet on March 19, 2009 10:21
-
Impossible to use the chat on multiple computers and browsers support...
Original error becomes incorrect serial number when you try to install Acrobat 9 Pro,
SN is taken from the box - checking accounts
My main problem is trying to contact someone to handle this... the only option I can find is to use the support chat
which does not work (on multiple computers using several browsers). I certainly do not seem to only I have this and the use of the forum seems to be the only alternative.
1st time, that I had to deal with the help of adobe and so far I'm going along in circles wasting my time and my customers because of what seems to be a common problem. I've now read several forums but I have not seen an answer about not being able to contact support... except CONTACT SUPPORT!
Contact the office of the United Kingdom again and ask them to check the s/n. Even if the product is not supported or compatible (Acrobat 9 is compatible only with Windows 7 since the versions that you mentioned, and even then there are 9.2 or later version), they should still be able to tell if your s/n is valid or not. If they refuse to work, ask to speak to a supervisor.
-
Using the query to get the group by rollup subtotal
Hello
Expected output is, for 'chris' each record must have subtotal row because it has different 'no' of the column values.
For 'John' the subtotal came as planned because she didn't even.
Could you please correct the query for "chris" below!
select case when nm is null then 'Total' when no is null then 'Subtotal' else nm end nm,no,emplmt,profund,status,dt,sal,days,intrst,intrs1,intrs2 from ( with t as (select 'chris' nm , 10 no ,'FT' Emplmt, 'PF' ProFund , 'Reg' Status ,to_Date ('01/22/2014','mm/dd/yyyy') dt , 2456 sal, 10 days , 50 intrst ,55 intrs1 ,60 intrs2 from dual union all select 'chris' nm , 20 no ,'FT' Emplmt, 'PF' ProFund , 'Reg' Status ,to_Date ('01/03/2014','mm/dd/yyyy') dt , 1000 sal, 30 days , 50 intrst ,55 intrs1 ,60 intrs2 from dual union all select 'chris' nm , 30 no ,'FT' Emplmt, 'PF' ProFund , 'NonReg' Status ,to_Date ('01/01/2014','mm/dd/yyyy') dt , 20 sal, -5 days , 1 intrst ,1 intrs1 ,1 intrs2 from dual union all select 'john' nm , 11 no ,'PT' Emplmt, 'PF' ProFund , 'Reg' Status ,to_Date ('05/02/2014','mm/dd/yyyy') dt , 1153 sal, 10 days , 50 intrst ,55 intrs1 ,60 intrs2 from dual union all select 'john' nm , 11 no ,'PT' Emplmt, 'PF' ProFund , 'Reg' Status ,to_Date ('05/16/2014','mm/dd/yyyy') dt , 1000 sal, 8 days , 40 intrst ,45 intrs1 ,50 intrs2 from dual ) select nm,no,emplmt,profund,status,dt,sum(sal)sal,sum(days)days,sum(intrst)intrst,sum(intrs1)intrs1,sum(intrs2)intrs2 from t GROUP BY ROLLUP (nm,no,emplmt,profund,status,dt) order by nm,no,emplmt,profund,status,dt ) where (no is not null and emplmt is not null and profund is not null and status is not null and dt is not null) or (no is null and emplmt is null and profund is null and status is null and dt is null)
allows us to use grouping sets to produce just the totals you want.
with t as
(select "chris" nm1, 10 no1, "Pi" Emplmt, "PF" ProFund "Reg" Status, to_Date (January 22, 2014 "," mm/dd/yyyy") dt, 2456 sal, 10 days, 50 intrst, intrs1 55 intrs2 60 double)
Union of all the
Select No, the "chris" nm, 20 'ft' Emplmt, "PF" ProFund "Reg" Status, to_Date (3 January 2014 "," mm/dd/yyyy") dt, intrst 50, intrs1 55, 1000 sal, 30 days, 60 intrs2 of the double
Union of all the
Select "chris" nm, 30 no, "Pi" Emplmt, ProFund "PF", "NonReg" State, to_Date (January 1, 2014 "," mm/dd/yyyy") dt, 20 sal,-5 days, 1 intrst, 1 intrs1, 1 intrs2 of the double
Union of all the
Select "Jean" nm, 11 no, "PT" Emplmt, "PF" ProFund "Reg" Status, to_Date (May 2, 2014 "," mm/dd/yyyy") dt, 1153 sal, 10 days, 50 intrst, intrs1 55 intrs2 60 double
Union of all the
Select "Jean" nm, 11 no, "PT" Emplmt, "PF" ProFund "Reg" Status, to_Date (16 may 2014 "," mm/dd/yyyy") dt, 1000 sal, 8 days, intrst 40, 45 intrs1, 50 intrs2 of the double
)
SELECT
CASE
WHEN grouping (nm1) = 1
THEN "Total".
WHEN grouping (emplmt) = 1
THEN "Subtotal".
Of ANOTHER nm1
END nm,
CASE
WHEN grouping (emplmt) = 1
THEN NULL
Of ANOTHER no1
END no emplmt, profund, status, dt, sal SUM (sal), SUM (days) days, SUM (intrst) intrst, SUM (intrs1) intrs1, intrs2 SUM (intrs2)
T
GROUP BY Grouping SETS ((), (nm1, no1), (nm1, no1, emplmt, profund, status, dt))
ORDER BY nm1, no1, emplmt, profund, status, dt
NM NO EM PR STATUS DT SAL DAYS INTRST INTRS1 INTRS2 chris 10 FT PF Reg 22.01.14 2456 10 50 55 60 Subtotal 2456 10 50 55 60chris 20 FT PF Reg 03.01.14 1000 30 50 55 60 Subtotal 1000 30 50 55 60chris 30 FT PF NonReg 01.01.14 20 -5 1 1 1 Subtotal 20 -5 1 1 1john 11 PT PF Reg 02.05.14 1153 10 50 55 60 john 11 PT PF Reg 16.05.14 1000 8 40 45 50Subtotal 2153 18 90 100 110 Total 5629 53 191 211 231
-
Retrieve the screen VCD ticket using the query service
Good afternoon.
Anyone has any advice on the recovery of the url of the post screen for a virtual machine by using the VCD query service?
Thre is a wonderful post on VirtuallyGhetto on how to retrieve this pure REST help, but I can't translate to VCO.
Any help would be greatly appreciated.
Have you checked the workflow 'Acquire a ticket' in the library?
Christophe.
-
use the software on multiple computers
I don't think it's a question of 'forum', but I can't understand how to contact Adobe directly (very annoying!). I need to know if, with a creative cloud account, I use Photoshop on my laptop and my desktop computers. Someone knows the answer, or know where to find? If you can answer me by e-mail (email removed by moderator) who would be useful, as I don't regularly check this forum. Thank you -
See also CC help | Creative cloud / Common Questions
Can I use the software that I download creative cloud on more than one machine?
Yes. Creative desktop cloud applications can be downloaded and installed on multiple computers, regardless of the operating system. However, the activation is limited to two machines per person associated with membership. See terms of use for more information. Learn how to turn off a Creative License on a cloud machine.
Maybe you are looking for
-
Firefox crashes when I open it and I can't open it in safe mode
Here's the crash id I hope they can be more detailed than what I'm typing BP-25faf820-3ada-4c6b-846f-a3c412130711 BP-d123fd1a-CD29-46f0-AC47-e29ff2130711 BP-04cbde72-6dd1-4344-89cd-f63d72130711 BP-a491faed-59C6-401F-8E38-802632130711 Here's the info.
-
Qosmio F20: How to use a TV tuner?
Hello I recently bought a F20 but cannot tune TV. I followed the instructions of windows media and when you grant through the main Jimmy TV I get no picture. I am not an expert with computers so am well and truly stuck. Any advice will be greatly app
-
Help.My HP8660 all-in-one does not work correctly.
When I use color scanning and copying, the book came out with a lot of vertical colored lines. But it works fine if I copy in black and grayscale scanning.
-
downloaded game trys to install but theres just a black flash
I reinstalled windows 2000 xp and know that I loaded cradel of Persia: off playcity.com and know that it will not install the game
-
My son it is very difficult to make a black text on white background, but he is very good with blue on white. How can I make sure that all text, regardless of the program, etc., shows the text in blue on a white background? We use Vista. Thank you.