Combine queries to get the result set with max Y
HelloI use forms 6i and db 10.2.0.1.0
With the query below
Select ufam_usrgrp,ufam_filegrp,ufam_read,ufam_write,ufam_overwrite,ufam_delete from usr_file_access_master
Where ufam_ecode = '0004108';
the result set isUFAM_USRGRP UFAM_FILEGRP UFA UFA UFA UFA
--------------- --------------- --- --- --- ---
MGMNT CV Y Y Y Y
EMPLOYEE GENERAL Y N N N
EMPLOYEE PERSONAL Y N N N
Another querySelect uul_usrgrp, ufl_file_grp,ufl_read,ufl_write,ufl_overwrite,ufl_delete from usr_usrgrp_lnk,USRGRP_FILEGRP_LINK
Where usr_usrgrp_lnk.uul_usrgrp = USRGRP_FILEGRP_LINK.UFL_USR_GRP
and usr_usrgrp_lnk.uul_ecode = '0004108'
gives the resultUUL_USRGRP UFL_FILE_GRP UFL UFL UFL UFL
--------------- --------------- --- --- --- ---
MGMNT GENERAL Y Y Y Y
EMPLOYEE GENERAL Y Y N N
MGMNT CV Y N N N
I need to combine these two queries to get a separate result set with maximum YLike here "MGMNT CV" is repeated in both the result set, but the first has more, then it should come from the combined result set. reverse-case also the same (such as "EMPLOYEE GENERAL")
So I want to combine the queries so that I get the result as set below
UserGroup FileGroup Rd Wrt Owrt Del
--------------- --------------- --- --- --- ---
MGMNT GENERAL Y Y Y Y
EMPLOYEE GENERAL Y Y N N
MGMNT CV Y Y Y Y
EMPLOYEE PERSONAL Y N N N
Please help me to combine these queriesPublished by: Divya on August 14, 2011 21:24
Changed the result set and the last exit
NOT TESTED!
select y.uul_usrgrp,
y.ufl_file_grp,
greatest(ufl_read,nvl(ufam_read,' ')) ufl_read,
greatest(ufl_write,nvl(ufam_write,' ')) ufl_write,
greatest(ufl_overwrite,nvl(ufam_overwrite,' ')) ufl_overwrite,
greatest(ufl_delete,nvl(ufam_delete,' ')) ufl_delete
from (select ufam_usrgrp,ufam_filegrp,ufam_read,ufam_write,ufam_overwrite,ufam_delete
from usr_file_access_master
Where ufam_ecode = '0004108'
) x,
(select uul_usrgrp, ufl_file_grp,ufl_read,ufl_write,ufl_overwrite,ufl_delete
from usr_usrgrp_lnk,USRGRP_FILEGRP_LINK
Where usr_usrgrp_lnk.uul_usrgrp = USRGRP_FILEGRP_LINK.UFL_USR_GRP
and usr_usrgrp_lnk.uul_ecode = '0004108'
) y
where y.uul_usrgrp = x.ufam_usrgrp(+)
and y.ufl_file_grp = x.ufam_filegrp(+)
Concerning
Etbin
Edited by: Etbin on 14.8.2011 13:08
deleted by group
Tags: Database
Similar Questions
-
How can I get a result set of a table as a comma-separated value? I saw there are dbms_utility.table_to_comma but don't know how to use it.
For example,
Select column_name from user_tab_columns where table_name = "TAB1".
I want to get the result as col1, col2, col3
I'm using Oracle 11 g.
Your help is very appreciated. :)Hello
in oracle 11, you can use:
select LISTAGG(column_name,',') WITHIN GROUP (ORDER BY COLUMN_ID) CSV from user_tab_columns where table_name = 'PBCATCOL' ; CSV --------------------------------------------------------------------------------------------------------------------------------------------- PBC_TNAM,PBC_TID,PBC_OWNR,PBC_CNAM,PBC_CID,PBC_LABL,PBC_LPOS,PBC_HDR,PBC_HPOS,PBC_JTFY,PBC_MASK,PBC_CASE,PBC_HGHT,PBC_WDTH,PBC_PTRN,PBC_BMAP,PBC_INIT,PBC_CMNT,PBC_EDIT,PBC_TAG
Kind regards
Peter
-
Failed to get the result set for Get_Search_Results CRMI
Hi all
Face with the Null pointer exception while showing the result of the RIDC "GET_SEARCH_RESULTS" Server
So I can't get the real result of the Content server
Here is my code:
ClientManager IdcClientManager = new IdcClientManager(); Customer IdcClient = clientManager.createClient ("idc://kcsezapp01:4444"); ") UserContext IdcContext = new IdcContext ("weblogic", "welcome1"); HdaBinderSerializer serializer = new HdaBinderSerializer ("UTF-8", client.getDataFactory ()); If (!) () userContext is nothing)) { DataBinder binding = client.createBinder (); binder.putLocal ("IdcService", "GET_SEARCH_RESULTS"); binder.putLocal ("QueryText", "dDocAuthor < start > 'pra'"); client.sendRequest (binder, userContext); serializer.serializeBinder (System.out, binding); System.out.println ("userContext is:" + userContext); System.out.println ("dataBinder is:" + linking); Resp ServiceResponse = client.sendRequest (userContext, binder); System.out.println ("the answer is:" + RESP); DataBinder serverBinder = resp.getResponseAsBinder (); serializer.serializeBinder (System.out, serverBinder); ResultSet DataResultSet = serverBinder.getResultSet("GET_SEARCH_RESULTS"); for (DataObject dataObject: resultSet.getRows ()) { System.out.println ("" Content ID: "+ dataObject.get ("dDocName") +"\t"+" review: ' "+ dataObject.get ("dRevLabel") +"\t"+" title of the content item: "+ dataObject.get ("dDocTitle")"); System.out.println ("author is:" + dataObject.get ("dDocAuthor")); } } } Prashant_AP wrote:
ResultSet DataResultSet = serverBinder.getResultSet("GET_SEARCH_RESULTS"); Shouldn't this read "resultSet DataResultSet = serverBinder.getResultSet("SearchResults");"?
-
Hi alexk,.
Greetings!
Seems to be a problem with the graphics card driver.
Please follow the steps below. :
Go to Edition-> Preferences-> Performance (Windows) | Photoshop-> preferences-> performance (MAC)
Uncheck-> use graphics processor
Click Ok
Restart Photoshop.
Repeat the steps you did.
Concerning
Jitendra
-
Unable to get the database searched with MAX and GROUP BY function
Hello
All the
I have a table as below:
COLUMN TYPE
User_id VARCHAR2 (10 byte)
ID_processus VARCHAR2 (30 bytes)
END_TIME DATE (STAMP)
TO_LOC VARCHAR2 (12 bytes)
TO_LOC_TYPE VARCHAR2 (15 bytes)
FROM_LOC VARCHAR2 (12 bytes)
ITEM_ID VARCHAR2 (25 bytes)
CASE NUMBER (12.4)
LMS_UDA1 VARCHAR2 (250 bytes)
AREA VARCHAR2 (2 bytes)
I only want to get one record with all the columns, have only one clause MAX (END_TIME)
But the other column value of the difference.
When I use MAX (END_TIME) and GROUP OF USER_ID, ID_processus, CASE...
the sql did not a single record,
It gives the number of records
Please help me on this
Concerning
Saven>
I only want to get one record with all the columns, have only one clause MAX (END_TIME)
But the other column value of the difference.
>
Maybe it's not possible because it depends on your data.If the combination of all columns except END_TIME is not unique then there will be multiple records; a record for each unique combination (GROUP BY) of all other columns.
The only way to ensure that a record is
SELECT MAX(END_TIME) FROM myTable
-
Help with the query to select only one record from the result set in double
Hello
Please help with the query. Version of Oracle database we use is 10g R2.
I have a vision that is duplicated IDS, but they are used across the different functions. See below examples of data. Please help me with a query to select only one record (based on ID regardless of the area) from the bottom of the result set of duplicate records. For what is the point of view is there unique records, given the combination of the fields ID, Org, DF, dry, Sub-Sec
ID Org DF Sec Sub-Sec (163) CQ CPDM CPDM HD (163) PC ENG ENG ENG (163) CQ ASIC ASIC IS 8888 TS TAC TAC TAC (163) TS HE HE SW 6789 CQ INFO INFO FOS 6789 PC SECSYS SECSYS INFO1 6789 TS SECSYS SECSYS INFO2 9009 PC BMS BMS BMS1 My result set must eliminate the duplicate identifiers regardless of whoever we choose of the result set. (I mean without distinction Org, DF, s, Sub-s). My expected result set should be.
ID DSB DF SEC Sub-Sec (163) CQ CPDM CPDM HD 8888 TS TAC TAC TAC 6789 CQ INFO INFO FOS 9009 PC BMS BMS BMS1 Thank you
Orton
Hello
This sounds like a job for ROW_NUMBER:
WITH got_r_num AS
(
SELECT id, DSB, df, s, sub_sec org
ROW_NUMBER () OVER (PARTITION BY ID.
ORDER BY org
) AS r_num
OF view_x
)
SELECT id, DSB, df, sub_sec s,
OF got_r_num
WHERE r_num = 1
;
He is a Top - N query example, where you choose the elements of N (N = 1 in this case) from the top of an ordered list.
I hope that answers your question.
If not, post a small example of data (CREATE TABLE and INSERT, only relevant columns instructions) to your sample data and the results desired from these data. (I know that you said that you were a view selection. Just for this thread, pretending it is a picture and post simple CREATE TABLE and INSERT statements to simulate your point of view).
Point where the above query is to produce erroneous results, and explain, using specific examples, how you get the right results from data provided in these places. (I didn't quite understand the explanation above. I don't know why you want toID ORG DF DRY SUB_SEC
-- --- -- --- -------
1234 CQ DPRK DPRK HD
and is not
1234 IS CQ ASIC, ASIC
or
TS 1234 IT IT SW
or
1234 CQ ASIC ASIC HD
)
If you change the query at all, post your modified version.
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
-
Get spaces empy in the result set
Hello
We are migration CF 5 to 9. App works great in CF5. but when we run the same code in CF9, for all sets of results, we get the empty sapce for each field.
Ex:
CF5: field1: order_id, value = "OL123456".
CF9: field1: order_id, value = "OL123456".
We get the empty sapce for each field in the result sets. I know that we can use the topping, but we have so many pages in the application and we cannot do that. can someone help how to solve this problem. I am using the database Ingres and connection with another datasource in CF Admin.
Srinivas
I used the query of queries and the problem is solved.
-
I use JDev 11.1.1.6 and when I type in a value in an af:inputListOfValues element and press enter or the tab key, it will replace the value I entered with the first element in the set of results LOV. If enter a value, simply click on the component af:inputListOfValues it works correctly. If I use the popup and find a value it works properly as well. I have a programmatic view object that contains a single transitional attribute (this is the view object that is used to create the list of the components of the value of) and then I have another object from view based on entities which defines one of its attributes in a list of the attribute value. I tried to use a base object view of entity to create the LOV to and everything works as expected, so I don't know if this is a bug when using programmatic view objects or if I need more code in the VOImpl. In addition, it seems after that first of the value being replaced by the first value in the result set that it will work correctly as well. Here are some excerpts of important code.
Also, it seems that this does not work only if the text entered in the component af:inputListOfValues would have only a single game, returned in the result set. For example, given the result defined in code: Brad, Adam, Aaron, Fred, Charles, Charlie, Jimmy
If we get into Cha, the component works as expected
If we register A, the component works as expected
If we get Jimmy, the component does not work as expected, and returns the first value of results IE. Brad
If we get Fred, the component does not work as expected, and returns the first value of results IE. Brad
I also checked that I get the same behavior in JDev 11.1.1.7
UsersVOImpl (programmatic view with 1 transitional attribute object)
import java.sql.ResultSet; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import oracle.adf.share.logging.ADFLogger; import oracle.jbo.JboException; import oracle.jbo.server.ViewObjectImpl; import oracle.jbo.server.ViewRowImpl; import oracle.jbo.server.ViewRowSetImpl; // --------------------------------------------------------------------- // --- File generated by Oracle ADF Business Components Design Time. // --- Wed Sep 18 15:59:44 CDT 2013 // --- Custom code may be added to this class. // --- Warning: Do not modify method signatures of generated methods. // --------------------------------------------------------------------- public class UsersVOImpl extends ViewObjectImpl { private static ADFLogger LOGGER = ADFLogger.createADFLogger(UsersVOImpl.class); private long hitCount = 0; /** * This is the default constructor (do not remove). */ public UsersVOImpl () { } /** * executeQueryForCollection - overridden for custom java data source support. */ protected void executeQueryForCollection (Object qc, Object[] params, int noUserParams) { List<String> usersList = new ArrayList<String>(); usersList.add("Brad"); usersList.add("Adam"); usersList.add("Aaron"); usersList.add("Fred"); usersList.add("Charles"); usersList.add("Charlie"); usersList.add("Jimmy"); Iterator usersIterator = usersList.iterator(); setUserDataForCollection(qc, usersIterator); hitCount = usersList.size(); super.executeQueryForCollection(qc, params, noUserParams); } // end executeQueryForCollection /** * hasNextForCollection - overridden for custom java data source support. */ protected boolean hasNextForCollection (Object qc) { Iterator usersListIterator = (Iterator)getUserDataForCollection(qc); if (usersListIterator.hasNext()) { return true; } else { setFetchCompleteForCollection(qc, true); return false; } // end if } // end hasNextForCollection /** * createRowFromResultSet - overridden for custom java data source support. */ protected ViewRowImpl createRowFromResultSet (Object qc, ResultSet resultSet) { Iterator usersListIterator = (Iterator)getUserDataForCollection(qc); String user = (String)usersListIterator.next(); ViewRowImpl viewRowImpl = createNewRowForCollection(qc); try { populateAttributeForRow(viewRowImpl, 0, user.toString()); } catch (Exception e) { LOGGER.severe("Error Initializing Data", e); throw new JboException(e); } // end try/catch return viewRowImpl; } // end createRowFromResultSet /** * getQueryHitCount - overridden for custom java data source support. */ public long getQueryHitCount (ViewRowSetImpl viewRowSet) { return hitCount; } // end getQueryHitCount @Override protected void create () { getViewDef().setQuery(null); getViewDef().setSelectClause(null); setQuery(null); } // end create @Override protected void releaseUserDataForCollection (Object qc, Object rs) { Iterator usersListIterator = (Iterator)getUserDataForCollection(qc); usersListIterator = null; super.releaseUserDataForCollection(qc, rs); } // end releaseUserDataForCollection } // end class
<af:inputListOfValues id="userName" popupTitle="Search and Select: #{bindings.UserName.hints.label}" value="#{bindings.UserName.inputValue}" label="#{bindings.UserName.hints.label}" model="#{bindings.UserName.listOfValuesModel}" required="#{bindings.UserName.hints.mandatory}" columns="#{bindings.UserName.hints.displayWidth}" shortDesc="#{bindings.UserName.hints.tooltip}" autoSubmit="true" searchDesc="#{bindings.UserName.hints.tooltip}" simple="true"> <f:validator binding="#{bindings.UserName.validator}"/> </af:inputListOfValues>
I found a solution to this problem. It seems that, when using a view object programmatic that has a transient as its primary key attribute, you need to override the methods in the ViewObjectImpl so that he knows how to locate the line related to the primary key when the view object records are not in the cache. That's why it would work properly sometimes, but not always. Here are the additional methods that you must override. The logic you use in the retrieveByKey would be on a view view object database object and would be different if you had a primary key consisting of multiple attributes.
@Override protected Row[] retrieveByKey (ViewRowSetImpl viewRowSetImpl, Key key, int i) { return retrieveByKey(viewRowSetImpl, null, key, i, false); } @Override protected Row[] retrieveByKey (ViewRowSetImpl viewRowSetImpl, String string, Key key, int i, boolean b) { RowSetIterator usersRowSetIterator = this.createRowSet(null); Row[] userRows = usersRowSetIterator.getFilteredRows("UserId", key.getAttribute(this.getAttributeIndexOf("UserId"))); usersRowSetIterator.closeRowSetIterator(); return userRows; } @Override protected Row[] retrieveByKey (ViewRowSetImpl viewRowSetImpl, Key key, int i, boolean b) { return retrieveByKey(viewRowSetImpl, null, key, i, b); }
-
How to exclude the each row of the result set XML declaration?
Hello
I have a table with an XMLTYPE column and would like to SELECT a set of rows. How can I exclude the each row of the result set XML declaration? My query currently looks like this, I am running through Spring JDBC:
SELECT XMLSerialize FROM t1 WHERE XMLEXISTS('$e/Event' PASSING XMLTEXT AS "e") ORDER BY t1.time DESC myschema.event (HAPPY t1.xmltext)
After selecting, in my application I convert each line in a string and concatenate all the rows in a large chain to analyze in a DOM model. I get a parser exception (org.xml.sax.SAXParseException: the target of the processing instruction corresponding to "[xX] [mM] [he's]" is not allowed) because there are several XML statements in my large chain. Of course, I could manually check the string on each line if it starts with the XML declaration, but it would be nicer if I could load the DB does not add it in the first place. Is there a way?
Thank you!
-DanielaHello
Some options that I can think of:
SELECT XMLSerialize(CONTENT XMLtransform(t1.xmltext, xmltype('
or quite simply,.
SELECT XMLSerialize(CONTENT extract(t1.xmltext,'/') ) FROM myschema.event t1 WHERE XMLEXISTS('$e/Event' PASSING XMLTEXT AS "e") ORDER BY t1.time DESC ;
-
Remove duplicates from the result set
Here's a challenge question that I was playing with a my free time during the work.
I assume you have the basic HR example somewhere around (I hope is not in production).
Let's say you want to get employees from the employees table whose name is similar to another employee last name.
The easiest way is to join the two tables with a join condition that checks for the name and employee id. Here's what I came with.
*************
Select e1.last_name, e1.first_name b, e2.last_name c, e2.first_name d
employees employees join e1 e2
on (e1.last_name = e2.employee_id <>e2.last_name and e1.employee_id)
order by one;
************
The above query returns 10 rows. The first and the second are essentially the same. It is similarly, 3 & 4, 5 & 6, 7 and 8 and 9 and 10. The question is: is there a way that allows me to get rid of using only sql duplicate rows from the result set of this query. I sat on it for 15 minutes and I couldn't know. I'll try to watch my completed work once again.Example:
SQL> column a format a10 SQL> column b format a10 SQL> column c format a10 SQL> column d format a10 SQL> SQL> SQL> select e1.last_name a , e1.first_name b, e2.last_name c, e2.first_name d 2 from employees e1 join employees e2 3 on ( e1.last_name = e2.last_name and e1.employee_id != e2.employee_id) 4 where e1.employee_id < e2.employee_id 5 order by a; A B C D ---------- ---------- ---------- ---------- Cambrault Gerald Cambrault Nanette Grant Kimberely Grant Douglas King Steven King Janette Smith Lindsey Smith William Taylor Jonathon Taylor Winston SQL>
-
How to get the results of the UK instead of the default USA?
I live in the United Kingdom and would like to be able to search for UK results. for example, Amazon UK results when I search a product, etc.
with the option of a search in the world so I don't get the results I wantTo add plugins to search for sites such as Amazon.co.UK and Google.co.uk to Firefox, open this page in Firefox and then search or click the sites that interest you: http://mycroft.mozdev.org/
When you click on one of the listed search plugins, Firefox will ask you if you want to install it.
After that, you can open the Firefox Add-ons Manager and click on disable one of the search engine integrated you want to use.
-
Hello
I'm looking for the most obvious and simple, LabVIEW:
1. start the motor Teststand: FACT
2. get a list of SEQ files to run: FACT
3 - loop through the list to run each file follows:<- found="" some="" examples="" but="" i="" have="" some="" trouble="" with="" the="" uimessage="">->
4. get the result of the execution of the SEQ:<->->
5 retrieve the XML + name of the generated report file path:<- obviously="" not="">->
http://digital.NI.com/public.nsf/allkb/3D3B2358DF9B786B8625789500549A3B
Here's my current implementation:
David Koch
-
Get the result of the sequence by programming
Hi all
in my custom operator interface to save the event EndExecution callback to accomplish several final operation.
What I can't do is to retrieve the result of the sequence ('Success' or 'Failure', exactly the one that is displayed in the default report under the voice "Result USE") using methods or properties API.
I've tried Execution.ResultStatus property and the SequenceContext.SequenceFailed property, but none of them works.
How can I get the result of the sequence?
Thank you
Process templates are already generating a Message from the user interface "TestingComplete" you can register an event reminder on. It also transmits the result as part of the parameter string State. The attached excerpt from LV show what the VI recall may contain to handle the event. If you need to deal with other UI event codes you can wire the event directly number in the structure box for the 34 decimal 'TestingComplete' event code.
P.S., the event is the same that Norbert has pointed out, event UIMessageEvent...
-
How to get the result of the test of CVI DLLs in teststand!
I write a driver dll to test a source, I want to get the tension of world SERVERS (the instrument of the RS) and I used to call DLLs that written by CVI, teststand
My question is what is the best way I can get the result of the test and show the user to teststand. the code below is fair? When I used to call this dll document, teststand
"" I just get the result by setting in TS.this is a good meathod, and what should you do in teststand, I put the "outputVoltageV" point to an object?
/*===========================================================================*/
/ * Function: read voltage/current output * /.
/ * End: this function returns the output and actual output voltage * /.
/ * current instrument. */
/*===========================================================================*/
ViStatus _VI_FUNC rsngsm_datReadOutput (ViSession instrSession,
ViPReal64 outputVoltageV, ViPReal64 outputCurrentA, ViPBoolean statusPeakCurrent)
{
ViStatus rsngsm_status = VI_SUCCESS;
Bruno buf [BUFFER_SIZE];
ViInt32 retCnt;
FMT (buf, "%s<>
If ((rsngsm_status = viWrite (instrSession, buf, NumFmtdBytes (), & retCnt))<>
Return rsngsm_status;
If ((rsngsm_status = viRead (instrSession, buf, 50, & retCnt))<>
Return rsngsm_status;
If (Scan (buf, "%s > %f [p2];")) %f [p2]; %i [b2] ", outputVoltageV, outputCurrentA, statusPeakCurrent). = 3)
Return rsngsm_status;
Return rsngsm_status;
}sean_tan,
Yes, you just pass a value of digital TestStand (e.g.; locals.number).
If you use the adapter of the ICB, it might make more sense that you can use the Flexible DLL adapter for this type of function, that you do not use the standard settings of tTestData and tTestError. While TestStand will correctly recognize the function prototype, you want to make sure you that include the type library of your function Panel (you will need to create one if you have not already done so) in settings target of LabWindows / CVI-> type library.
I hope this helps.
-Jack
-
Get the result of the procedure
Hi all
I have a procedure using storeb from the collection in an object of type as:
create or replace type calc_type as object ( field1 number, field2 number, field3 varchar2); create or replace type calc_table as table of calc_type; procedure make_calc_sched(v_id in number, v_user_id in varchar2) is table_calc calc_table; begin select s.id, s.price, s.desc bulk collect into table_calc from tableA s inner join tableB d on d.id = s.id --..... end;
How can I get the result of the procedure?
procedure make_calc_sched(v_id in number, v_user_id in varchar2, v_table in out ????) is
I plan to put up-to-date and inserts using the FORALL sentence.
Can I use slider? Maybe is a better way to do it.
With the help of Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0
Thank you
I think I got it:
procedure make_calc_sched(v_id in number, v_user_id in varchar2, v_table out calc_table) is begin select calc_type(s.id, s.price, s.desc) bulk collect into v_table from tableA s inner join tableB d on d.id = s.id --..... end;
I'll look to materialize views more later. Someone at - it examples?
Best,
Maybe you are looking for
-
My wife can no longer access his email
Suddenly, she lost the ability to receive emails through thunderbird even if she could send. The provider, century link, changed his password in an attempt to trouble. I managed to get to his mailing list, but now she has lost beyond emails and still
-
Hello IM forget securty question answer
-
my xp media center 2005. whenever I try to use my media center ' video decoder is currentley in use by another application close all applications and restart the Media Center» I have no other programs running and have no idea what as happened to crea
-
OfficeJet Pro 8620: Use eprint to print in b &; W
Hello I configured my printer Eprint Center so my colleague can print on my printer remotely. However what it prints out in color at my end. He said there is no option to its end to choose whether they come through color or B & W. I need to print in
-
Files deleted by accident and now need them
Recently, I accidentally deleted my trash with some files into it that I need... so I reinstalled my Windows Vista disk thought that would help... is there a way to get these back now or they are gone forever?