Problems with GROUP BY - not a GROUP BY expression

Hello,
I am fighting little bit with GROUP BY expression.
After some tests I am able to reduce the problem to following...
When can I use column numbers in GROUP BY expression?
Consider this situation:
CREATE TABLE EMP4 (
   NAME VARCHAR2(10)
COMMIT;
INSERT INTO EMP4 VALUES('Tamara');
INSERT INTO EMP4 VALUES('John');
INSERT INTO EMP4 VALUES('Joseph');
COMMIT;
SELECT NAME, COUNT(*)
FROM EMP4
GROUP BY 1;
00979. 00000 -  "not a GROUP BY expression"
-- This is working
SELECT NAME, COUNT(*)
FROM EMP4
GROUP BY NAME;Why is the GROUP BY 1 not workig?
I am using the GROUP BY 1 because in real query there is some PL/SQL function which somehow modifies the column NAME, so I can't use the column name
SELECT TEST_PACKAGE.AppendSomeCharacter(NAME), COUNT(*)
FROM EMP4
GROUP BY 1;Of course I can nest the query and move the COUNT and GROUP BY to outer query or maybe something else, but I was just curious why is the GROUP BY not working...
Also in real query, there are 3 columns in the GROUP BY expression, so I have there GROUP BY 1, 2, 3
Thanks for help

hai
try the following
CREATE TABLE TBL(ID NUMBER,VAL VARCHAR(20));
INSERT INTO TBL VALUES(1,'Z');
INSERT INTO TBL VALUES(2,'X');
INSERT INTO TBL VALUES(1,'Z');
INSERT INTO TBL VALUES(2,'X');
INSERT INTO TBL VALUES(3,'A');
INSERT INTO TBL VALUES(4,'H');
INSERT INTO TBL VALUES(5,'B');
INSERT INTO TBL VALUES(6,'C');
INSERT INTO TBL VALUES(7,'T');
INSERT INTO TBL VALUES(3,'A');
INSERT INTO TBL VALUES(4,'H');
INSERT INTO TBL VALUES(5,'B');
INSERT INTO TBL VALUES(6,'C');
INSERT INTO TBL VALUES(7,'T');
CREATE TYPE SAMPLETYPE AS OBJECT ( ID NUMBER, NAME
VARCHAR2(25) ) ;
CREATE TYPE SAMPETBLTYPE AS TABLE OF SAMPLETYPE;
CREATE OR REPLACE FUNCTION SAMPLEFUNC
p_colname varchar2
)return SAMPETBLTYPE pipelined as
ret_val SAMPLETYPE;
TYPE cursor_ref IS REF CURSOR;
fcur cursor_ref;
di TBL%ROWTYPE;
sqlstr varchar2(1000);
colname varchar(30):=p_colname;
begin
sqlstr:='SELECT * FROM TBL ORDER BY '|| colname ;
DBMS_OUTPUT.PUT_LINE(sqlstr);
open fcur FOR sqlstr;
loop
FETCH fcur INTO di;
EXIT WHEN fcur%NOTFOUND;
ret_val:=SAMPLETYPE(di.ID,di.VAL);
PIPE ROW(ret_val);
end loop;
close fcur;
return;
end;     
select * from table(SAMPLEFUNC('ID'));
select * from table(SAMPLEFUNC('VAL'));

