Need help on Order by Condition

hi, I have a generic column in the table and value can be jan08,feb08................dec11 or YR08,YR09......YR11
i need a order by condition based on the parm selected.
I tried like this but gives me error.
select x
from t
order by decode(&p_cal,'month',(to_number(substr(trim(t), -2)), TO_DATE(substr(trim(t), 1,3)),''MON'')),'year',1);
Thanks
--K                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Hi,
Whatever you want, you'll stay in trouble anyway (or the guy maintaining your code when you have retired), since you store year in 2 digits...
I borrowed Salim's suggestion, and see what happens:
MHO%xe> WITH t AS
  2         (SELECT 'dec11' m
  3            FROM DUAL
  4          UNION ALL
  5          SELECT 'feb08'
  6            FROM DUAL
  7          UNION ALL
  8          SELECT 'YR08'
  9            FROM DUAL
10          UNION ALL
11          SELECT 'jan08'
12            FROM DUAL)
13    SELECT CASE
14              WHEN INSTR (m, 'YR', 1) = 0
15                 THEN TO_DATE (m, 'monYYYY')
16              ELSE TO_DATE (SUBSTR (m, -2), 'YYYY')
17            end m1           
18    ,      CASE
19              WHEN INSTR (m, 'YR', 1) = 0
20                 THEN TO_DATE (m, 'monRRRR')
21              ELSE TO_DATE (SUBSTR (m, -2), 'RRRR')
22            end m2         
23    from t
24    order by
25           CASE
26              WHEN INSTR (m, 'YR', 1) = 0
27                 THEN TO_DATE (m, 'monYYYY')
28              ELSE TO_DATE (SUBSTR (m, -2), 'YYYY')
29           END;
M1                  M2
01-01-0008 00:00:00 01-01-2008 00:00:00
01-02-0008 00:00:00 01-02-2008 00:00:00
01-05-0008 00:00:00 01-05-2008 00:00:00
01-12-0011 00:00:00 01-12-2011 00:00:00How can you even tell the right CENTURY you're in here?
How will you create reliable reports/overviews/aggregations etc.?
It's 2009 already and still people are using strings to store dates??
Still people only use 2 digits for a year??
Still people refuse to use the DATE functionality Oracle offers?
This 'generic thing' s**ks major/is a very bad approach..you will ALWAYS run into trouble and it will ALWAYS perform less efficient compared to using the right datatype.
DATES are DATES, and therefore they are NOT 'generic strings we can play with without any trouble'.
You might get away with it temporarily, but it will haunt you ( or 'the guy after you' ) eventually.
So, like SomeoneElse already stated: fix your datamodel.
Edited by: hoek on May 4, 2009 10:01 PM some minor changes

