Using group by and searching with in a group
I am looking for a way to group results in a table, then compare the results with in each group.
Here is some example data.
cid--eid--gid--seqid
101--m123--g123--111
100--m123--g123--111
102--m123--g123--111
200--m124--g124--211
201--m124--g124--211
202--m124--g124--210
300--m125--g223--311
301--m125--g223--311
302--m125--g223--311
303--m125--g223--311
400--m125--g223--411
401--m125--g223--411
402--m125--g223--411
403--m125--g223--411
403--m125--g223--412
If I group by eid, gid and order by cid I would get the following
Group 1:
101--m123--g123--111
100--m123--g123--111
102--m123--g123--111
Group 2:
200--m124--g124--211
201--m124--g124--211
202--m124-g124---210
Group 3:
300--m125--g223--311
301--m125--g223--311
302--m125--g223--311
303--m125--g223--311
Group 4:
400--m125--g223--411
401--m125--g223--411
402--m125--g223--411
403--m125--g223--411
403--m125--g223--412
Now I need to find out the cids in each group for which the seqid is NOT matching with majority in the group. For example, I need the output as
cid--eid--gid--seqid
202--m124--g124--210
403--m125--g223--412
What are the ways to do the above? One way I think is to use a temp table, but given the size of the table that may not be a possibility
Please let me know how to do this
with sample_table as (
select 101 cid,'m123' eid,'g123' gid,111 seqid from dual union all
select 100,'m123','g123',111 from dual union all
select 102,'m123','g123',111 from dual union all
select 200,'m124','g124',211 from dual union all
select 201,'m124','g124',211 from dual union all
select 202,'m124','g124',210 from dual union all
select 300,'m125','g223',311 from dual union all
select 301,'m125','g223',311 from dual union all
select 302,'m125','g223',311 from dual union all
select 303,'m125','g223',311 from dual union all
select 400,'m125','g223',411 from dual union all
select 401,'m125','g223',411 from dual union all
select 402,'m125','g223',411 from dual union all
select 403,'m125','g223',412 from dual
select cid,
eid,
gid,
seqid
from (
select cid,
eid,
gid,
seqid,
seqid_cnt,
max(seqid_cnt) over(partition by grp) max_cnt
from (
select cid,
eid,
gid,
seqid,
grp,
count(*) over(partition by grp,seqid) seqid_cnt
from (
select s.*,
cid - row_number() over(partition by eid,gid order by cid) grp
from sample_table s
where seqid_cnt != max_cnt
CID EID GID SEQID
202 m124 g124 210
403 m125 g223 412
SQL> SY.
Similar Messages
-
Mail wants to use the restricted Service "Search With Google."
This is the response/error I see when I try to do a Google search from an email message - "Mail wants to use the restricted Service “Search With Google.”"
Interesting - I just created a new user account I named "Test", and tried "Search With Google" in Notes and it worked fine in this new account. Without any additional change, I went back into my normal user account, and tried to use "Search with Google" on the highlighted word, and it pulled up the Google search fine as well. No reason I can think of that these actions would have resolved the problem - e.g., either the creation of the "Test" account, or switching between this "Test" account and my normal account. Possibly creating new account caused a cleanup of the Safari preferences to point to version 6.0.(essentially reset the default)
Would be curious if droow007 solution works for others. Definitely quicker than the route I went :~) -
Can I use Adobe Premiere and Photoshop (with cloud license) on more than one computer? WHen on the oroad I would like to use it n my laptop, while I installed on the desktop.
Hi Kasiah,
As per the EULA accepted while you launch Adobe applications you can download & install on 2 systems but can use on one at the same time.
Source:http://www.adobe.com/in/products/creativecloud/faq.html
Let me know if you have any questions on this.
Cheers~!
-Mandhir -
Have been using an iPhone and sysncing with Outlook through iTunes for several years. Downloaded the recent update to iTunes and now sycing of contacts & calendars is not occuring. I did see that i had to recheck to sync contacts and calendars again and have done this, but still no syncing is occuring. Any suggestions?
Hi Brian!
I have an article here for you that addresses your issue and can help you troubleshoot this further:
iPhone, iPad, iPod touch: Troubleshooting contact and calendar syncing via USB on Windows
http://support.apple.com/kb/HT1692
Thanks for coming to the Apple Support Communities!
Regards,
Braden -
How to upload a file into server using j2ee jsp and servlet with bean?
How to upload a file into server using j2ee jsp and servlet with bean? Please give me the reference or url about how to do that. If related to struts is more suitable.
Anyone help me please!u don't need j2ee and struts to do file uploading. An example is as such
in JSP. u use the <input> file tag like
<input type="file"....>You need a bean to capture the file contents like
class FileUploadObj {
private FormFile srcFile;
private byte[] fileContent;
// all the getter and setter methods
}Then in the servlet, you process the file for uploading
* The following loads the uploaded binary data into a byte Array.
FileUploadObj form = new FileUploadObj();
byte[] byteArr = null;
if (form.signFile != null) {
int filesize = form.srcFile.getFileSize();
byteArr = new byte[filesize];
ByteArrayInputStream bytein = new ByteArrayInputStream (form.srcFile.getFileData());
bytein.read(byteArr);
bytein.close();
form.setFileContent(byteArr);
// Write file content using Writer class into the destination file in the server.
... -
How to use the eventing and databag with a WAS 6.20 ?
How to use the eventing and databag with a WAS 6.20 ?
Is what there is a good guide for these services?
Thank'sIn the raise event you can pass the value
like below.
<SCRIPT>
function raiseEvt(value1){
if(window.document.domain == window.location.hostname){
if ( document.domain.indexOf(".") > 0 ) document.domain = document.domain.substr(document.domain.indexOf(".")+1);
EPCMPROXY.raiseEvent( "urn:com.sap:BWEvents","BWiViewevent", value1, null );
// alert('tree domain'+document.domain);
</SCRIPT>
and in the
subscribe event you can get the values like below.
<script language="javascript">
if(window.document.domain == window.location.hostname){
document.domain = document.domain.substring(document.domain.indexOf('.')+1);
EPCMPROXY.subscribeEvent("urn:com.sap:BWEvents","BWiViewevent", window, "myreceiveEvent");
function myreceiveEvent( eventObj ) {
document.forms[0].gp_hidden.value = eventObj.dataObject;
</script>
Also look at the following link for a complete documentation.
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/Enterprise%20Portal%20Client.pdf
Regards
Raja -
Been using mail forever and only with my gmail account. All of a sudden, all my inbox mails are missing except for anything after yest night. I log into gmail on safari and everything is there but not on my mac or iphone in mail
Same problem in 8.1.3
Apple help! -
How shall I use my IMac and MacBookPro, with synchronized files
Hi, how shall I use my IMac and MacBookPro, with synchronized files? I used to work at home and office with those to machines and finally always have different version of my documents. Is there any dispositive that I should use, where all my files are moving with me? os there is something to synchronized the computers using WiFi or bluetooth?
The following has instructions: OS X Mavericks: Share your Internet connection
-
Why it is keep asking for Username and Password but i didn't use any username and password with my database. Please help me i m very frustrated right now please help anybody. I m new in this.,
Hi,
Please check below threads:
Crystal Report Layout asking for Login Info
SAP B1 ask for credentials to print or to preview Crystal Reports report -
Cannot use double tap and move with one finger to select text in Mountain Lion
I've been using OS X in my Macbook Pro since Snow Leopard, and if I choose "tap with one finger to click", I can use double tap and move with one finger to select text if the cursor is between text.
It works in Snow Leopard,and Lion However, in Mountain Lion, this doesn't work!! I have to click in the bottom right corner of my trackpad in order to select the text.
Can anyone get this fixed ?
Thanks.Caolei,
I don't know if you'll ever see this, but thank you! I hope this helps somebody else down the line, too.
re. "I can use double tap and move with one finger to select text if the cursor is between text."
I've been trying to figure out how to select text with tapping and without clicking.
This did the trick.
It's quite finicky to not select a space in between words.
Zooming in does seem to help (two finger double tapping in a body of text may trigger a SmartZoom and zoom the current frame of text to fill the screen, if anybody doesn't know this.)
((There's a smartMagnifyWithEvent Cocoa NSEvent that's not universally supported across all applications for noob OS X developers like me.))
I haven't been able to find the part about double tapping between text to begin a selection (which seems to work best when double tapping directly next to a letter) anywhere in the help system on or online. I probably just missed it, though.
Clicking with the built-in trackpad on my MacBook Pro w/ Retina or Magic Mouse just takes too much pressure for an old-time touch typist like me.
As an aside, I've been trying BetterTouchTool and MagicPrefs to enable one finger tap on the Magic Mouse. BetterTouchTool seems to trigger text selection unwantedly and randomly, though.
The whole mystique of Mac / Apple being intuitive and user-friendly seems to be one of the greatest marketing coups / unbelievable con jobs of the last century.
I'm actually somewhat qualified to express an opinion as a software engineer with a degree in Computer Science and programming and user interface design experience in Windows, UNIX, web, Android and other systems, and now OS X and iOS. I could go on and on and on but I won't other to say that I still find Macs buggy and hard to use. I'm now finding that my new iPhone 5 is just as big of a pain (i.e. big thumbs missing landscape keyboard in Contacts.) Of course, I like flexibility and options and custom workflows and more than one way to do things and simply being able to do things at all, so I'm also actually somewhat biased. Sorry for the rant...
Cheers,
Hal -
Can i use my mac and pc with a cloud app?
can i use my mac and pc with a cloud app
Yes.
http://www.adobe.com/products/creativecloud/faq.html
Yes, as a member of Creative Cloud, you get many benefits that you do not get when you purchase a traditional shrinkwrapped product:
An ever-expanding membership that provides access to Adobe's latest products, services, features, and workflows as soon as they are available. You no longer have to wait 12, 18, or 24 months for the latest innovations.
Access to both the Mac OS and Windows® versions of the desktop applications and the ability to install them on your primary computer and one backup computer. So, if you have a Mac at home and a PC at work, you can install your applications on both as long as they are not running at the same time. See the product license agreements page for more information. -
Using JCheckBox, JButton and JTextArea with JDBC
Hello shlumph and SoulTech2012.
thanks for the reply. I�m wondering do any of you have links to web pages that include tutorials and source code on using JCheckBox, JButton and JTextArea with JDBC. would any of you who have experience with using JCheckBox, JButton, JTextArea and JDBC together be able to give me a few tips on how to select certain data from a table using JCheckBox, JButton and display the data in a JTextArea? examples of such data could be CD/DVD/Game data - i want users of my video library system to be able to view CD/DVD/Game information by name, age category, type and year. Users should be able to click on a check box (e.g. view by name, age category, type or year) and press a button. What would happen then is that data from the Product table would appear in the text area (which could be placed beneath the check box + button inside a frame and/or panel).
Thank you very much for your help.Quit triple posting and cross posting your questions all over the forum. You already have a posting in this forum on this topic and another posting in the Swing forum and another posting in the Programming forum.
-
I am using Iphone 3G and running with ios version 4.2.1 .I am looking for to run whatsup apps.Can you guide me which IOS version should i download wherein,it will support whatsup apps
with an iphone 3G the most up to date ios is 4.2.1 so you have a problem because whatsapp requires a higher version. If you saved an earlier version of whatsapp you could install that otherwise you cannot use the app. You will need to get a more up to date phone
-
SSince the update, I have no keyboard clicks on my iPad, no sound on many of the apps, And searching with the Duck is like going back to the dark ages. I hate Google but at least it works! I am getting soooo tired of releases that aren't fully de-bugged before they're released.
http://www.apple.com/feedback/
is the proper avenue to send comments to apple -
Using iMac and Maverick OS. I have Chrome as my default browser. I find that going to System Preferences/General under default browser, I note that Chrome is chosen as default, yet the browser "above the line" is Safari and Chrome, while checked off is "below the line". In other words, the top listed browser is Safari which is unchecked with a line underneath, even though all the other browsers are listed below the line and only Chrome has a check mark.
When I am on a website and I select words to search in Google, it always searches with Safari instead of Chrome. How do I change that?Thanks for your response. I think it was my error in that I did not define the problem properly. Indeed Chrome is my default browser. And Maverick does not have a "next line" to default to Google. I can do that in the Chrome settings.
My problem is that when I am in another application.....and it is apparently an application native to Maverick....for example Contacts or Calendar, Reminders, Notes, etc., if I highlight a word or phrase, and right click and choose "search with Google", it defaults to Safari. How do I change that? -
Using PSE 6 and 7 with DPI's larger than 96
Many people have discovered that if they increase the DPI (dots per inch) of their high-resolution Windows monitor to make text more readable, the PSE 6 and 7 Organizer will no longer show the menu bars.
I just discovered a workaround: In the Organizer, set the option Edit > Preferences > General > Use System Font. This works on my Vista system for both 6 and 7, but I havent tested it on XP or other computers.
The results arent always the prettiest, e.g. the font in the Editors menu bar stays small, but the font in the dropdown menus gets large, and much of the PSE text stays small. But this workaround at least lets you keep the DPI large so that you can read the text in all your other applications.<i>Part II of II</i><br /><br /><b>4. Reconnect folders residing on a network drive.</b> If youve moved folders that originally resided on one network drive to another network drive, the Organizer will treat them as offline rather than missing, and it will show a red circle with a vertical line in the corner of the thumbnails. An offline file is one that might show up later on, such as when you reconnect your laptop to the network containing your file server or you insert a DVD containing your archived photos.<br /><br />Since the moved files are offline, the PSE 6 Reconnect All Missing command wont do anything but tell you there are no files to reconnect. You can force PSE to reconnect many offline files at once:<br /><br />a. Select all the photos that are offline.<br /><br />b. Do File > Write Keyword Tag and Properties Info.<br /><br />c. In the Find Offline Volumes window that pops up, select Reconnect and click OK.<br /><br />Unfortunately, method 3 doesnt appear to work with offline files on a network drive. If you have a large number of individual folders and dont have the patience to reconnect each folder in turn, you can either use method 1 (restore the files to their original location) or recreate the original UNC name for the network drive (e.g. \\mycomputer\share). (You could also try editing the catalog file using the tool sqlite3 search these forums for how to do it. But thats sketchy at best.) <br /><br />------------------------------------<br />If you reconnect a file and get the message <old file> was not connected to <new file> or The file already exists in the catalog, then youve stumbled over a PSE bug for which there are workarounds. See this thread:<br /><br /><a href="/webx?14@@.59b66777/5">John Rolfe Ellis, "Cannot Reconnect; File already exists" #6, 17 Sep 2008 2:49 pm</a><br /><br />------------------------------------<br />I havent tested any this in PSE 5, so I cant say how much works the same way.
Maybe you are looking for
-
How can i block an iPad from linking iMessage with my iPhone?
Okay, so my friend has recently discovered that his parents' iPad has his number linked to the iMessage feature. So basically his parents can just go on the iPad whenever they want and read all of his messages. Is there any way that he can block the
-
My new iPhone6 has horizontal light gray lines lines! Best visible in the white or bright areas, such as the SMS or the Healt App Button...
-
Iphoto preview not showing corrections with Yosemite
I created a new iPhoto file for 2015 and when I make adjustments to some of the photos with an outside editor (PhotoShop), the preview image does not show the corrections after making the changes. This has always worked before. If I click to open the
-
I am using iTunes 7.4.2.4 on my Windows XP machine 2Gb ram AMD athlon 64 X2 Dual 3800+ But still iTunes runs like a pregnant snail in a glue jar. My library of files is quite big. But still it is very slow compared to other "media managers"/players.
-
I received a message on my Officejet Pro 8600 all-in-one that my fax log was full and that I should empty it. How do you do that?