Similar Messages

  • To group or not to group?

    Hi there,
    I'm an illustrator that has been using Photoshop for years but has just learnt to use illustrator.
    I'm doing a publishing job where I am suppling muliple spot illustrations on one spread ( I'm working by drawing my line work on one layer & colour on another) This is my first job using illustrator so I just want to check this out before I supply the artwork, Should I group each individual spot illustration so they can scale them or move them if they need to, it's just this freaks me out slightly as it makes the illustration one layer! & I'm used to suppling everything layered in photoshop, I know they can ungroup it so just want to check this is they way most people using Illustrator supplly artwork.
    Sorry in advance if this is an idiotic question!
    Any advice greatly appreciated : )
    Cheers

    To group or not to group is a judgment call based upon the artwork. In Illustrator most often the more grouping the better. The direct select tool with the option key held down turns into the group select tool. This can be a very powerful tool for making edits, if the file is grouped logically.
    I recommend keeping groups logical. Someone may need to rotate the arm of a character you illustrated, so if your arm group included a small spectral highlight in an eyeball, someone may be zoomed in on that arm, and miss that they rotated that part of the eyeball.
    When you are done it is always good to check if you have anything locked or hidden. Occasionally I get some artwork and when I do a show all, something appears that was hidden, and you are not sure if that was part of the art or not.
    In your example of all black linework on one layer, and the color on another, using separate layers is perfectly acceptable and would be preferred by myself if I had to do something like thicken up all the black lines, or  warm up all the colors. You cannot be perfect for everyone, but if you try to keep your groups logical, you will save time/errors for yourself in the end and most everyone else.

  • Problem with file descriptors not released by JMF

    Hi,
    I have a problem with file descriptors not released by JMF. My application opens a video file, creates a DataSource and a DataProcessor and the video frames generated are transmitted using the RTP protocol. Once video transmission ends up, if we stop and close the DataProcessor associated to the DataSource, the file descriptor identifying the video file is not released (checkable through /proc/pid/fd). If we repeat this processing once and again, the process reaches the maximum number of file descriptors allowed by the operating system.
    The same problem has been reproduced with JMF-2.1.1e-Linux in several environments:
    - Red Hat 7.3, Fedora Core 4
    - jdk1.5.0_04, j2re1.4.2, j2sdk1.4.2, Blackdown Java
    This is part of the source code:
    // video.avi with tracks audio(PCMU) and video(H263)
    String url="video.avi";
    if ((ml = new MediaLocator(url)) == null) {
    Logger.log(ambito,refTrazas+"Cannot build media locator from: " + url);
    try {
    // Create a DataSource given the media locator.
    Logger.log(ambito,refTrazas+"Creating JMF data source");
    try
    ds = Manager.createDataSource(ml);
    catch (Exception e) {
    Logger.log(ambito,refTrazas+"Cannot create DataSource from: " + ml);
    return 1;
    p = Manager.createProcessor(ds);
    } catch (Exception e) {
    Logger.log(ambito,refTrazas+"Failed to create a processor from the given url: " + e);
    return 1;
    } // end try-catch
    p.addControllerListener(this);
    Logger.log(ambito,refTrazas+"Configure Processor.");
    // Put the Processor into configured state.
    p.configure();
    if (!waitForState(p.Configured))
    Logger.log(ambito,refTrazas+"Failed to configure the processor.");
    p.close();
    p=null;
    return 1;
    Logger.log(ambito,refTrazas+"Configured Processor OK.");
    // So I can use it as a player.
    p.setContentDescriptor(new FileTypeDescriptor(FileTypeDescriptor.RAW_RTP));
    // videoTrack: track control for the video track
    DrawFrame draw= new DrawFrame(this);
    // Instantiate and set the frame access codec to the data flow path.
    try {
    Codec codec[] = {
    draw,
    new com.sun.media.codec.video.colorspace.JavaRGBToYUV(),
    new com.ibm.media.codec.video.h263.NativeEncoder()};
    videoTrack.setCodecChain(codec);
    } catch (UnsupportedPlugInException e) {
    Logger.log(ambito,refTrazas+"The processor does not support effects.");
    } // end try-catch CodecChain creation
    p.realize();
    if (!waitForState(p.Realized))
    Logger.log(ambito,refTrazas+"Failed to realize the processor.");
    return 1;
    Logger.log(ambito,refTrazas+"realized processor OK.");
    /* After realize processor: THESE LINES OF SOURCE CODE DOES NOT RELEASE ITS FILE DESCRIPTOR !!!!!
    p.stop();
    p.deallocate();
    p.close();
    return 0;
    // It continues up to the end of the transmission, properly drawing each video frame and transmit them
    Logger.log(ambito,refTrazas+" Create Transmit.");
    try {
    int result = createTransmitter();
    } catch (Exception e) {
    Logger.log(ambito,refTrazas+"Error Create Transmitter.");
    return 1;
    } // end try-catch transmitter
    Logger.log(ambito,refTrazas+"Start Procesor.");
    // Start the processor.
    p.start();
    return 0;
    } // end of main code
    * stop when event "EndOfMediaEvent"
    public int stop () {
    try {   
    /* THIS PIECE OF CODE AND VARIATIONS HAVE BEEN TESTED
    AND THE FILE DESCRIPTOR IS NEVER RELEASED */
    p.stop();
    p.deallocate();
    p.close();
    p= null;
    for (int i = 0; i < rtpMgrs.length; i++)
    if (rtpMgrs==null) continue;
    Logger.log(ambito, refTrazas + "removeTargets;");
    rtpMgrs[i].removeTargets( "Session ended.");
    rtpMgrs[i].dispose();
    rtpMgrs[i]=null;
    } catch (Exception e) {
    Logger.log(ambito,refTrazas+"Error Stoping:"+e);
    return 1;
    return 0;
    } // end of stop()
    * Controller Listener.
    public void controllerUpdate(ControllerEvent evt) {
    Logger.log(ambito,refTrazas+"\nControllerEvent."+evt.toString());
    if (evt instanceof ConfigureCompleteEvent ||
    evt instanceof RealizeCompleteEvent ||
    evt instanceof PrefetchCompleteEvent) {
    synchronized (waitSync) {
    stateTransitionOK = true;
    waitSync.notifyAll();
    } else if (evt instanceof ResourceUnavailableEvent) {
    synchronized (waitSync) {
    stateTransitionOK = false;
    waitSync.notifyAll();
    } else if (evt instanceof EndOfMediaEvent) {
    Logger.log(ambito,refTrazas+"\nEvento EndOfMediaEvent.");
    this.stop();
    else if (evt instanceof ControllerClosedEvent)
    Logger.log(ambito,refTrazas+"\nEvent ControllerClosedEvent");
    close = true;
    waitSync.notifyAll();
    else if (evt instanceof StopByRequestEvent)
    Logger.log(ambito,refTrazas+"\nEvent StopByRequestEvent");
    stop =true;
    waitSync.notifyAll();
    Many thanks.

    Its a bug on H263, if you test it without h263 track or with other video codec, the release will be ok.
    You can try to use a not-Sun h263 codec like the one from fobs or jffmpeg projects.

  • Problem with Adobe Reader not being able to run with Maverick  10.9.2?

    problem with Adobe Reader not being able to run with Maverick  10.9.2?

    Have you updated your version of Adobe Reader?

  • Has anyone had a problem with fcp x not playing back a project since installing 10.0.9 update?

    Has anyone had a problem with fcp x not playing back a project since installing 10.0.9 update?

    Not here;  updated three systems without issues.
    Can you provide more details on your system specs, the projects you're referring to, and what kind of behavior you're encountering?
    Russ

  • Has anyone else had a problem with the audio not keeping up with the video when switching to full screen on YouTube?

    Hi. I have a OS X Yosemite Version 10.10.1 Mac Book Air, Processor 1.86 GHz Intel Core 2 Duo.
    Has anyone else had a problem with the audio not keeping up with the video when switching to full screen on YouTube?
    The video starts out fine, but if I click on the expand icon in the lower right corner of the screen the audio won't keep up.
    Refreshing the page don't help at all. In fact, nothing seems to help once it starts.
    I did not have this problem at all using Mavericks. The problem started after installing Yosemite.
    Any way to fix it?

    only $99, i thought it was closer to $175.

  • I had a problem with my WRT54GS not connecting to my inte...

    I had a problem with my WRT54GS not connecting to my internet until I cloned my old routers mac address. I was using a BEFW11S4 which was bullet proof and worked for several years until I changed to Wireless G. Upon purchasing the WRT54GS and setting up all parameters exactly like I had before I could not make any connections, wireless or otherwise until I cloned my mac address to the same address as my previous router. Apparently my ISP had that mac address registered and would not properly perform DHCP even though all other paremeters were correct. I read lots of messages here on line with issues with the WRT54GS connecting and this fixed my problem outright. If you upgrade from a previous generation router (Linksys or otherwise apparently) copy your old routers mac address and clone it to your new router and you should be able to connect. This fixed my problem after several hours and days of troubleshooting. Good Luck Karnage

    As an alternative to using MAC address cloning, you can phone your ISP, tell them you have a new router, and tell them to reset their system to accept the MAC address of your new router.   This way, you won't have to remember the old MAC address, in the event that you need to reset your router to factory defaults.

  • Is anyone having a problem with iPhone 5 not backing up to iCloud. No problem at first now it says it will take 35 hrs, etc to back up.

    Is anyone having a problem with iPhone 5 not backing up to iCloud. No problem at first now it says it will take 35 hrs, etc to back up.

    Thanks for the swift reply, I have been looking online and a loose plug seems to be somewhat of an issue with many, I hope mine is actually a problem and not what others are experiencing. It's taken me this long to even reach out for the simple fact I HATE being a complainer but this is just horrible.
    Do you have an iPad 3 as well? And is yours not experiencing any issues close to mine?
    Thanks again!

  • Using 10.9.2 has anyone had problems with mail sounds not sounding even when they have been selected in mail preferences?, Using 10.9.2 has anyone had problems with mail sounds not sounding even when they have been selected in mail preferences?

    Using 10.9.2 has anyone had problems with mail sounds not sounding even when they have been selected in mail preferences?

    Your download or install of the update may have been corrupt. Visit the Mac App Store and re-download the update or visit http://support.apple.com/kb/DL1726 and download the 10.9.2 update combo and re-install.
    If that fails to solve the problem please post back and post a EtreCheck Report which you can locate at:
    http://www.etresoft.com/etrecheck

  • TS3276 Does anyone have problems with sent messages not showing in their Mail? I have two sent folders when really I only want one. Any tips?

    Does anyone have problems with sent messages not showing in their Mail? I have two sent folders when really I only want one. Any tips?

    Not sure if this is a fix, but I tried sending myself a test email from only  the Bcc field, and lo and behold it now shows the Bcc field in all sent item previews;
    ...maybe leaving the 'To' field blank on purpose forced Mail to show it.
    Rebooted the Mail program, still there - rebooted the machine, still there. Hope this is still relevant and it works for you too - J.

  • HT1338 has anyone else had problems with their mail not loading properly and the multi gestures stopped working on their mac pro after new updates?

    has anyone else had problems with their mail not loading properly and the multi gestures stopped working on their mac pro after new updates?

    Have you tried calling Apple tech support?
    http://www.apple.com/contact/

  • TS3274 i have problem with the sound not working

    i have problem with the sounds not working

    Have you got notifications muted ? Only notifications (including games) get muted, so the iPod/Music and Videos apps, and headphones, still get sound.
    Depending on what you've got Settings > General > Use Side Switch To set to (mute or rotation lock), then you can mute notifications by the switch on the right hand side of the iPad, or via the taskbar : double-click the home button; slide from the left; and it's the icon far left; press home again to exit the taskbar. The function that isn't on the side switch is set via the taskbar instead : http://support.apple.com/kb/HT4085

  • I have new Ipad...MacBook Pro with Mountain Lion:  I have problems with certain applicaitons not sync'ing (like email, cal, notes)...need help

    I have problems with certain applicaitons not sync'ing (like email, cal, notes)...need help

    There are a few twists here. This is my opinion of a quick and easy way to do what you want to do.
    Get a 2.5" sata enclosure like this one - this is just a sample:
    http://www.amazon.ca/eForCity-2-5-inch-SATA-Enclosure-Blue/dp/B0083OOV9G/ref=sr_ 1_1?ie=UTF8&qid=1360012807&sr=8-1
    Put the new ssd in the enclosure, connect it to the Mac using the included USB cable. It is now an external drive.
    Format the drive using Disk Utility.
    Download and run Carbon Copy cloner, and clone your drive to the new external.
    Shutdown. Open the MBP and remove the SSD drive from the enclosure and put it in the place of the old drive.
    Boot the MBP. Once you know the new drive is up and running, you can get to the process of installing the old one in the optical bay.
    http://mac.tutsplus.com/tutorials/hardware/how-to-upgrade-your-macbook-pro-to-an -ssd/

  • Prime Infrastructure 2.1 problem with sorting devices in device groups

    Hi,
    I have a problem with prime infrastructure, namely prime is not doing appropriate sorting of devices in default device groups.
    Example: device type > routers > Cisco 2800 series integrated services routers - under shown results there are Cisco 2911 Integrated Service router, Cisco 2901 etc.
    Any solution? 
    Tnx

    Hi all:
    I have tried using Designing Monitoring Template to set the Health Check Polling time from default 15 minutes to 5 minutes and also tried also 1 minute.
    The result is 5 minutes is working but 1 minute is not working.
    May I know any one can help on this?
    Many thanks!
    Best regards,
    tangsuan

  • [Solved] Problem with file permissions for a group

    I'm working on a simple Apache HTTP server just to get a small education in proper unix work.
    To save myself sudoing everything (and generally because it seems the proper way to use unix), I'm trying to give my user control over the /srv directory. So I ran:
    - `sudo groupadd srvadmin` to create a group called srvadmin
    - `sudo chown -R :srvadmin /srv` to change the group-owner of /srv to srvadmin (and all files inside it)
    - `sudo chmod -vR g+w /srv` to give /srv and all its files group write permission
    - `sudo gpasswd -a <me> srvadmin` to add my user to the srvadmin group
    But I still can't create or edit files in /srv
    "ls -l / | grep srv" gives:
    drwxrwxr-x 4 root srvadmin 4096 Dec 19 17:44 srv
    all the files and directories inside /srv also have group write permissions and are owned by user "root" and group "srvadmin"
    "cat /etc/group | grep srv" gives:
    srvadmin:x:1000:<me>
    However, possibly herein lies a clue:
    "id" gives:
    uid=1000(<me>) gid=100(users) groups=100(users),7(lp),10(wheel),50(games),91(video),92(audio),93(optical),95(storage),96(scanner),98(power)
    That is, "id" doesn't tell me I'm in the srvadmin group.
    It seems like there's an important concept about groups and permissions that I'm not getting, but reading several man and wiki pages hasn't enlightened me. Could anyone suggest what I'm missing?
    Thanks.
    Last edited by bjackman (2012-01-15 20:43:09)

    fsckd wrote:
    bjackman wrote:Edit: I'm guessing only mods can put [Solved] tags in a title?
    No, our job is to tell you to do it yourself: https://wiki.archlinux.org/index.php/Fo … ow_to_Post (second to last bullet)
    Ok, this is pretty embarrassing given the parallels with the topic of this thread, but I coudn't edit the title (which is the reason for my earlier remark; I assumed I didn't have permission)!
    The text box was un-editable (not "disabled", I just couldn't edit the text in it). I managed to change it in the end by deleting all the text and typing a new title. I think it may have been just because the title was at the exact character limit.

Maybe you are looking for

  • Create Organization Data programatically

    I am using ALBPM 5.7 Studio and trying to create Organization data programatically - OU, Participant, Role etc. I am able to fetch data but not able to create OU. For the following code DirOrganizationalUnit dirOrgUnit; dirOrganizationalUnit = dirOrg

  • Data migration from SAP to Oracle

    Can any one suggest best possible method for migrating master and transactional data from SAP to Oracle. Please suggest methods to get data in text file from SAP.

  • PDF Document Atttached in PO- Table or field needed

    HI All, As per the business requirement we have attached the PDF format in the PO. Now business needs to findout in which are all the PO's (List of PO's) the PDF document has been attached? Is there any table or field is available in SAP? or Is there

  • Cannot access card reader Z61t in Windows 7

     hello all, I just recently installed Windows 7 Enterprise, all the driver were installed, but I still can't access my card reader anyone can help?

  • ADF FACES: af:table and complex column data

    Using EA15. I want to use an af:table to allow the in-place editing of the data. However, I have some fields that are not simple text entry fields. Two of them would ideally use af:selectOneList elements. This doesn't work given the limitations of ho