Similar Messages

  • I had to put my computer by together without migration or time machine I NEED help with order of the files?

    I had to put my computer by together without migration or time machine I NEED help with order of the files?

    Hi, where are these other files exactly?

  • Need help in order to buy Toshiba notebook from Toshiba directly

    Good morning.
    I want to buy a laptop in http://www.toshibadirect.com/ and chose the product,
    I have credit card.
    I have a family who will receive the laptop
    What I want is someone advise me on the east or purchase I need help to complete the purchase.
    Personal toshiba to help me to complete this purchase. .
    Thanks
    Note:
    I live in Peru.
    I have some queries about the product.

    Hi
    First of all you should know that this is a user to user forum. So you will not find any people from Toshiba here.
    Secondly I have checked the page which you have posted in the posting and find this phone number. Call 800-316-0920 for shopping assistance.
    Otherwise I recommend searching for some online dealers who provide the notebook which you want to buy.
    Good luck

  • Need help with ORDER BY clause

    Hey,
    I have a table:
    Name: Year:
    Eagle 2000
    Tiger 2001
    Eagle 2002
    Lion 2006
    Lion 1999
    Fox 1991
    Lion 1995
    I need a query which will return in such order:
    Name: Year: Position:
    Eagle 2000 1
    Eagle 2002 2
    Fox 1991 1
    Lion 1995 1
    Lion 1999 2
    Lion 2006 3
    Tiger 2001 1
    So, of course to get Name and Year in this order is quite easy:
    select Name, Year from Animals order by Name, Year;
    but how about Position, is there a way to count it with SQL?
    any help is welcome,
    Silvestras

    SQL> with rt as
      2  (select 'Eagle' nm, 2000 yr from dual union all
      3  select 'Tiger', 2001 from dual union all
      4  select 'eagle', 2002 from dual union all
      5  select 'Lion', 2006 from dual union all
      6  select 'Lion', 1999 from dual union all
      7  select 'Fox', 1991 from dual union all
      8  select 'Lion', 1995 from dual)
      9  select nm,yr,row_number() over(partition by (nm) order by nm,yr) position from rt;
    NM            YR   POSITION
    Eagle       2000          1
    Fox         1991          1
    Lion        1995          1
    Lion        1999          2
    Lion        2006          3
    Tiger       2001          1
    eagle 2002 1
    7 rows selected.
    SQL> with rt as
      2  (select 'Eagle' nm, 2000 yr from dual union all
      3  select 'Tiger', 2001 from dual union all
      4  select 'eagle', 2002 from dual union all
      5  select 'Lion', 2006 from dual union all
      6  select 'Lion', 1999 from dual union all
      7  select 'Fox', 1991 from dual union all
      8  select 'Lion', 1995 from dual)
      9  select nm,yr,row_number() over(partition by lower(nm) order by nm,yr) position from rt;
    NM            YR   POSITION
    Eagle       2000          1
    eagle 2002 2
    Fox         1991          1
    Lion        1995          1
    Lion        1999          2
    Lion        2006          3
    Tiger       2001          1
    7 rows selected.
    SQL> 

  • Need help to check multiple conditions and set AD user properties

    hello All,
    I have a data csv sheet where information as follows, using below information I need to update AD account attributes based on below conditions . I have full right and I can set any user properties. So this is not access right issue.   
    samaccountname,Othertelephone,language,employeeId
    abcd                      XXXXXXXXX     EN         SMS
    Now I need to check following conditions:
    Othertelephone =  if this should not be blank ,if so display message " filed is blank " and no changes should allowed in further attributes and  it should abort
    language= this field should only contain  EN or FR value if No display msg " error in language field " and no further changes to  the user attributes and it should abort
    employeeID= this field should only contain OTP or SMS value if Not filled display msg " error in Employee ID field " No further changes to the user attributes and it should abort
    changes to user will permit  when all attributes is filled. I do the testing taking samaccountname , othertelephone and employeeId into consideration but it did not helped. Getting error
    THIS is complete Code Of my Task where you need my focus on conditions
    group=Get-QAdGroup -SearchRoot  "domain/vpn group"
    Import-Csv D:\VPN.csv |
    ForEach-Object{
    if ($_.samaccountname -eq "")
       Write-Host "SAMACCOUNTNAME is blank"   -fore red
    else
     $user=Get-QAduser $_.samaccountname
    if ($user.memberof -contains  $group.DN)
     Write-Host "$($_.Samaccountname) user is allready a member" -fore red
    else
     Add-QADGroupMember $group $_.Samaccountname
    If ($_.othertelephone -eq "")
    Write-Output "$($_.samaccountname) telephone Number is blank"
    else
    if ($_.EmployeeID -notmatch 'OTP' -and 'SMS')
    Write-Output "$($_.samaccountname) EmployeeID field is not correctly field")
    Else
    Set-QADUser $_.SamAccountName -ObjectAttributes @{telephonenumber=$_.othertelephone;EmployeeID=$_.EmployeeID}
    error
    Set-QADUser : Access is denied.
    At C:\Users\g512263\AppData\Local\Temp\5f8facb6-f942-4c3d-b924-8953d9a706da.ps1:37 char:8
    +                    Set-QADUser $_.SamAccountName -ObjectAttributes @{telephonenumber=$_.othe ...
    +    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Set-QADUser], UnauthorizedAccessException
        + FullyQualifiedErrorId : System.UnauthorizedAccessException,Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlets.SetUserCm
       dlet

    <title>Untitled - PowerGUI Script Editor</title>
    Hello JRV,Thank you for your time, There is no comma in my csv file , I double check. below I wrote a simple code.I removed all the conditions and just try to set the EmployeeID and it is working fine with same file.But as soon as I add conditions it gives access denied. as well as if I remove employee Id from your previous code and only try to set telephone No. still it gives access denied.I am just trying to figure out what is causing this.
    $group=Get-QAdGroup -SearchRoot "com/Group"
    Import-Csv D:\VPN.csv |
    ForEach-Object{
    if ($_.samaccountname -eq ""){
    Write-Host "SAMACCOUNTNAME is blank" -fore red
    }else{
    $user=Get-QAduser $_.samaccountname
    if ($user.memberof -contains $group.DN){
    Write-Host "$($_.Samaccountname) user is allready a member" -fore red
    }else
    Add-QADGroupMember $group $_.Samaccountname
    If ($_.othertelephone -ne "")
    Set-QADUser $user.SamAccountName -ObjectAtt Aributes @{telephonenumber=$_.othertelephone}
    } else
    Write-Output "$($_.samaccountname) phonenumber is blank"
    If ($_.EmployeeID -ne "")
    Set-QADUser $_.SamAccountName -ObjectAttributes @{EmployeeID=$_.EmployeeID}
    }else
    Write-Output "$($_.samaccountname) EmployeeID field is blank"
    If ($_.Preferredlanguage -ne "")
    Set-QADUser $_.SamAccountName -ObjectAttributes @{Preferredlanguage=$_.preferredlanguage}
    } else
    Write-Output "$($_.samaccountname) PreferredLanguage field is blank"

  • Need help to solve if condition

    Hi All,
    I need to resize the images to thumbnail veiw the condition is width should not exceed 75 pixels and height should not exceed 50 pixels
    app.preferences.rulerUnits = Units.PIXELS     
         var Wid = docRef.width;
         var Hig = docRef.height;
                    if (Number(Wid) > 75)
                             docRef.resizeImage(75,null,);                 
                    else if(Number(Hig) >= 50)
                            docRef.resizeImage(null,50,);
    This works fine, but if the images are width 85 and hieght 200 px
    The result is (75,176).  which is wrong.
    Please help me to solve
    regards,
    Vinoth

    What you were doing is also what Fit image plug-in script does and scripts like the Image processor does to resize images to fit within some pixels area while maintaining the images aspect ratio. Fit an image into some pixel width and into some pixel height. In fact the images processor uses the Fit Image plugin script to do the work. Here is that code from the Image processor script
    // use the fit image automation plug-in to do this work for me
    function FitImage( inWidth, inHeight ) {
              if ( inWidth == undefined || inHeight == undefined ) {
                        alert( strWidthAndHeight );
                        return;
              var desc = new ActionDescriptor();
              var unitPixels = charIDToTypeID( '#Pxl' );
              desc.putUnitDouble( charIDToTypeID( 'Wdth' ), unitPixels, inWidth );
              desc.putUnitDouble( charIDToTypeID( 'Hght' ), unitPixels, inHeight );
              var runtimeEventID = stringIDToTypeID( "3caa3434-cb67-11d1-bc43-0060b0a13dc4" );
              executeAction( runtimeEventID, desc, DialogModes.NO );

  • Need help cancelling order

    Hello,
    I placed order {removed per forum guidelines} and changed the order delivery to In Store pickup.  I have decided I want to cancel this order altogether, but I am unable to do it on the website.  I would like assistance in cancelling this order {removed per forum guidelines} thank you.

    If it is has already been confirmed as ready for pickup, you would either need to call 1888bestbuy, go to the store, or simply wait and it will auto cancel after 8 days of being ready for pickup.
    Crystal
    Superuser
    Forum Guidelines | Terms & Conditions | Community Guidelines | What is a Superuser?
    *Remember to mark your questions solved and click the star to give kudos to show your thanks!*
    While I used to be a Best Buy Employee, I no longer have any affiliation with Best Buy.
    My opinions do not in any way shape or form represent Best Buy's Official decisions.

  • Need help in returning error condition from web service

    Hi,
    I need one help regarding webservice. Currently my web service is returning "true" value when it works fine without any issues but it returns "false" when any any error is encountered. So my question is, can we return error instead of string "false". I dont know how to return exact error from webservice. If you any idea then please mail me.
    Below is a small code snippet:
    System.out.println("User "+ userFullName + usrKey + " end date has been updated to "+usrEndDate +" in IDM DB");
    result = true;
    catch (tcAPIException e) {
    log.error("Error in finding the user" + e.getMessage());
    result = false;
    } catch (tcUserNotFoundException e) {
    log.error("Error in getting user status" + e.getMessage());
    result = false;
    } catch (tcStaleDataUpdateException e) {
    log.error("Error in updating end date of user" + e.getMessage());
    result = false;
    }catch (Exception e1) {
    e1.printStackTrace();
    result =false;
    return result;
    Here i want to return error instead of false. Can we do that?
    Thanks,
    Kalpana.

    instead of storing false store below
    use result=e1.getMessage();
    Edited by: Nishith Nayan on Feb 23, 2012 8:07 PM

  • [10g] Need help with order by clause in hierarchical query

    I have the following sample data:
    CREATE TABLE     bill_test1
    (     parent_part     CHAR(25)
    ,     child_part     CHAR(25)
    ,     line_nbr     NUMBER(5)
    ,     qty_per          NUMBER(9,5)
    INSERT INTO bill_test1 VALUES ('ABC-1','ABC-10',100,1);
    INSERT INTO bill_test1 VALUES ('ABC-1','ABC-20',200,2);
    INSERT INTO bill_test1 VALUES ('ABC-1','ABC-30',300,3);
    INSERT INTO bill_test1 VALUES ('ABC-1','HARDWARE-1',401,10);
    INSERT INTO bill_test1 VALUES ('ABC-1','HARDWARE-2',402,5);
    INSERT INTO bill_test1 VALUES ('ABC-10','ABC-155',100,2);
    INSERT INTO bill_test1 VALUES ('ABC-10','HARDWARE-1',200,1);
    INSERT INTO bill_test1 VALUES ('ABC-155','RAW-2',100,4.8);
    INSERT INTO bill_test1 VALUES ('ABC-155','HARDWARE-3',200,3);
    INSERT INTO bill_test1 VALUES ('ABC-20','RAW-1',100,10.2);
    INSERT INTO bill_test1 VALUES ('ABC-30','RAW-3',100,3);And the query below gives me exactly what I want, in the order I want it. However, I am wondering if there is a way to get this order without creating the SEQ column, since I don't need it in my results
    SELECT     part_nbr
    ,     parent_part
    ,     child_part
    FROM     (
         SELECT     CONNECT_BY_ROOT b.parent_part                         AS part_nbr
         ,     b.parent_part
         ,     b.child_part
         ,     SYS_CONNECT_BY_PATH(b.line_nbr,' ')                    AS seq
         FROM     bill_test1 b
         ,     dual
         CONNECT BY     parent_part     = PRIOR child_part
    WHERE          part_nbr     = 'ABC-1'
    ORDER BY     seq
    Results of above query, except with SEQ included in SELECT (just to show what I'm sorting off of):
    PART_NBR                     PARENT_PART                  CHILD_PART                   SEQ
    ABC-1                        ABC-1                        ABC-10                        100
    ABC-1                        ABC-10                       ABC-155                       100 100
    ABC-1                        ABC-155                      RAW-2                         100 100 100
    ABC-1                        ABC-155                      HARDWARE-3                    100 100 200
    ABC-1                        ABC-10                       HARDWARE-1                    100 200
    ABC-1                        ABC-1                        ABC-20                        200
    ABC-1                        ABC-20                       RAW-1                         200 100
    ABC-1                        ABC-1                        ABC-30                        300
    ABC-1                        ABC-30                       RAW-3                         300 100
    ABC-1                        ABC-1                        HARDWARE-1                    401
    ABC-1                        ABC-1                        HARDWARE-2                    402

    Hi,
    As long as there's only one root, you can say ORDER SIBLINGS BY, but you can't do that in a sub-query (well, you can, but usually there's no point in doing it in a sub-query). If the CONNECT BY is being done in a sub-query, there is no guarantee that the main query will preserve the hierarchical order that the sub-query provides.
    The query you posted doesn't require a suib-query, so you can say:
    SELECT     CONNECT_BY_ROOT b.parent_part                         AS part_nbr
    ,     b.parent_part
    ,     b.child_part
    --,     SYS_CONNECT_BY_PATH(b.line_nbr,' ')                    AS seq
    FROM     bill_test1 b
    WHERE          CONNECT_BY_ROOT b.parent_part     = 'ABC-1'
    CONNECT BY     parent_part     = PRIOR child_part
    ORDER SIBLINGS BY     b.line_nbr     
    ;I said the query you posted doesn't require a sub-query. It also doesn't require dual, so I suspect what you posted is a simplification of what you're really doing, and that may need a sub-query. In particular, if you intend to GROUP BY part_nbr, then you need the sub-query. We can repeat the CONNECT_BY_ROOT expression in the WHERE clause (or, now that I think about it, use a START WITH clause instead of WHERE), but, for some reason, we can't use CONNECT_BY_ROOT in a GROUP BY clause; we need to compute CONNECT_BY_ROOT in a sub-query, give it a name (like part_nbr), and GROUP BY that column in a super-query.
    This assumes that there is only one root node. ORDER SIBLINGS BY means just that: children of a common parent will appear in order, but the root nodes, who have no parents, will not necessarily be in order.
    Here's what I meant by using START WITH instead of WHERE:
    SELECT     CONNECT_BY_ROOT b.parent_part                         AS part_nbr
    ,     b.parent_part
    ,     b.child_part
    --,     SYS_CONNECT_BY_PATH(b.line_nbr,' ')                    AS seq
    FROM     bill_test1 b
    START WITH     b.parent_part     = 'ABC-1'
    CONNECT BY     parent_part     = PRIOR child_part
    ORDER SIBLINGS BY     b.line_nbr     
    ;This should be much more efficient, because it narrows down the results before you waste time getting their descendants.
    Using a START WITH clause here is analagous to me sending you an e-mail, saying "Come to a meeting a my office at 3:00."
    Using a WHERE clause here is analagous to me sending an e-mail to everyone in the company, saying "Come to a meeting a my office at 3:00", and then, as people get here, telling everyone except you that they can go back.
    ORDER SIBLINGS BY was introduced in Oracle 9.
    Edited by: Frank Kulash on Dec 9, 2010 2:39 PM
    Added version with START WITH clause

  • Need help in order to recovery my Satellite L450-16Q

    My laptop had a virus so I used the Product Recovery disk that came with it, thinking that it would fix it but it ended up erasing the whole of my computer even windows 7.
    So now I have a computer I can't use I have bought windows 7 directly from microsoft which I have downloaded and tried to install but it doesn't work.
    I have also bought the product recovery disks from toshiba's backup media site in hope that they will work.
    Can anyone help/advise on what I need to do.
    Thank you
    Sharron

    Hello
    The whole story is a little bit confusing for me. So lets see what you wrote:
    >... thinking that it would fix it but it ended up erasing the whole of my computer even windows 7.
    Thinking is wrong. What you need is exact info about recovery installation and this can be found in users manuals document. Recovery disc is not like Microsoft installation disc and cannot be used for repair. Recovery disc contains recovery image and can be used for clean OS installation (recovery image installation) only.
    > So now I have a computer I can't use
    Why you cannot use it? Recovery image installation installs OS again. Which OS is installed after running recovery image installation?
    > I have also bought the product recovery disks from toshiba's backup media site
    But why if you already have recovery disc that you have used at the beginning of the whole story?
    What you need to do is to use this original disc for OS installation.
    -start your notebook and press F12 several times to enter BOOT menu
    -when the menu is shown put recovery disc into ODD
    -select CD/DVD drive in the menu and press ENTER
    -follow the menu on the screen
    After recovery image installation you will have factory settings again and everything should be OK.
    More questions?

  • Need help on order by in PL/SQL

    Hi all,
    I know this problem would have occurred a lot of times before, but me being a beginner want to know all the possible solution for this one.Now I am having a procedure in which I am declaring a cursor to select rows from a table
    create or replace procedure call_me(sortstring IN Varchar2(200))
    IS
    cursor cur is
    select * from EMP order by (sortstring);
    BEGIN
    for rec in cur
    Loop
    DBMS_OUTPUT.PUT_LINE(cur.EMPNAME)
    END LOOP;
    END;
    Assume the EMP table has
    EMPID,EMPNAME,EMPCITY,EMPDEPT as its fields
    I am calling the procedure like
    exec procedure_call('EMPCITY,EMPDEPT')
    but I get an unsorted output, worse still
    exec procedure_call('EMPCITY')
    itself is not working.If I hard-code the order by columns in the query it is working, but when I pass it as argument it is not working.Please help me resolve this issue.

    In your case,
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    Elapsed: 00:00:00.33
    satyaki>
    satyaki>select * from emp order by '&str';
    Enter value for str: empno
    old   1: select * from emp order by '&str'
    new   1: select * from emp order by 'empno'
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7499 Travor     SALESMAN        7698 20-FEB-81       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       4450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       7000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
    13 rows selected.
    Elapsed: 00:00:01.00
    satyaki>In our case,
    satyaki>select * from emp order by &str;
    Enter value for str: empno
    old   1: select * from emp order by &str
    new   1: select * from emp order by empno
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7499 Travor     SALESMAN        7698 20-FEB-81       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7782 CLARK      MANAGER         7839 09-JUN-81       4450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       7000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
    13 rows selected.
    Elapsed: 00:00:00.31
    satyaki>/
    Enter value for str: empno,job
    old   1: select * from emp order by &str
    new   1: select * from emp order by empno,job
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7499 Travor     SALESMAN        7698 20-FEB-81       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7782 CLARK      MANAGER         7839 09-JUN-81       4450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       7000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
    13 rows selected.
    Elapsed: 00:00:00.18
    satyaki>So, capitalizing this ->
    satyaki>
    satyaki>declare
      2    cursor cur
      3    is
      4      select *
      5      from EMP
      6      order by &sortstring;
      7     
      8    rec cur%rowtype;
      9  begin
    10   for rec in cur
    11    Loop
    12      DBMS_OUTPUT.PUT_LINE(rec.ENAME);
    13    END LOOP;
    14  END;
    15  /
    Enter value for sortstring: empno,job
    old   6:     order by &sortstring;
    new   6:     order by empno,job;
    Travor
    WARD
    JONES
    MARTIN
    BLAKE
    SOURAV
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    JAMES
    FORD
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.84
    satyaki>Got my point?
    Regards.
    Satyaki De.

  • Need help with order booking tutorial

    Hi
    I am new to OracleFusion.
    Started Learning By practising OrderBooking tutorial for 10g.
    I am practising parellel branching in the tutorial .
    I ve invoked Rapid distributors service in branch 1 of the flow activity.
    and
    i ve invoked Select manufacturing service in branch 2 of flow activity.
    I ve deployed order booking service,rapid distributed service,select manufacturing service in the server.
    Select manufacturing service is an asynchronous service .for this service to be complete it requires user to manually set price for the item ordered.
    So I accesed SelectManufacturinUI in browser as instructed in book.The problem is tht it is directing me to login page where User id and password should be submitted.
    In the tutorial no info is given regarding login details fot this page.Hence i am not able to set price for order.
    So the Select manufacturing service is not completed ..hence i am not able to move further in the tutorial..
    Kindly help with this..if any one has faced same prblm
    thanks

    Hi
    I got the answer. Just posting it so that it helps someone
    User id i tried : jcooper
    password : Bpel console startup password

  • Need help with Order by statement

    I have a report which has an order by statement to order a varchar2 field in ascending order.
    The report sorts the records correctly but if I rerun the report, the records with the same values in the column that I order by, do not maintain the same order as was in the report's 1st run.
    The records will still be sorted in ascending order but those records that have the same values interchange positions each time I run the report.
    Is this ok or is there a way of making records with same values maintain the same order in all the report runs? Please assist. Thanks.

    user8655468 wrote:
    but those records that have the same values interchange positions each time I run the report.
    Is this ok or is there a way of making records with same values maintain the same order in all the report runs? Please assist. Thanks.Hello,
    It's normal those are same values may interchange at each run. you can add another column in order by clause. That
    Order by column1,column2 may add another column3 -- this will maintain always same but column 1,2,3 have same value , it will may interchange.
    Hope this helps
    Hamid

  • Need help with order by

    Test Data:
      CREATE TABLE "TEST_GMU"
       ( "PZINSKEY" VARCHAR2(255) NOT NULL ENABLE,
    "PXCREATEDATETIME" DATE,
    "PXURGENCYASSIGN" NUMBER(18,0),
    "WORK_PXURGENCYWORK" NUMBER(18,0),
    "MASTERACCNTFIRMCUSTID" VARCHAR2(255 CHAR)
       ) SEGMENT CREATION IMMEDIATE
      PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
    insert into test_gmu values ('ASSIGN-WORKBASKET SCHWAB-ACE-SERVICEREQUEST-WORK-ACCTMAINT AM-12858!AMADVISORSERVICESFLOW','16-JUL-13 15.55.57.000000 PM',0,40,'2531215'); 
    insert into test_gmu values ('ASSIGN-WORKBASKET SCHWAB-ACE-SERVICEREQUEST-WORK-ACCTMAINT AM-12859!AMADVISORSERVICESFLOW','16-JUL-13 15.01.22.000000 PM',0,40,'742254777');
    insert into test_gmu values ('ASSIGN-WORKBASKET SCHWAB-ACE-SERVICEREQUEST-WORK-ACCTMAINT AM-12860!AMADVISORSERVICESFLOW','16-JUL-13 15.01.23.000000 PM',0,40,'2531215'); 
    insert into test_gmu values ('ASSIGN-WORKBASKET SCHWAB-ACE-SERVICEREQUEST-WORK-ACCTMAINT AM-12861!AMADVISORSERVICESFLOW','16-JUL-13 15.03.55.000000 PM',0,40,'2568091'); 
    insert into test_gmu values ('ASSIGN-WORKBASKET SCHWAB-ACE-SERVICEREQUEST-WORK-ACCTMAINT AM-12862!AMADVISORSERVICESFLOW','16-JUL-13 15.03.56.000000 PM',0,40,'742254777');
    insert into test_gmu values ('ASSIGN-WORKBASKET SCHWAB-ACE-SERVICEREQUEST-WORK-ACCTMAINT AM-12863!AMADVISORSERVICESFLOW','16-JUL-13 15.03.57.000000 PM',0,40,'2568091'); 
    insert into test_gmu values ('ASSIGN-WORKBASKET SCHWAB-ACE-SERVICEREQUEST-WORK-ACCTMAINT AM-12864!AMADVISORSERVICESFLOW','16-JUL-13 15.06.29.000000 PM',0,40,'742254777');
    insert into test_gmu values ('ASSIGN-WORKBASKET SCHWAB-ACE-SERVICEREQUEST-WORK-ACCTMAINT AM-12865!AMADVISORSERVICESFLOW','16-JUL-13 15.06.31.000000 PM',0,40,'2568091'); 
    insert into test_gmu values ('ASSIGN-WORKBASKET SCHWAB-ACE-SERVICEREQUEST-WORK-ACCTMAINT AM-12866!AMADVISORSERVICESFLOW','16-JUL-13 15.06.32.000000 PM',0,40,'742254777');
    The output required is like below
    1.       AM-12859 BXYZAB CO. 742254777  07/16/2013 15:01:21
    2.       AM-12862 BXYZAB CO. 742254777  07/16/2013 15:03:56
    3.       AM-12864 BXYZAB CO. 742254777  07/16/2013 15:06:27
    4.       AM-12866 BXYZAB CO. 742254777  07/16/2013 15:06:31
    5.       AM-12858 WHIJKL CO.  2531215  07/16/2013 15:01:16       The values of this timestamp is actually '16-JUL-13 15.55.57 in datbase
    6.       AM-12860 WHIJKL CO.  2531215  07/16/2013 15:01:22
    7.       AM-12861 SIJKLM CO.  2568091  07/16/2013 15:03:54
    8.       AM-12863 SIJKLM CO.  2568091  07/16/2013 15:03:56
    9.       AM-12865 SIJKLM CO.  2568091  07/16/2013 15:06:30
    I could work this out till below:
    ASSIGN-WORKBASKET SCHWAB-ACE-SERVICEREQUEST-WORK-ACCTMAINT AM-12859!AMADVISORSERVICESFLOW 7/16/2013 3:01:22 PM 0 40 742254777
    ASSIGN-WORKBASKET SCHWAB-ACE-SERVICEREQUEST-WORK-ACCTMAINT AM-12862!AMADVISORSERVICESFLOW 7/16/2013 3:03:56 PM 0 40 742254777
    ASSIGN-WORKBASKET SCHWAB-ACE-SERVICEREQUEST-WORK-ACCTMAINT AM-12864!AMADVISORSERVICESFLOW 7/16/2013 3:06:29 PM 0 40 742254777
    ASSIGN-WORKBASKET SCHWAB-ACE-SERVICEREQUEST-WORK-ACCTMAINT AM-12866!AMADVISORSERVICESFLOW 7/16/2013 3:06:32 PM 0 40 742254777
    ASSIGN-WORKBASKET SCHWAB-ACE-SERVICEREQUEST-WORK-ACCTMAINT AM-12861!AMADVISORSERVICESFLOW 7/16/2013 3:03:55 PM 0 40 2568091 
    ASSIGN-WORKBASKET SCHWAB-ACE-SERVICEREQUEST-WORK-ACCTMAINT AM-12863!AMADVISORSERVICESFLOW 7/16/2013 3:03:57 PM 0 40 2568091 
    ASSIGN-WORKBASKET SCHWAB-ACE-SERVICEREQUEST-WORK-ACCTMAINT AM-12865!AMADVISORSERVICESFLOW 7/16/2013 3:06:31 PM 0 40 2568091 
    ASSIGN-WORKBASKET SCHWAB-ACE-SERVICEREQUEST-WORK-ACCTMAINT AM-12860!AMADVISORSERVICESFLOW 7/16/2013 3:01:23 PM 0 40 2531215 
    ASSIGN-WORKBASKET SCHWAB-ACE-SERVICEREQUEST-WORK-ACCTMAINT AM-12858!AMADVISORSERVICESFLOW 7/16/2013 3:55:57 PM 0 40 2531215
    with order by masteraccntfirmcustid desc ,pxcreatedatetime
    But one of the developer told me masteraccntfirmcustid should be asc
    This resultset is supposed to be ordered by
    order by masteraccntfirmcustid ,pxurgencyassign desc NULLS LAST ,work_pxurgencywork desc NULLS LAST,pxcreatedatetime
    in the test data I have been given pxurgencyassign and work_pxurgencywork is same for all the records
    Could you please help?
    Thanks,
    swapnil

    the results of the query are not matching the data in the table.  like ....
    1.      BXYZAB CO.
    2.      BXYZAB CO.
    3.      BXYZAB CO.

  • Need help restoring order of songs on albums

    Please help me!!!
    For some reason, all the songs on my albums are playing/displaying in alphabetical order!!! I have no idea how this happened. Can you tell me how to fix this?
    (For example, for some reason now when I open an artist's album, all the songs are displayed and played in either ascending or descending order alphabetically.)

    If you have the track number in the ID tag you can just resort by that column in iTunes.
    If you can't see the track number column right click teh header bar to add it

Maybe you are looking for

  • FCE 4 Automatic Color Corrections

    I imported some old VHS tapes (originally on 16 MM video camera, converted to VHS) via my ADVC-300. I am new to MAC and FCE so forgive my basic question, searches did not result in any hits. Anyone have suggestions on cleaning up the video? Can the f

  • Wireless connection issue

    Hi, I have been using the BT Home Hub 2.0 for approx 1.5 years, wirelessly connected to my Mac. I have now bought a network adaptor for my PC which is upstairs. the adaptor was installed easily and connected straight away to the hub and shows excelle

  • HELP!!!...Firefox 4...STOP cursor focus from going to Bing search box????

    I just installed Firefox 4....Now every time I open firefox the cursor will automatically jump to the bing search box. I want it to start and stay inside the address bar. A long time ago I had this same problem and searched online and found a solutio

  • How can I encrypt a ViewPreset (InDesign server)

    I am creating a website in which customers can create their own documents. I have created templates in InDesign and the customer can adjust the texts in the website. What I would like to see, is the option to encrypt a PDF, so that the customer canno

  • HT5312 how to creat a rescure email address ?

    hi I have ann Apple acount but I dont have a rescure email address, how can i add a rescure email address to my account?