order by in select query
Hi guysI get problem in my select query that creates a long string, it works very well without a prescription but when I run this order that she be hanged. This request for help on the function to concatenate multiple strings into one string as well
Please help me what I'm doing wroing.
Select
regexp_substr(PE.emp_id,'[0-9]+$') |' | ' ||
p.title |' | ' ||
CDT. Text: ' |' |
j.tit | staff_pcb.host_pub_tit |' | ' ||
jou.vol | PCB.vol | PCP.vol |' | ' ||
jou.journal_number |'| ' |
substr (jou.pages |) PCB.pages | PCP.pages, 1, instr (jou.pages |) PCB.pages | PCP.pages, '-')-1) |' | ' ||
substr (jou.pages |) PCB.pages | PCP.pages, instr (jou.pages |) PCB.pages | PCP.pages, '-') + 1) |' | ' ||
PCB.St | jou. St | PCP.St |'| ' |
concat_aut (p.ID)
Pub p, j, caa c, pe, cdt class_t,.
(select pcj.pub_id, pcj.vol, pcj.pages, pcja.st
Of pub_C_j_a airports, JCP pc_j
where pcja.pub_c_j_id = pcj.pub_id) played.
(select pcb.pub_id, pcb.host_pub_tit, pcb.pages, pcb.vol, pcba.st
Pub_c_b pcb, printed circuit board pub_c_b_a
where pcba.pub_c_b_id = pcb.pub_id) pcb.
(select pcp.pub_id, pcp.vol, pcp.pages, pcpa.st
Of pcp, pub_c_p_a LPA pub_c_p
where pcpa.pub_c_p_id = pcp.pub_id) CFP,.
where
p.ID = c.pub_id
and c.person_id = pe.id
and p.t_c_id = cdt.c_id
and p.journal_id = j.id (+)
and p.id = jou.publication_id (+)
and p.id = pcb.publication_id (+)
and p.id = pcp.publication_id (+)
and substr (regexp_substr(pe.emp_id,'[0-9]+$'), 1, 2) in('77','78')
and pcb.st. jou. St | PCP.St = '1' order of pe.emp_id
;
Here's something
regexp_like(emp_id,'(^|[^0-9])(77|78)[0-9]*$')
work instead?
Not sure if this should use an index no longer however.
Kind regards
Bob
Published by: BobLilly on March 25, 2010 14:56
Published by: BobLilly on March 25, 2010 14:58
Tags: Database
Similar Questions
-
Hello
First of all, I had two tables. The first PARAMETER called that inculdes three columns parameter_id (number), the parameter_desc (varchar2 (20) and (number) parameter_value.) The parameter_id is a PK. The INSERT statement might like this:
Enter the parameter (parameter_id, parameter_desc, parameter_value) values (1, 'TEST1', 233);
Enter the parameter (parameter_id, parameter_desc, parameter_value) values (2, 'TEST2', 456);
Insert in the parameter (parameter_id, parameter_desc, parameter_value) values(3,'TEST3',678);
And a second table, called TOPO_PARAM, which includes three columns (number) topo_id, parameter_id (number) and topo_param_value (varchar2 (10).) The PK is on topo_id and parameter_id. The insert for this one is
insert into topo_param (topo_id, parameter_id, topo_param_value) values (349.1, 'FALSE');
insert into topo_param (topo_id, parameter_id, topo_param_value) values (568,2, 'TRUE');
I want a select query that links the two tables and returns this:
If topo_id = 349
I wish to have this:
parameter_id parameter_value topo_param_value
1 233 'FALSE'
2 456 NULL
3 678 NULL
If topo_id = 568,
parameter_id parameter_value topo_param_value
1 233 NULL
2 456 'TRUE'
3 678 NULL
And if topo_id = 500,
parameter_id parameter_value topo_param_value
1 233 NULL
2 456 NULL
3 678 NULL
Thanks for your response!
SELECT T1. PARAMETER_ID,
T1. PARAMETER_VALUE,
T2. TOPO_PARAM_VALUE
THE PARAMETER T1 LEFT OUTER JOIN
TOPO_PARAM T2
ON T1. PARAMETER_ID = T2. PARAMETER_ID
TOPO_ID = & INP
ORDER OF T1. PARAMETER_ID;
OUTPUT:
Enter the value of the inp: 349
7 old: AND TOPO_ID = & INP
7 new: AND TOPO_ID = 349PARAMETER_ID PARAMETER_VALUE TOPO_
------------ --------------- -----
1 233 FALSE
2 456
3 678 -
Hello
I have a query something like...
Select...
....
where
b.ProdName as 'GEAR of the TREE %' or b.prodname like '% FRONT GEAR %' or b.prodname like '% BREAK 4 %k '.
and
b.ProdName as
(select the name of the society of companyms
where < some comdition >
)
order of 3.6
I have blocked in:
b.ProdName as
(select the name of the society of companyms
where < some comdition >
)
How to give a select query with like operator.
In above query I want to b.prodname as above and the name of the company for which I give condition. Company names are stored in another table and I want to select and use them with like operator.
Thank you.
Hello
It is not clear what you want to do.
One possibility is an EXISTS subquery, like this:
...
WHERE (b.prodname LIKE "% of the CYCLE of the TREE" - begins with this text
OR b.prodname LIKE '% FRONT GEAR %' - contains this text
OR b.prodname LIKE '% BREAK 4 %k' - contains this text
)
AND THERE ARE)
SELECT 1
OF companynms
WHERE--a condition
AND b.prodname AS business
)
I hope that answers your question.
If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
Explain, using specific examples, how you get these results from these data.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).See the FAQ forum: https://forums.oracle.com/message/9362002
-
SELECT projid , LISTAGG (building_num, ';') WITHIN GROUP (ORDER BY building_num) AS building_nums FROM table_x GROUP BY projid;
output-buidling waited NUM should be separate. Output expected next. can you help me with the select query.From this query i am getting Actual ouput projid building_num 100 100-10;100-10 200 200-10;200-20 300 300-10;300-10;300-20 400 na;400-10;na
Published by: 893185 on March 13, 2012 09:53Actual ouput projid building_num 100 100-10 200 200-10;200-20 300 300-10;300-20 400 na;400-10
Hello
This is called String aggregation . See
http://www.Oracle-base.com/articles/10G/StringAggregationTechniques.php
many ways to do it.Which way is best for you? It depends on your version of Oracle and your specific needs.
For example, if you use Oracle 11.2, and you want the secondary channels ordered:SELECT projid , LISTAGG (building_num, ';') WITHIN GROUP (ORDER BY building_num) AS building_nums FROM table_x GROUP BY projid ;
-
Hi all
Need select records less where Rownum < = 100, a table in which the records are classified by a field in a query, but after stopped in the ordering of rownum gets changes.
Now I want to select records where ronum < = 2 as below, this can be done by changing only in where clause and do not touch the query select, as can do a nested query I but need to do it by changing only in where clause.with t as (select 1 a,'d' b from dual union select 8 a,'t' b from dual union select 3 a,'u' b from dual union select 7 a,'k' b from dual ) select t.*,rownum from t order by 2 ; A B ROWNUM 1 d 1 7 k 3 8 t 4 3 u 2
Thanks in advanceA B ROWNUM 1 d 1 7 k 3
Thanks and greetings
Sanjay
Published by: Sanjay March 29, 2011 06:26Hi, Sanjay
Sanjay wrote:
Hi allNeed select records less where Rownum<= 100,="" from="" a="" table="" in="" which="" records="" are="" ordered="" by="" a="" field="" in="" a="" query="" but="" after="" doing="" order="" by="" the="" rownum="" ordering="" gets="">=>
with t as (select 1 a,'d' b from dual union select 8 a,'t' b from dual union select 3 a,'u' b from dual union select 7 a,'k' b from dual ) select t.*,rownum from t order by 2 ; A B ROWNUM 1 d 1 7 k 3 8 t 4 3 u 2
Now I want to select records where ronum<= 2="" like="" below,="" can="" this="" be="" done="" by="" changing="" only="" in="" where="" clause="" and="" not="" touching="" the="" select="" query="" as="" it="" can="" be="" done="" by="" nested="" query="" i="" but="" need="" to="" do="" it="" by="" changing="" only="" in="" where="">=>
A B ROWNUM 1 d 1 7 k 3
No, there is no way to get these results by changing only the WHERE clause. As it is, you have no column or expression in the main query that indicates how the lines are classified according to b, which is exactly what to test in the WHERE clause. (Remember, ROWNUM is assigned before ORDER BY is done in the same auxiliary request). You must add a using ROWNUM or ROW_NUMBER analytic function. either way requires some preparation to be done in a subquery.
For example, the following query has an ORDER BY clause, added to the request slot, so that ROWNUM in the main query will be more arbitrary:
with t as (select 1 a,'d' b from dual union select 8 a,'t' b from dual union select 3 a,'u' b from dual union select 7 a,'k' b from dual ORDER BY b -- Added ) SELECT t.* , ROWNUM FROM t WHERE ROWNUM <= 2 -- Added ORDER BY b ;
Output:
` A B ROWNUM ---------- - ---------- 1 d 1 7 k 2
It is no coincidence that the numbers in the column ROWNUM are 1 and 2. If you want really to arbitrary numbers (such as 1 and 3), you will need an another subquery.
-
Help of the complex select query (Group by)
Hello
I am in need of your help to create a unique select query for the data in the table below and whose output requies. I use oracle 10g on RHEL 5 version.
create table bustour (number of bussno (4), start_date date, number (2)) passenger;
ALTER session set nls_date_format = "dd-mm-yyyy";
insert into bustour values (4123, April 10, 2009 ", 20);
insert into bustour values (4123, may 10, 2009 ", 25);
insert into bustour values (4123, may 10, 2009 ', 18);
insert into bustour values (4123, June 10, 2009 ', 15);
insert into bustour values (6138, March 10, 2009 ', 16);
insert into bustour values (' 6138, March 10, 2009 ", 19);
insert into bustour values (6138, April 10, 2009 ', 22);
insert into bustour values (' 6138, April 10, 2009 ", 13);
insert into bustour values ("4123, July 10, 2009 ', 23);
insert into bustour values (4123, August 10, 2009 ", 27);
insert into bustour values (4123, November 10, 2009 ', 15);
insert into bustour values (6138, may 10, 2009 ', 16);
insert into bustour values (6138, may 10, 2009 ', 13);
insert into bustour values (6138, may 10, 2009 ', 18);
insert into bustour values (' 6138, may 10, 2009 ", 24);
insert into bustour values (6138, July 10, 2009 ", 20);
insert into bustour values (6138, August 10, 2009 ", 18);
So that we can know on what particular travel calendar, we have obtained maximum passengers and the date. (For calculating % of bonus driver)SQL> select * from bustour; BUSSNO START_DATE PASSENGERS ---------- ---------- ---------- 4123 04-10-2009 20 4123 05-10-2009 25 4123 05-10-2009 18 4123 06-10-2009 15 6138 03-10-2009 16 6138 03-10-2009 19 6138 04-10-2009 22 6138 04-10-2009 13 4123 07-10-2009 23 4123 08-10-2009 27 4123 11-10-2009 15 BUSSNO START_DATE PASSENGERS ---------- ---------- ---------- 6138 05-10-2009 16 6138 05-10-2009 13 6138 05-10-2009 18 6138 05-10-2009 24 6138 07-10-2009 20 6138 08-10-2009 18 17 rows selected. I want query output as below : Bussno start_date end_Date totalpassengers maxpessenger maxpassdate 4123 04-10-09 06-10-09 78 25 05-10-09 6138 03-10-09 04-10-09 70 22 04-10-09 4123 07-10-09 11-10-09 65 27 08-10-09 6138 05-10-09 08-10-09 109 24 05-10-09
Please help me to write the query.
Best regards
NishaOK, something like this:
with my_tab as (select 1 id, 4123 busno, to_date('04/10/2009', 'dd/mm/yyyy') start_date, 20 passengers from dual union all select 2 id, 4123 busno, to_date('05/10/2009', 'dd/mm/yyyy') start_date, 25 passengers from dual union all select 3 id, 4123 busno, to_date('05/10/2009', 'dd/mm/yyyy') start_date, 18 passengers from dual union all select 4 id, 4123 busno, to_date('06/10/2009', 'dd/mm/yyyy') start_date, 15 passengers from dual union all select 5 id, 6138 busno, to_date('03/10/2009', 'dd/mm/yyyy') start_date, 16 passengers from dual union all select 6 id, 6138 busno, to_date('03/10/2009', 'dd/mm/yyyy') start_date, 19 passengers from dual union all select 7 id, 6138 busno, to_date('04/10/2009', 'dd/mm/yyyy') start_date, 22 passengers from dual union all select 8 id, 6138 busno, to_date('04/10/2009', 'dd/mm/yyyy') start_date, 13 passengers from dual union all select 9 id, 4123 busno, to_date('07/10/2009', 'dd/mm/yyyy') start_date, 23 passengers from dual union all select 10 id, 4123 busno, to_date('08/10/2009', 'dd/mm/yyyy') start_date, 27 passengers from dual union all select 11 id, 4123 busno, to_date('11/10/2009', 'dd/mm/yyyy') start_date, 15 passengers from dual union all select 12 id, 6138 busno, to_date('05/10/2009', 'dd/mm/yyyy') start_date, 16 passengers from dual union all select 13 id, 6138 busno, to_date('05/10/2009', 'dd/mm/yyyy') start_date, 13 passengers from dual union all select 14 id, 6138 busno, to_date('05/10/2009', 'dd/mm/yyyy') start_date, 18 passengers from dual union all select 15 id, 6138 busno, to_date('05/10/2009', 'dd/mm/yyyy') start_date, 24 passengers from dual union all select 16 id, 6138 busno, to_date('07/10/2009', 'dd/mm/yyyy') start_date, 20 passengers from dual union all select 17 id, 6138 busno, to_date('08/10/2009', 'dd/mm/yyyy') start_date, 18 passengers from dual) -- end of mimicking your data; use SQL below: select busno, min(start_date) start_date, max(start_date) end_date, sum(passengers) total_passengers, max(passengers) max_passengers, max_pass_date from (select id, start_date, busno, passengers, distance, max(start_date) keep (dense_rank first order by passengers desc) over (partition by distance, busno) max_pass_date from (select id, start_date, busno, passengers, -- using tabibitosan method, borrowed from Aketi Jyuuzou dense_rank() over (order by id) - row_number() over (partition by busno order by id) distance from my_tab)) group by busno, distance, max_pass_date order by min(id) BUSNO START_DATE END_DATE TOTAL_PASSENGERS MAX_PASSENGERS MAX_PASS_DATE ---------- ---------- ---------- ---------------- -------------- ------------- 4123 04/10/2009 06/10/2009 78 25 05/10/2009 6138 03/10/2009 04/10/2009 70 22 04/10/2009 4123 07/10/2009 11/10/2009 65 27 08/10/2009 6138 05/10/2009 08/10/2009 109 24 05/10/2009
-
SELECT query time-out - huge table
DBA dear friends,
DB version 11.1.0.7. I have a SELECT query that is running long and wedging on. Query joins the 2 tables. It is partitioned hash (16 sheets) and others are not partitioned, each table is with the same volume of data - 230 million lines.
> Optimizer stats are not outdated
SELECT only 1 row (as indicated in the PLAN of EXPLAIN) should be fast.
-
Can I use * and the list of the column names in a select query
PLSQL again. Can I use * and the list of the column names in a select query, i.e. Select *, col1, col2 from Mytable. When I do that my questions tend to the bomb. Can do in other databases.
Thank you
Mike
Hi, Mike,.
If there is something else in the more SELECT clause *, then * must be qualified with a table name or alias.
For example:
SELECT Mytable. *, col1, col2
FROM MyTable;
-
place a select query calculation in a different column in the same table
How can I put my calculation result in a column named within the same table?
I have a table called: dgpercentagedatachart
I use the columns of this dgpercentagedatachart: totalcecrating divided by lowestfeederrating times 100 to get the percentage
In the query, I gave the result the Alias of the cal
What I want is to put this result in my application or my calculation (in percentage) in my column "percent" on my table of dgpercentagedatachart vacuum.
How can I configure this syntax?
This is the select query, I came with:
Select dgpercentagedatachart.totalcecrating, dgpercentagedatachart.lowestfeederrating,.
100.00*dgpercentagedatachart.totalcecrating/dgpercentagedatachart.lowestfeederrating as cal
of dgpercentagedatachart;
Here are the results:
CAL lowestfeederrating Totalcecrating
8,978 7.48166666666666666666666666666666666667 120
30.951 25.7925 120
5.04 120 4.2
Hello
2685870 wrote:
How can I put my calculation result in a column named within the same table?
I have a table called: dgpercentagedatachart
I use the columns of this dgpercentagedatachart: totalcecrating divided by lowestfeederrating times 100 to get the percentage
In the query, I gave the result the Alias of the cal
What I want is to put this result in my application or my calculation (in percentage) in my empty column '%' on my table of dgpercentagedatachart .
How can I configure this syntax?
This is the select query, I came with:
Select dgpercentagedatachart.totalcecrating, dgpercentagedatachart.lowestfeederrating,.
100.00*dgpercentagedatachart.totalcecrating/dgpercentagedatachart.lowestfeederrating as cal
of dgpercentagedatachart;
Here are the results:
CAL lowestfeederrating Totalcecrating
8,978 7.48166666666666666666666666666666666667 120
30.951 25.7925 120
5.04 120 4.2
To change an existing column in a table, you can use the UPDATE or MERGE, instructions like this:
UPDATE dgpercentagedatachart
Percentage of VALUE = 100,00 * totalcecrating
/ lowestfeederrating
;
Noramlly, tables is not redundant columns like this. If percent can always be calculated from other columns, then it is probably better to calculate at run time and store it in the database, where you will have to be updated each time the columns it depends on change. You can use a view to avoid having to encode them the calculation.
If you really don't want a column that can be calculated in the same lines other columns, then use a virtual column (if you use Oracle 11 or higher).
I hope that answers your question.
If this isn't the case, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
If you ask on a DML statement, such as UPDATE, the sample data will be the content of the or the tables before the DML, and the results will be the State of the or the tables changed when it's all over.
Explain, using specific examples, how you get these results from these data.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum: Re: 2. How can I ask a question on the forums?
-
Hello
Oracle version: 11g R2 (11.2.0.2)
I get the following error message (I'm using TOAD for Oracle last version 12.1):
ORA-12801: error reported in the parallel query P032 Server
ORA-01114: block write IO file error (block #)
ORA-01114: IO error to the file 201 (block # 2165248) writing block
ORA-27072: IO file error
Linux-x86_64 error: 28: no space is available on the device
Additional information: 4
When you run a SELECT query:
SELECT field1, Field2...
OF (REVENUE_SOURCE b
INNER JOIN ACCOUNTS_CLASSIFICATION one
WE b.SUB_ACCOUNT = a.SUB_ACCOUNT)
INNER JOIN REPORT_PRODUCT_ID c
ON b.REPORT_PRODUCT_ID = c.REPORT_PRODUCT_ID
WHERE a.UC_BUSINESS_UNIT = 'ANX.
AND b.report_mm > =.
(SELECT ADD_MONTHS (MAX (report_mm),-13))
OF REVENUE_SOURCE)
AND b.REVENUE_FLAG = - 1
AND (b.CALLS <>0 b.MINUTES <>0 b.CHARGE_AMOUNT GOLD <>GOLD 0);
Please notify.
NOTE: the query worked well for a while, no errors, then all suddenly it became much accentsr and then I started to get the error message above.
Kind regards
M.R.
Hello
ORA-27072: IO file error
Linux-x86_64 error: 28: no space is available on the device
Looks like a system or OS, no SQL or PL/SQL problem problem. I think you will answer sooner if you check this issue as 'Response' and start a new question in the forum of "General Question":
https://forums.Oracle.com/community/Developer/English/oracle_database/general_questions/content
My guess is that Oracle tries to allocate space in the tablespace temp, but cannot because the disk is full. If you have a full disk, then create the space to this topic.
I see nothing wrong with your code; Certainly, nothing which would cause an error like that. The fact that the query has worked well for some time confirms that there is noting wrong with the request itself; It is just triggering a mistake elsewhere.
-
Formatting of the Select query
The following select query returns the data in green. How do I format to return the path that it is formatted in red?
Basically, if FIELD1 is "Customer A" and FIELD2 is "Gas" then I back to 'New customer' Field1 and Field2 'gas '. If 'Customer E' FIELD1 and FIELD2 is 'Total' then it should return 'E rejection' in Field1 and 'Prod_Discharge' in the Field2.
Please let me know if my question is not sensible or need to be clarified.
SELECT
DECODE (Field1, 'Nine', ' A', 'Old', 'E', 'Term', 'F', Field1)
DECODE (Field2, 'Prod', 'Gas', Field2)
Customers
FIELD1 FIELD2
Customer A gas
Customer has oil
Total customers E
Customer F Total
Need to format as follows:
Field1 Field2
New gas customer
New customer oil
E Prod_Discharged releases
F Prod_Discharged releases
Try this:
SELECT CustomerID
, CASE WHEN field1 = 'Customer A' THEN 'new customer '.
WHEN field1 = 'Customer E' AND field2 = 'Total' THEN 'E releases '.
WHEN field1 = ' customer F ' AND field2 = 'Total' THEN 'F performs ".
Of ANOTHER Field1
FIELD1 AS END
, CASE WHEN Field1 IN ('E of customer', ' customer F ') AND field2 = 'Total' THEN 'Prod_Discharged '.
Of OTHER Field2
END AS FIELD2
Status
Customers
;
-
How to run a Select query stored in a Variable
Hello
I have a following requirement:
Select a query result on Var1, result of another request selection in Var2,
If Va2 = "value11" or Var2 = "Value2" then Var1 = "select query. Now how can I run this SQL at the end of the Pl/SQL query?
so I write request for the same thing:
DECLARE
qry nvarchar2 (500);
result nvarchar2 (500);
BEGIN
Select "choose TEXTVAL as 'CHARGER' FROM TABLE1 WHERE LOC =" [ParameterValue] "and KEYNAME =" < < REPLACE > > "' double INTO qry ;"
SELECT CASE County WHEN (RW." CountofBATCH') > 1 then "mixture."
WHEN count (RW." CountofMAT') = 0 then 'None '.
ANOTHER 'other '.
END
AS a result
TABLENAME2 TT, XMLTable ('/ sets of lines/lines/lines ' PASSAGE TT.) XMLCOL
COLUMNS
"CountofBATCH" PATH "/ row [CLABS > 0] / LOADED ',"
"CountofMAT" PATH "/ row [MATNR = '[parameter value]'] / MAST '"
) AS RW
where
TT.PL = '[parameter value]' and
TT. TANK = "[value settings]";
IF result = 'Mixture' result GOLD = 'None' THEN
qry: replace = (qry, "< < REPLACE > >", result);
on the other
qry: = 'nothing. '
END IF;
Thus the qry variable will have select statement. Now how can I use this to get the select result of this statement in the same query qry?You can use execute immediately if the output of the query is in the same query.
It's very simple.
a query string signle and then go like thisdeclare
qry VARCHAR2 (255);
result varcharf2 (2500);
number of vempid: = 1;Start
qry: =' select empname emp where empid =: empid ";run immediately qry in the result using vempid;
-now the result of data is as a result
end; -
Sinlge select query in the diff for the same table (same Structure) diagrams
Scenario:
Table XYZ is created in detail a.
After a year, the old data of the previous year could be moved to another schema. However in the other schema of the same table name would be used.
For example
A schema contains XYZ table with data from the year 2012
Schema B contains XYZ table with data for the year 2011
Table XYZ in the two schemas have an identical structure.
So we can draw a single select query to read the data from the tables in an effective way.
For example select * from XYZ so including date between October 15, 2011 to March 15, 2012.
However, the data resides in 2 different schema altogether.
Creating a view is an option.
But my problem, there are ORM (Hibernate or Eclipse Top Link) layer between the application and the database.
If the queries would be constituted by the ORM layer and are not generated by hand.
So I can't use the view.
So is there any option that would allow me to use only query on different scheme?970773 wrote:
Scenario:Table XYZ is created in detail a.
After a year, the old data of the previous year could be moved to another schema. However in the other schema of the same table name would be used.For example
A schema contains XYZ table with data from the year 2012
Schema B contains XYZ table with data for the year 2011
Table XYZ in the two schemas have an identical structure.So we can draw a single select query to read the data from the tables in an effective way.
For example select * from XYZ so including date between October 15, 2011 to March 15, 2012.
However, the data resides in 2 different schema altogether.Creating a view is an option.
But my problem, there are ORM (Hibernate or Eclipse Top Link) layer between the application and the database.
If the queries would be constituted by the ORM layer and are not generated by hand.
So I can't use the view.Why not make the ORM as below?
SELECT * FROM VIEW_BOTH;
-VIEW_BOTH is a real VIEW of Oracle -
Please suggest a select query / under query with using any routines or
source table: three columns ORIGIN, DESTINATION, MILES
Origin Destination Miles
Sydney Melbourne 1000
Perth, Adelaide 3000
Canberra Melbounre 700
Melbourne Sydney 1000
Brisbane Sydney 1000
Perth, Darwin 4000
Sydney, Brisbane 1000
out put: three columns ORIGIN, DESTINATION, MILES
Duplicate routes should be ignored, so the output is
Origin Destination Miles
Sydney Melbourne 1000
Perth, Adelaide 3000
Canberra Melbounre 700
Brisbane Sydney 1000
Perth, Darwin 4000
Please suggest a select query / under query with using subroutines or functions/pkgs to get put out table.Hello
user9368047 wrote:
... Please suggest a select query / under query with using subroutines or functions/pkgs to get put out table.Why? If the most effective way to achieve the desired results is to use a function, why would you not use it?
Here's a way, without all the features:
SELECT a.* FROM source_table a LEFT OUTER JOIN source_table b ON a.origin = b.destination AND a.destination = b.origin AND a.miles = b.miles WHERE b.origin > a.origin -- Not b.origin > b.origin OR b.origin IS NULL ;
If you would care to post CREATE TABLE and INSERT statements for your sample data, and then I could test this.
Published by: Frank Kulash, November 6, 2012 19:39
Fixed WHERE after MLVrown clause (see below) -
Can get us data back from a stored procedure in a select query?
Hello
Suppose I have a function GetSum(x,y) that returns the sum of two numbers x and y. We can call this function from a function sql like this:
But it's possible thanks to a stored procedure? for example, can I call a stored procedure from a select query, as I did above code?select GetSum(4,5) SUM from dual;
bootstrap wrote:
Hello
Suppose I have a function GetSum(x,y) that returns the sum of two numbers x and y. We can call this function from a function sql like this:select GetSum(4,5) SUM from dual;
But it's possible thanks to a stored procedure?
NO!
Maybe you are looking for
-
I installed an SSD in my MBP and moved the old HD in bay view which I configured as a backup Time machine. Time Machine tries to save every hour, every day and every week as default (I think). First of all, is it possible to change this to a custom s
-
Pavilion g6: * after entering 3 times bios password wrong. System disabled-54965529
* After you enter 3 time wrong password. Deactivation of the system 54965529
-
How to transform the compatibility mode for iTunes on Windows 7?
How to disable the compatibility of a program? Original title: MESSAGE - TURN of the COMPATIBILITY MODE FOR I TUNES BEFORE OPENING - WAS ON WINDOWS XP NOW OS IS WINDOWS 7 - HOW to YOU turn OFF THIS OPTION?
-
All-in-one HP Officejet 5610 - very weak text - printing using Windows XP problems
Passed through the HP online help system to check ink levels and printed samples. All these OK. However, when you print a Word document, print is so small, that it cannot be read. Plain paper used, settings not changed project.
-
To give you an idea of what kind of project, I'm working, I did two characters in Photoshop and imported into After Effects. I did simple animations, some of them move and so on.I wanted to export more in Premiere Pro to play with her. But when I did