Interesting PLSQL request select...
Hi guys...
The following query, I have...
with tab1 as (select '53' as a 'AA' double b
Union all select them '45' as a 'BB' double b
the Union all select 'AA' as a '53' double b
Union all select 'BB' them as one, '45' double b
Union all select 'CC' them as a '88' b dual from
Union all select them '88', 'CC' double b
Union all select them '56', 'AS' double b)
Select *.
of tab1;
Power required...
A | B | |
53 | AA | |
45 | BB | |
CC | 88 | |
56 | AS |
Basically, I want to delete duplicate records and display only the 1st met recording.
Thanks guys...
Napster
You can make use of the SMALLEST and most MAJOR functions.
with tab1 as (select '53' as a, 'AA' as b from dual union all select '45' as a, 'BB' as b from dual union all select 'AA' as a, '53' as b from dual union all select 'BB' as a, '45' as b from dual union all select 'CC' as a, '88' as b from dual union all select '88' as a, 'CC' as b from dual union all select '56' as a, 'AS' as b from dual) select a, b from ( select a, b, row_number() over(partition by least(a, b), greatest(a, b) order by 1) rno from tab1 ) where rno = 1;
As you mentioned the order is not relevant I've specified as 1.
Tags: Database
Similar Questions
-
Feature request: selection of the timeline
I don't know if this is already possible, but is it possible that we can choose a specific part of the timeline as in After Effects?
I saved it takes several in a single audio file and would like to be able to select specific parts of the timeline that I'm working on my projects.
The only other option that I can think of is to split my takes separate audio files and create a scene for each audio file.
You can adjust the take (and beach bars), but we do not have the ability to specify a range of input/output for punch-in recording, or a way to divide a take at this time, but both are in our feature requests database to assess the pre-releases. I can add your name both of these applications. Thank you.
You can also try a scene from nesting in another (a bit like precomposition in After Effects) that cuts.
-
XMLquery - contours do not used throughout the code, but only in the xml request selected
Hello
We use-> database Oracle 11 g Enterprise Edition Release 11.2.0.2.0 - 64 bit
We have a part of our system of s/w works as:
If we execute just this request again, contour O_Name is used as can be seen in:Drop table xml_tbl create table xml_tbl ( xml_msg_id integer, xml_msg_text xmltype ); insert into xml_tbl values(1, '<main xmlns:ns1="Abc:SET"><ns1:id>1</ns1:id></main>'); insert into xml_tbl values(1, '<main xmlns:ns1="Abc:SET"><ns1:id>1</ns1:id></main>'); insert into xml_tbl values(1, '<main xmlns:ns1="Abc:SET"><ns1:id>2</ns1:id></main>'); commit; --Code DECLARE v_output CLOB; FUNCTION fn_xmlquery (p_date IN DATE) RETURN XMLTYPE AS v_xmlout XMLTYPE; v_query CLOB := TO_CLOB ( 'declare namespace ns1 = "Abc:SET"; fn:count($File_Data/main/ns1:id)'); BEGIN SELECT XMLQUERY (v_query PASSING t_tbl.xml AS "File_Data" RETURNING CONTENT) INTO v_xmlout FROM (SELECT XMLAGG (xml_msg_text) AS xml FROM xml_tbl t WHERE XMLEXISTS ( 'declare namespace ns1 = "Abc:SET"; /main/ns1:id = ("1") ' PASSING xml_msg_text)) t_tbl; RETURN (v_xmlout); END fn_xmlquery; BEGIN v_output := XMLType.getClobVal (fn_xmlquery (TO_DATE ('20121231', 'YYYYMMDD'))); DBMS_OUTPUT.put_line (v_output); END; --Now if I try the outline on xml_tbl query as: drop outline o_name; CREATE OUTLINE o_name ON SELECT XMLAGG (xml_msg_text) AS xml FROM xml_tbl t WHERE XMLEXISTS ( 'declare namespace ns1 = "Abc:SET"; /main/ns1:id = ("1") ' PASSING xml_msg_text); select * from dba_outlines;
Select * from dba_outlines;
It is used in the two schemas in DB, as we wish.
But if we execute all the code above, it takes, to make all the xquery deals.
O_Name OUTLINE is not used. Not even in the same pattern.
You can try the above, in your machine to replicate.
Please suggest how to do the work described in this case. As things do not work in our system at all because the query plan wrong by the above query on which we create the contour.
Thank you...
Published by: user8941550 on January 9, 2013 23:16Maybe the XQuery Modules will build in a future version of the database.
So please can you suggest a better way we can use so that we can avoid the dynamic xquery thing.
Make the dynamic SQL set instead, not only the request XQuery and run it via EXECUTE IMMEDIATE or DBMS_SQL.
This way, the CBO know XQ expression to analyze the time and be able to optimize it.I'm not a big fan of this approach, but the lack of something better.
-
Feature Request: Select and tag
Hi people
Our company often gets a lot of text into our pages.
It would be a great time of Eve in order to select the content and then apply tags opening and closing around this text via a single keyboard shortcut.
e, g,
1. Select the text
2. run the keyboard shortcut to activate an input field of the tag (with the same menu indicators used in regular tag entry).
3. the user enters the opening tag.
4 edge Code between tags opening / closing before and after the selected text.
A useful addition would be the ability to add tags custom to the list that the user often uses.
(for example a common tag followed by an attribute defined by the user, measure, etc. ()
Thank you!
Hi Thomas,
Discover the "Surround" extension: https://github.com/pedelman/brackets-surround. To install an extension like this, go to file > extensions Manager, click on 'Install from URL' and enter the URL I posted here.
-Peter
-
By selecting GeoRaster portions using SQL
Hello
I am interested in the selection of a portion of an image stored in the format inside the Oracle GeoRaster. After reviewing the documentation, I can see that there is something useful in the oracle.spatial.georaster.image.GeoRasterImage - in particular the method:
public getRasterImage (int pyramidLevel, JGeometry window) RenderedImage
However looking at the sample code provided in the API:
...
an object GeoRaster reading from database based on a request
ResultSet rs = statement.executeQuery ("" SELECT a.georaster FROM georaster_table where a.georaster.rasterdatatable =' RTD ' and a.georaster.rasterid = 1 ");
Geor rs.getObject = STRUCT (1) (oracle.sql.STRUCT);
construct a JGeoRaster object
JGeoRaster geoRaster = new JGeoRaster (geor);
get GeoRasterImage instance
GeoRasterImage geoRasterImage = geoRaster.getGeoRasterImageObject ();
retrieve a subset of the GeoRaster object as a Java image
RenderedImage image = geoRasterImage.getRasterImage (0,0,0,100,100);
...
You can see the code to get the result set uses the ID unique raster to get initial, then later in the code the subpicture is recovered by using the desired coordinates and the level of the pyramid.
But my question is this: get the set of results in this way requires the rasterid to be known as advance, who denies the whole reason/ability to select a secondary image based on coordinates/bounding box.
How can I do a SELECT statement using a box enclosing and level of the pyramid?
I hope this makes sense
Thank you
HDN °
-
Droid Razr: Select the Dock Type always appears now
Question started a few days before, around 2012 9-10 March. Got this Razr again this past January and this 'Select Dock Type' in the unlock (when the camera selection) screen or appears when opening other applications (for example a geo-cache app, sms text etc.). It doesn't matter if you tell him to remember the setting.
Another symptom, status bar indicates "HDMI plugged" while in fact, I don't ever connected to an hdmi cable.
When you try to use the camera, there is no display so you can see what you're shooting. It is the front or rear or video modes. Interestingly, when I select the camera from the unlock screen, it will display, but the popup "Select the Type of dock" then appears. Close it in fact shoplifters go away leaving me to guess what I'm going to snap and then looking at the thumbnail in the upper left corner to see what's broken.
Order to verizon store and agent says that it is a known problem. I could replace my new phone with a refurb or wait a few weeks for an update that will hopefully fix this, as he has been known to affect a small number on phones built before December.
Is there another way to get rid of this annoying popup? Tried to connect to hdmi dock to the verizon but no-go - store.
The system version: 6.12.173.XT912.verizon.en.us
Android version: 2.3.6
Build: 6.5.1 - 167_DHD_14_M2-5
Build date: Wed Dec 28 16:48:13 this 2011
I had the same problem when I bought my Razr last November. The notification started appearing after a week. It was definitely a hardware problem. Initially, the technical support of Verizon decided to send me a replacement phone. A few days later, I got a Razr renovated with a great sketch on the side. I sent it back, thinking that I have would address rather the annoying pop up. However, I finally gave and asked another phone of replacement in January. Still, I got a refurbished phone, but at least it looked brand new. My story probably won't help you much, but you have more chance to talk to the Verizon rep.
-
Help: selection tool can not select related items
Hello
I have a small but annoying problem (PP9.0.1).
While using the selection tool, whenever I try to select a video clip with audio link (like any normal clip) it selects only the video clip part, just as if you were selecting a component in isolation (option click on mac).
Interestingly, option click selects now the two elements as usual!
I'm 100% sure that these clips are linked, and I reset my keyboard shortcuts by default, but for the life of me can not find a way back to normal!
I have not being updated recently if he should not have been a change of software... I accidentally changed some obscure setting?
Please first Guru of throw me some wisdom!
Bravo, Jordan
Third top icon to the left of the sequence "Selection-bound" toggle Panel
-
How to pass notification request in. where condition in a task list
Dear friends
I need the page extension in the notifications page.
iI developed the query, for the moment, I hard coded requisition_header_id. This work of extension properly, now I want to spend requisition_header_id dynamically i.e. which users click on this id must go to my request of VO. Any person can give idea please.
This is my request
Select the site of ood.ORGANIZATION_NAME
hla. Location of DESCRIPTION
prha.segment1 Req_number
to_char (PRH. CREATION_DATE, 'Dd-mon-yy') Req_date
WP. FULL_NAME
-, hla. LOC_INFORMATION14 contact_person
hla. TELEPHONE_NUMBER_1 contact_number
-, hla. LOCATION_ID
-, hla. INVENTORY_ORGANIZATION_ID
SUM (prla. Unit_price * prla. Total_Estimated_value of QUANTITY)
-, hla. LIGNE_ADRESSE_1 | HLA. LIGNE_ADRESSE_2 | » '|| HLA. Location zip_code
of po_requisition_headers_all PRH
po_requisition_lines_all prla,
org_organization_definitions ood
hr_locations_all hla
per_all_people_f WP
where prla. REQUISITION_HEADER_ID =: 2... I tried this way... here I give condition... this: 2 is given by others SEEDED in the same page.
-PRH. REQUISITION_HEADER_ID = 34002... earlier I've hardcoded in this way
-segment1 = '38'
- and prha.ORG_ID = ood.ORGANIZATION_ID
and PRH. REQUISITION_HEADER_ID = prla. REQUISITION_HEADER_ID
and prla. DELIVER_TO_LOCATION_ID = hla. LOCATION_ID
and hla. INVENTORY_ORGANIZATION_ID = ood.ORGANIZATION_ID
and PRH. PREPARER_ID = WP. PERSON_ID
and sysdate between ppf.effective_start_date and ppf.effective_end_date
Ood.ORGANIZATION_NAME group
hla. LIGNE_ADRESSE_1 | HLA. LIGNE_ADRESSE_2 | » '|| HLA. ZIP_CODE
prha.segment1
PRH. CREATION_DATE
hla. LOC_INFORMATION14
hla. TELEPHONE_NUMBER_1
hla. LOCATION_ID
hla. INVENTORY_ORGANIZATION_ID
-, SUM (prla. Unit_price * prla. QUANTITY)
hla. DESCRIPTION
WP. FULL_NAME
I want to know for any clarification, please help.
Thank you
Aravinda
Published by: Aravinda on April 16, 2013 03:01Now that you have downloaded the workflow, open it in the workflow designer and find the notification that is displayed on the screen, under the condition. Once you have identified the notification in the workflow, all you have to do is minor changes to the notification. There's a chance he could be created using Page OA region. If this isn't the case, then take assistance of a workflow developer to make changes to the HTML notification.
-
UTL_HTTP. Request for the https site
Hello
I am running the following using sqlplus login as sys as sysdba (also tried connect you as the end user)
Utl_http.request SELECT ('https://www.accestochina.com', 'null', 'file:C:\wallets', ' XXX - password has been entered here - XXX') FROM dual;
*
ERROR on line 1:
ORA-29273: HTTP request failed
ORA-06512: at "SYS." UTL_HTTP", line 1722
ORA-12545: Connect failed because target host or object does not exist
ORA-06512: at line 1
The platform I use is
CORE 11.2.0.1.0 Production
NLSRTL Version 11.2.0.1.0 - Production
Oracle Database 11 g Release 11.2.0.1.0 - 64 bit Production
PL/SQL Release 11.2.0.1.0 - Production
AMT for 64-bit Windows: Version 11.2.0.1.0 - Production
After spending some time looking at the problem without success ideas / solution very welocome
Thanks for looking, PeteI posted the user (pipeline table) WebBrowser() above function.
The only things missing from this code example, the TStrings definition that defines the type of data collection that returns the function of pipeline:
create or replace type TStrings as table of varchar2(4000); /
-
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; -
Select the records from the first n distinct values of column
I need to write a query in plsql to select records for the first 3 values distinct from a single column (example below, ID) and all lines for the next 3 distinct values of column and so on until the end of the number of distinct values in a column.
for example:
Age of name ID
1 abc 10
1 def 20
2 IA 10
2 20 JKL
2 mno 60
3 10 pqr
4 the RST 10
4 10 TÜV
5 vwx 10
6 10 XYZ
hij 6 10
7 lmn 10
.
.
.
so now... (up to a few County)
Result must be
1 the application should result->
Age of name ID
1 abc 10
1 def 20
2 IA 10
2 20 JKL
2 mno 60
3 10 pqr
Query 2 should lead to->
4 the RST 10
4 10 TÜV
5 vwx 10
6 10 XYZ
hij 6 10
Query 3 should lead to->
7 lmn 10
.
.
9... ..
so now...
How to write a query for this inside a loop.Hello
Thus, a panel will consist of the lowest id value, the 2nd lowest and the 3rd lower, reggardless of how many lines is involved. The next group will include the 4th lowest id, the 5th lowest and the 6th lowest. To do that, you must assign the numbers 1, 2, 3, 4, 5, 6,... for the rows in order by id, with all lines with the same id, getting the same number and without jumping all the numbers.
This sounds like a job for the analytical DENSE_RANK function:WITH got_grp_id AS ( SELECT id, name, age , CEIL ( DENSE_RANK () OVER (ORDER BY id) / 3 ) AS grp_id FROM table_x ) SELECT id, name, age FROM got_grp_id WHERE id = 1 -- or whatever number you want ;
If you would care to post CREATE TABLE and INSERT statements for your sample data, then I could test it.
See the FAQ forum {message identifier: = 9360002} -
Get the select count (*) including zero '0 '.
Hi gurus,
I have the problem here, I have this request:
SELECT COUNT (t.column1) AS mycount.
To_char(t.CREATION_DATE,'MONTH') AS themonth
Table 1 t
WHERE the t.creation_date BETWEEN TO_DATE('01/01/2011') AND TO_DATE('09/07/2011') AND t.column1 > 0
GROUP OF TO_CHAR (t.creation_date, 'MONTH')
ORDER BY TO_DATE (TO_CHAR (t.creation_date, 'MONTH'), 'MONTH')
then I get this query result
MYCOUNT. THEMONTH
-------------- ----------------
JANUARY | 3
MARCH | 6
APRIL | 5
CAN | 9
JULY | 2
and I need like this
MYCOUNT. THEMONTH
-------------- ----------------
JANUARY | 3
FEBRUARY | 0
MARCH | 6
APRIL | 5
CAN | 9
JUNE | 0
JULY | 2
what I am doing wrong? or what I can add to the code? Please, I hope you can help with this one.
Best regards
MentorMentor wrote:
Hey and when I don't have a date range and did well id how can I get the result?
SELECT NVL(COUNT(column1),0) mycount, TO_CHAR(TRUNC(creation_date,'MM'),'MONTH') themonth FROM ( SELECT column1, creation_date FROM table1 WHERE column_id IN (2,3,12,67,49,182) AND column1 > 0 UNION ALL SELECT NULL column1, ADD_MONTHS(min_creation_date,LEVEL - 1) creation_date FROM ( SELECT TRUNC(MIN(creation_date),'MM') min_creation_date, TRUNC(MAX(creation_date),'MM') max_creation_date FROM table1 WHERE column_id IN (2,3,12,67,49,182) AND column1 > 0 ) CONNECT BY ADD_MONTHS(min_creation_date,LEVEL - 1) <= LAST_DAY(max_creation_date) ) GROUP BY TRUNC(creation_date,'MM') ORDER BY TRUNC(creation_date,'MM') /
>
and another question, how can I get the two counts of the same column where the condition its diferent?
SELECT NVL(COUNT(CASE column2 WHEN 'JOHN' THEN 1 END),0) count_a, NVL(COUNT(CASE column2 WHEN 'MICHAEL' THEN 1 END),0) count_b, TO_CHAR(TRUNC(creation_date,'MM'),'MONTH') themonth FROM ( SELECT column2, creation_date FROM table1 WHERE column2 IN ('JOHN','MICHAEL') UNION ALL SELECT NULL column2, ADD_MONTHS(min_creation_date,LEVEL - 1) creation_date FROM ( SELECT TRUNC(MIN(creation_date),'MM') min_creation_date, TRUNC(MAX(creation_date),'MM') max_creation_date FROM table1 WHERE column2 IN ('JOHN','MICHAEL') ) CONNECT BY ADD_MONTHS(min_creation_date,LEVEL - 1) <= LAST_DAY(max_creation_date) ) GROUP BY TRUNC(creation_date,'MM') ORDER BY TRUNC(creation_date,'MM') /
SY.
-
Value of the item as column name to select
Hello
I have a problem with the selection of the columns in the query using elements. For example: I have a request:
Select column_a table; or select table column_b;
and I want to do something like this:
n ' any item where I choose the column name
-query: select column_from_item from the tale of
Is this possible?
My version of the apex: 4.0.2.00.07
My version of db oracle: oracle 11gHello
Create a report... type... as a function returning the SQL statement...
and then you source should be something like
declare my_sql_statement varchar2(1000); begin my_sql_statement := 'select ' || :p1_x || ' from table'; return my_sql_statement; end;
Kind regards
Shijesh -
Question about SELECT DBMS_METADATA. GET_DDL
Hello
In reading the other posts, I found this interesting statement:
I thought it would be useful. When I tried as user SCOTT, the result I got is 'incomplete', as shown below:SELECT DBMS_METADATA.GET_DDL('TABLE','TABLE_NAME') FROM DUAL;
looks like the function smothered in half way through.SQL> select dbms_metadata.get_ddl('TABLE', 'EMP') from dual; DBMS_METADATA.GET_DDL('TABLE','EMP') -------------------------------------------------------------------------------- CREATE TABLE "SCOTT"."EMP" ( "EMPNO" NUMBER(4,0), "ENAME" VARCHAR2(10), SQL> describe emp; Name Null? Type ----------------------------------------- -------- ---------------------------- EMPNO NOT NULL NUMBER(4) ENAME VARCHAR2(10) JOB VARCHAR2(9) MGR NUMBER(4) HIREDATE DATE SAL NUMBER(7,2) COMM NUMBER(7,2) DEPTNO NUMBER(2) SQL> select dbms_metadata.get_ddl('TABLE', 'DEPT') from dual; DBMS_METADATA.GET_DDL('TABLE','DEPT') -------------------------------------------------------------------------------- CREATE TABLE "SCOTT"."DEPT" ( "DEPTNO" NUMBER(2,0), "DNAME" VARCHAR2(14 SQL>
Question: No idea why GET_DDL did not return all DDL for tables above?
I thought that maybe it was a question of the privileges of the user, so I tried to sys as sysdba, then he tried to find EMP in SYS (which is obviously not there). How the ADMINISTRATOR bring the DDL for a table without having to sign in as a user that owns the schema?
Thank you for your help,
John.You need to set the LONG and LONGCHUNKSIZE parameters to sql * higher level for a complete result.
-
My query on VS2010 designer change request
Hello
I use VS2010 with ODT 11.2.0.1.1 and I have a strange behavior with the 'requeteur '...
When I enter this request:
SELECT ARTICLE_PCH. AP_CODE... ARTICLE_SAP.AS_USAGE_UNIQUE
OF ARTICLE_SAP, ARTICLE_PCH
WHERE ARTICLE_SAP.AS_NUMERO = ARTICLE_PCH.AS_NUMERO (+) AND (ARTICLE_SAP.AS_CIRCUIT = 'SAD') AND (ARTICLE_SAP.AS_SUPRESSION IS NULL) AND
(ARTICLE_SAP.AS_FAMILLE <>'ZEP') AND (ARTICLE_PCH. AP_CODE IS NULL)
ORDER BY ARTICLE_SAP.AS_LIB_40
The query designer adds a (+) before the 'IS NULL.
Like this
SELECT ARTICLE_PCH. AP_CODE... ARTICLE_SAP.AS_USAGE_UNIQUE
OF ARTICLE_SAP, ARTICLE_PCH
WHERE ARTICLE_SAP.AS_NUMERO = ARTICLE_PCH.AS_NUMERO (+) AND (ARTICLE_SAP.AS_CIRCUIT = 'SAD') AND (ARTICLE_SAP.AS_SUPRESSION IS NULL) AND
(ARTICLE_SAP.AS_FAMILLE <>'ZEP') AND (ARTICLE_PCH. AP_CODE (+) IS NULL)
ORDER BY ARTICLE_SAP.AS_LIB_40
And then the query returns an incorrect result. When I test with sqlplus demand without the sign (+) return the right result. But I can not enter the request because the query generator automatically change my request...
Someone there had the same problem with this version beta of ODT?
I have no problem with the previous version of ODT.
Thanks in advance
The fHi Jeff,
Please this post on the ODT forum:
Oracle Developer Tools for Visual StudioKind regards
-Native
Maybe you are looking for
-
Satellite Pro P100 - support for 4 GB of RAM in Win7 64 and Intel Virtualization
Hello to the members of the forum, I have the Satellite Pro P100 (PSPAHE - 002001GR) and I installed the WIN 7 Enterprise 64 free trial. I have Modules of memory 2 x 2 GB Corsair, a T7400 processor and Bios version 4.7. Everything works fine without
-
Sansa fuze will not turn on or charge
My sansa fuze was working fine until one day when he suddenly cut off and since it lights up for about 10 seconds and cut again once
-
problem with msn messenger error Ox8ac70013
So that's the problem I have my Messenger will not recognize my webcam on live Messenger window but I can't yet we spyke it have no problem with my cam, the update always have problem maybe someday I'll make one that will not change my computer
-
CD-ROM drive or cd/dvd E: drive / missing
Well, I did most of the solutions, but no luck. can't see my E: drive or cd on my Windows vista drive? Please help pleaee :(
-
Secondary ASA with IP transparent mode on the router
Hello I have Router - ASA (Transparent) - switch and wonder if it is possible to configure the secondary IP on the interface of the router that is connected to the ASA So there is plenty of room in terms of range of LAN IP addresses. Or do I have to