SQL select all sessionid for which ONLY exist actionid 1 OR 2 OR 5
Create Table:
create table x ( sessionid number, actionid number, sessionactionid number, a3 varchar2(10));
Inserts;
insert into x values (1000, 1, 100, 'asdfsadf' );
insert into x values (1000, 2, 101, 'asdfsadf' );
insert into x values (1000, 3, 102, 'asdfsadf' );
insert into x values (1000, 4, 103, 'asdfsadf' );
insert into x values (1001, 1, 104, 'asdfsadf' );
insert into x values (1001, 3, 105, 'asdfsadf' );
insert into x values (1001, 6, 106, 'asdfsadf' );
insert into x values (1001, 1, 107, 'asdfsadf' );
insert into x values (1001, 1, 108, 'asdfsadf' );
insert into x values (1002, 1, 109, 'asdfsadf' );
insert into x values (1002, 2, 110, 'asdfsadf' );
insert into x values (1002, 5, 111, 'asdfsadf' );
insert into x values (1003, 1, 112, 'asdfsadf' );
insert into x values (1003, 2, 113, 'asdfsadf' );
insert into x values (1003, 5, 114, 'asdfsadf' );
insert into x values (1003, 4, 115, 'asdfsadf' );
insert into x values (1004, 2, 116, 'asdfsadf' );
insert into x values (1004, 5, 117, 'asdfsadf' );
Query to resolve;
select all sessionid for which ONLY exist one actionid for each of 1 and 2 and 5
also important that all 3 actionid must exist for that sessionid otherwise that record is not valid for us.
with the table above the result should be;
SESSIONID
=======
1002
PS: Sorry my db is not accessible at the moment and therefore could not test the above CREATE and INSERTS statements.
Edited by: Andre on Jan 19, 2012 5:17 PM
Hi, Andre,
Andre wrote:
Create Table:
create table x ( sessionid number, actionid number, sessionactionid number, a3 varchar2(10));
Inserts;
insert into x values (1000, 1, 100, 'asdfsadf' );
insert into x values (1000, 2, 101, 'asdfsadf' );
insert into x values (1000, 3, 102, 'asdfsadf' );
insert into x values (1000, 4, 103, 'asdfsadf' );
insert into x values (1001, 1, 104, 'asdfsadf' );
insert into x values (1001, 3, 105, 'asdfsadf' );
insert into x values (1001, 6, 106, 'asdfsadf' );
insert into x values (1001, 1, 107, 'asdfsadf' );
insert into x values (1001, 1, 108, 'asdfsadf' );
insert into x values (1002, 1, 109, 'asdfsadf' );
insert into x values (1002, 2, 110, 'asdfsadf' );
insert into x values (1002, 5, 111, 'asdfsadf' );
insert into x values (1003, 1, 112, 'asdfsadf' );
insert into x values (1003, 2, 113, 'asdfsadf' );
insert into x values (1003, 5, 114, 'asdfsadf' );
insert into x values (1003, 4, 115, 'asdfsadf' );
insert into x values (1004, 2, 116, 'asdfsadf' );
insert into x values (1004, 5, 117, 'asdfsadf' );
Query to resolve;
select all sessionid for which ONLY exist one actionid for each of 1 and 2 and 5
also important that all 3 actionid must exist for that sessionid otherwise that record is not valid for us.
with the table above the result should be;
SESSIONID
=======
1002Why isn't 1003 included? It has only 1 each of 1, 2, and 5, and it has all 3 of those actionids.
This does what you requested:
SELECT sessionid
FROM x
WHERE actionid IN (1, 2, 5)
GROUP BY sessionid
HAVING COUNT (actionid) = 3
AND COUNT (DISTINCT actionid) = 3
;This does not assume anything is uniue.
Did you mean that the sessionids displayed must not have any actionids other than 1, 2 and 5? If so:
SELECT sessionid
FROM x
GROUP BY sessionid
HAVING COUNT (actionid) = 3
AND COUNT (DISTINCT actionid) = 3
AND COUNT ( CASE
WHEN actionid IN (1, 2, 5)
THEN 1
END
) = 3
;Either way, GROUP BY ... HAVING is a natural way to approach the problem. You're interested in groups of rows, not single rows (that's what GROUP BY is all about), and the group as a whole must meet certain conditions (that's what HAVING is all about).
Edited by: Frank Kulash on Jan 19, 2012 11:22 PM
Added 2nd guess
Similar Messages
-
ITunes always selects all Applications for installing on iPod
When I connect my iPod to my Mac to sync, iTunes tends to select all applications for upload to the iPod, even when I've previously selected just a few apps. Is this the intended behaviour? Its not desirable from my perspective!
Message was edited by: agw1976I have a similar issue. Apps that I have previously deleted reappear. How many Apps do you have in Itunes?
I have over 3000 and suspect this may be creating some type of problem?
I can delete the apps on my I-Phone 3GS with current app code 3.1.3 or via Itunes 9.1(79) on my computer which has the latest operating system 10.6.3 and Itunes that were released 3/30/10 and still have the problem.
I have deleted the sync cache with no luck. Previously I removed all the applications from Itunes and re-synced the apps from the phone this solved the problem for a while but ended up occurring again once I got closer to 3000 apps. Either it is app qty. related or some type of corruption that is occurring?
Apple Please fix this; while your at it add folders! I'm getting real tired of this.
I-Mac Mac OS X (10.6.3) -
How to show a database to a user for which only he has the read access?
Hi All,
We have a SQL Server and it has say 10 datatabases, we have created a login and also a user which has read access to just one of the 10 databases.
I used
use [master]
DENY VIEW ANY DATABASE to msam_test
To hide all the databases from explorer for that user if he logsin with msam_test.Now, i want this user to see a database named suresh3_test for which he has a read access.
Can someone please help me if this is achievable?
Thankshi,
It is not possible to look at one database if the user only have read access in your scenario.
either you revoke the DENY VIEW ANY DATABASE permission, which will list all the databases for the user
or You need to make the user database owner by doing so:
First delete the user from the database
Right click on the database and select properties and change the owner to msam_test as shown in the pic below
But the user will have owner rights on the database.
Hope this clarifies your doubt. The same was explained in your earlier post as well
Thanks
Bhanu -
Discoverer Report: Select all values for a Page Item
Hi Guys
I have created a Disco Report which has one Page Item.
It populates all columns based on values I select for Page Item that is perfectly fine.
How do I Display column values for all possible values of Page Item?
Is thera ny way I can have Option to select All possible values for Page Item?
Cheers
VijayHi Vijay
Just to confirm what Rod has said, this capability to manage ALL in Page Items was introduced as part of 10.1.2 and has been maintained into 10.1.2.3 and 11g. It will not be back ported to previous releases.
Best wishes
Michael -
Any way to select all emails for delete with one touch?
The only time I really need to see emails on my iPhone is when I am away from home. When I am home, and receive a huge number of emails on my iMac, I also receive the same ones on my iPhone.
I review them on the iMac, and then have to delete them from the iPhone. I go into the account on the iPhone and touch edit, but then have to scroll and check off each one so I can delete them.
Is there any way to "select all" instead of checking off each one?The iPhone's mail client does not synchronize with the incoming mail server for a POP account. The iPhone's mail client is no different in this regard from accessing a POP account with an email client on your computer. You have an option to remove messages from the server when downloaded for a POP account with the iPhone's mail client as is available with an email client used on your computer to access a POP account.
All server stored mailboxes with an IMAP account are kept synchronized with the server automatically with each email client used to access the account including with the iPhone's mail client. A POP account is not synchronized with the server - not with the iPhone's mail client or with an email client on your computer. -
Call function which only exists in the target system
Hello,
I have to call the function module BAPI_QUOTATION_CREATEFROMDATA2 from a BI system. Of course, the function module does not exist in the BI system. My problem is now how to create the necessary parameter types for the function call?
I found out that the function module RFC_GET_STRUCTURE_DEFINITION returns me the complete definition for the necessary types but how can I transform this information into a field-symbol or something similar?
Or is there perhaps a different solution which is easier to implement?
regards
ThomasHi
I think so, but I believe you don't need all structure, so you could define only structure you need in your program, it's probably faster than to manage dynamically many structure.
Anyway you can create your structure at runtime by field-symbols, there are many post about this argoment.
This is the last:
Re: Populating Dynamic Internal Table from Internal Table
Max
Message was edited by: max bianchi -
HT4236 I selected 'all photos' for syncing and nothing happens
When i try to sync my iphone 3GS, 32 GB, half full. it only syncs 905 of 2555 photos. All are selected and i get an error message that such and such a number of photos will not sync see itunes.
Where do i look for the message on the sync, and how can i sync ALL my photos?Hi there PaulFR,
You may find the troubleshooting steps in the article below helpful.
iTunes: Unable to sync photos
http://support.apple.com/kb/TS3697
-Griff W. -
Fetch all Subsite for Read-only user
HI,
I have a site collection in which the users have only "Read" access.
I would like to fetch all the sites(incuding root site, subsites), which the user has access. How to achieve this in Javascript client object model?
I have tried using get_web().get_webs(), but since the user has only "Read" access, I am getting access denied error when trying to load the site.
How to fetch all the sites(incuding root site, subsites), in the sitecollection using Javascript client object model?
ThanksHi,
Refer to following post:
http://social.msdn.microsoft.com/Forums/en-US/fb318464-916c-4d0a-ae59-8511b58b6309/run-code-with-elevated-privileges-in-client-object-model
It summarizes as below:
The SharePoint 2010 client object model does not support SPSecurity.RunWithElevatedPrivileges.
Since you're code runs on the client, the identity can not be reverted to the application pool account. Running code as system account via the client object model would open a security hole and then everybody could write and execute code as an administrator.
Another possible way is to develop a custom web service on the server which run the code in RunWithElevatedPrivilege() method and then call the web service from the client object model.
you may refer to the this blog post giving a simple example of creating WCF service for SharePoint 2010:
How
to Create WCF Web Service on SharePoint 2010
You would also like to have a brief look at the screencast for Building and deploying a WCF service to SharePoint 2010:
http://www.codefornuts.com/2010/04/building-and-deploying-wcf-service-to.html
Hope it helps!
Avni Bhatt -
Deleting lines from Sales order for which PO exists
HI all,
We have a setup where MTO/PTO configurable sales order lines are created in SAP from a different application. In this scenario user did create a couple of PTO lines manually in SAP sales order which generated Purchase requisition and a purchase order was created. Since order entry has to be done from the front end application, the line number has been already consumed by the manually created line in SAP. So we need to somehow delete these two PTO lines from the sales order. We tried setting deletion flags to the purchase order lines but still not bale to delete the lines from the sales order.
Could some one come up with some idea?
Thanks
GopiGopi
I think you should work from SD Sales Order first. Did you try rejecting the sales order items without doing anything to the PO.
Also check what requirement routines you have in IMG T codes OVB5 (Maintain Requirements For Purchase And Assembly Orders) and OVB8 (Maintain Requirements For Transfer Of Requirements).
Hope this helps. -
'Select ALL' not working for WD ABAP ALV
Hi all,
I have a web dynpro application with a tab strip with 9 tabs. Each tab has an ALV embedded in it. Each ALV is mapped to the same node in component controller. When the application is executed 'Select ALL' works for first ALV on the first tab. However if i select a different tab i get the select all option on the left hand corner but it does nothing when chosen.
I also tried creating custom button on ALV toolbar for this functinality. Here i am looping over all elements of the node (bound to ALV) and using method set_selected( abap_true ) ( method of if_wd_context_element ). This also works for first ALV on the
first tab. However again get the same issue if i choose any other tab.
Node cardinality : 0.... n
Node selection : 0.....n
ALV selection mode set to MULTI using method SET_SELECTION_MODE( CL_WD_TABLE=>E_SELECTION_MODE-MULTI ) of cofig class cl_salv_wd_config_table.
All your inputs/suggestions to resolve this issue will be greatly appreciated.
Thanks,
Vivek PriyadarshiHi Aditya,
Thanks for your reply. I am using 9 comp. usage of SALV_WD_TABLE to display 9 alv and all are mapped to the same comp. controller context node. The context node has the master structure with all fields, based on the chosen tab i am populating this context node with records and setting config model for ALV accordingly.
I tried your trick, clicked on select all on first ALV (all records chosen, works correctly here) then chose the second tab on tabstrip, however records in the new (second) ALV were not selected. When i clicked 'Select all' it did nothing, no records were chosen ( original issue ).
Did you invalidate the common node when you navigate between tabs?In my case i am populating this node with new data every time i navigate between tabs.
One new thing i noticed. On the first tab i am able to select individual rows by clicking on the row selection buttons on the left edge of every row. However when i go the second tab clicking on row selection button it does not get selected, only way to select a row in this case is by doing CLTR+click, something doesn't feel right about this application.
I am going to create a new context node to check if sharing a common context node is causin this issue.
-Vivek -
Ansi SQL for "select ... for update nowait"
Hi, All,
I have a sql
select ... for update nowait
My boss wants it to be ANSI compliant.
I am not familiar with ANSI SQL.
What should be the syntax in Ansi?
Thanks a lot!I resent having the lowest salary :-)Sorry John, it's probably due to the exchange rate of sterling against the canuck dollar right now.
SQL> select empno, ename, sal, job, mgr from emp;
EMPNO ENAME SAL JOB MGR
7369 SPENCER 800 CLERK 7902
7499 VERREYNNE 1600 SALESMAN 7698
7521 VAN WIJK 1250 SALESMAN 7698
7566 MAINGUY 2975 MANAGER 7839
7654 KISHORE 1250 SALESMAN 7698
7698 BARRY 2850 MANAGER 7839
7782 BOEHMER 2695 MANAGER 7839
7788 PADFIELD 3000 ANALYST 7566
7839 SCHNEIDER 5500 PRESIDENT
7844 GASPAROTTO 1500 SALESMAN 7698
7876 CAVE 1100 CLERK 7788
7900 CLARKE 950 CLERK 7698
7902 JAFFAR 3000 ANALYST 7566
7934 ROBERTSON 1430 CLERK 7782
14 rows selected.
SQL> Cheers, APC -
Selecting all rows currently visible in the table
Hi ,
we need to add the "Select all" functionality for the a table used in one of the screens. The examples I have found for this would select all the elements of the node bound to the table. However, we need to select only those elements which are presently visible on the screen, which would change if the user presses the previous or next button.
Please guide me on how it can be possibly done .
Edited by: Dhruwat Bhagat on Dec 28, 2007 11:45 AMHi Dhruawat,
Modify the example functionality SelectAll like this:
Create visRow context attribute of type int. Bind this to firstVisibleRow property of table.
Check visibleRowCount value (default is 5)
//for loop on the table node
for(int i=visRow ;i<(visRow + visibleRowCount value );i++)
select the element;
// end of for loop
regards,
Siva -
Select all siblings if any child is modified and recalculate qty.
Hi All,
I am in a following situation.
with sales as
select 1025 CUST_ID, '23239D' ITEM_ID, 1 qty_ord, 1 qty_Ship, 1 qty_Cancel, TO_DATE('12/08/2013 09:59:25', 'MM/DD/YYYY HH24:MI:SS') load_ts, TO_DATE('12/08/2013 09:59:25', 'MM/DD/YYYY HH24:MI:SS') updt_ts from dual union all
select 1025, '3434h', 1, 1, 1, TO_DATE('12/08/2013 09:59:25', 'MM/DD/YYYY HH24:MI:SS'), sysdate + 1 from dual UNION ALL
select 1025, 'sku324', 1, 1, 1, TO_DATE('12/08/2013 09:59:25', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/08/2013 09:59:25', 'MM/DD/YYYY HH24:MI:SS') from dual union all
select 1025, 'TRL.33', 1, 1, 1, TO_DATE('12/08/2013 09:59:25', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/08/2013 09:59:25', 'MM/DD/YYYY HH24:MI:SS') from dual union all
select 1025, 'RTL56', 1, 1, 1, TO_DATE('12/08/2013 09:59:25', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/08/2013 09:59:25', 'MM/DD/YYYY HH24:MI:SS') from dual union all
select 1025, '34fgh', 1, 1, 1, TO_DATE('12/08/2013 09:59:25', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/08/2013 09:59:25', 'MM/DD/YYYY HH24:MI:SS') from dual union all
select 1027 CUST_ID, '23239D' ITEM_ID, 1 qty_ord, 1 qty_Ship, 1 qty_Cancel, TO_DATE('12/08/2013 09:59:25', 'MM/DD/YYYY HH24:MI:SS') load_ts, TO_DATE('12/08/2013 09:59:25', 'MM/DD/YYYY HH24:MI:SS') updt_ts from dual union all
select 1027, '3434h', 1, 1, 1, TO_DATE('12/08/2013 09:59:25', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/08/2013 09:59:25', 'MM/DD/YYYY HH24:MI:SS') from dual UNION ALL
select 1027, 'TRL.33', 1, 1, 1, TO_DATE('12/08/2013 09:59:25', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/08/2013 09:59:25', 'MM/DD/YYYY HH24:MI:SS') from dual union all
select 1027, 'RTL56', 1, 1, 1, TO_DATE('12/08/2013 09:59:25', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/08/2013 09:59:25', 'MM/DD/YYYY HH24:MI:SS') from dual
select * from sales
where updt_ts > sysdate
Now in the above table if any record is modified then the UPDT_TS will be updated with sysdate.
And every morning an ETL job runs to identify the changes in the above table, While for changes only one record is updated with the Updt_ts. But the requirement is to write a select Query which would select all siblings for any change in the Updt_ts for a given CUSTID. Please let anyone need more information.
The select query returns only 1 record with ITEM_ID = 3434h, but requirement is it shoud return all siblings associate with cust_id 1025Hi,
Thanks for posting the sample data; that's very helpful.
Don't forget to post the exact results you want from that data, and explain how you get those results from that data.
See the forum FAQ: https://forums.oracle.com/message/9362002
Define any special terms you use in the explanation, such as "sibling". How can you tell if 2 given rows are siblings or not?
If being a sibling means having the same cust_id, then maybe:
SELECT *
FROM SALES
WHERE cust_id IN (
SELECT cust_id
FROM sales
WHERE updt_ts > SYSDATE
Of course, if updt_ts is always set to SYSDATE when a row is modified, then updt_ts > SYSDATE will never be TRUE in a query run later (unless you're resetting the clock on the database server). -
Help, question about "select ... for update nowait"
There is a proc code. In the beginning of the code, I used a SQL "select ... for update nowait" in order to prevent from another proc executing at the same time. When the case happens, "-54, ORA-00054: resource busy and acquire with NOWAIT specified" will be printed in the screen.
But there is a question: I need to print sth to indicate "another proc is running". I used "if (sqlca.sqlcode == -54)" as precondition, such as:
if (sqlca.sqlcode == -54) {
printf("There is another proc running.\n");
However, this line will not be printed. I doubt that the code quits directly when using "select ... for update nowait" so as not to set value (-54) to sqlca.sqlcode.
So, could you suggest whether there is another way that I can use to print "There is another proc running" when another proc is running?
Thx a lot for your kindly reply.Yes, that link. Scroll down a bit and you will see:
The calling application gets a PL/SQL exception, which it can process using the error-reporting functions SQLCODE and SQLERRM in an OTHERS handler. Also, it can use the pragma EXCEPTION_INIT to map specific error numbers returned by raise_application_error to exceptions of its own, as the following Pro*C example shows:
EXEC SQL EXECUTE
/* Execute embedded PL/SQL block using host
variables v_emp_id and v_amount, which were
assigned values in the host environment. */
DECLARE
null_salary EXCEPTION;
/* Map error number returned by raise_application_error
to user-defined exception. */
PRAGMA EXCEPTION_INIT(null_salary, -20101);
BEGIN
raise_salary(:v_emp_id, :v_amount);
EXCEPTION
WHEN null_salary THEN
INSERT INTO emp_audit VALUES (:v_emp_id, ...);
END;
END-EXEC;
This technique allows the calling application to handle error conditions in specific exception handlers. -
BatchUpdateException :Results returned for UPDATE ONLY.
I got an error message at the statement stmt.executeBatch();
java.sql.BatchUpdateException: Results returned for UPDATE ONLY.
There are 3 SQL commands in the batch and it throws the above exception while executing the first command.
(The first command is a SELECT command with COUNT returned to a variable
eg. SELECT @ABC := COUNT(*) ....
The second and the third commands use the returned variable to make updates)
I printed out the updated information using BatchUpdateException.getUpdateCounts and I got
-3 1 1 (-3 means Statement.EXECUTE_FAILED)
However, I checked the database (mysql) and I discovered those two update commands were executed correctly ???!!!
An interesting thing is: if I use stmt.execute or stmt.executeQuery instead of executeBatch, it works fine and doesn't throw any exception.
I wonder if anybody experience similar situation before or have idea on this problem. Thanx :)Can somebody help me, please?
Maybe you are looking for
-
Inspection lot is not getting updated in quant
Hi Experts, Need your help.. I have posted two material doc with same material following is the consequences : 1.we have immediate TO creation process , so now we have 2 TO's and 2 inspection lots. 2.When i am doing UD for first inspection lot PCN do
-
Dear Apple, I am glad that I can finally send you an email. This email is in regards to your ITUNES. I think what you have done is amazing. However, being a customer I think you need to support your internet customer users more. Downloading APPLE
-
Passing JavaScript value to Jsp
Hi, Any idea how to pass a value from javascript to jsp page when the page gets load on browser. I use below code but an event is require to pass the value. Is there any code that pass automatically the value from javascript to jsp. <html> <head> <ti
-
Is OCZ Vertex Turbo 60GB 2.5" SSD compatible with my Mac Pro, or do I need
Is OCZ Vertex Turbo 60GB 2.5" SSD compatible with my Mac Pro, or do I need the Vertex Mac Edition? I have decided to purchase a SSD to use as a boot drive in the spare optical drive bay. There are so many brands available, and Intel X25-M 'G2' seems
-
Baisc Aqualogic Interaction SSO mechanism
I have a basic question on how the aqualogic interaction SSO works. I see an Authentication SOurce SSO, but i dont understand which repository it connects to. How it generates the Login Token. Can i use the features of authentication service outside