SQL Help adding totals to cols..

Hi All,
We have a sql report that we need some help finishing please.
The report display col data as rows and we need to total up the values at the end of the report.
The table is as follows:
desc all_positions
Name                                                                     Null?    Type
OFFICE_TYPE_DESCRIPTION                                                           VARCHAR2(60)
POSITION_ABBREVIATION                                                             VARCHAR2(10)
POSITION                                                                          VARCHAR2(60)
SD                                                                                VARCHAR2(43)
HIRED                                                                             NUMBER
OPEN                                                                              NUMBERThe SQL select is:
SELECT  SD
          ,SUM(open) total_open
          ,SUM(hired) total_hired
          ,COUNT(decode(a.position_abbreviation, 'POS-1', 1, NULL))   "Position 1 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-2', 1, NULL))      "Position 2 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-3', 1, NULL))   "Position 3 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-4', 1, NULL))   "Position 4 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-5', 1, NULL))   "Position 5 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-6', 1, NULL))   "Position 6 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-7', 1, NULL))   "Position 7 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-8', 1, NULL))   "Position 8 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-9', 1, NULL))   "Position 9 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-10', 1, NULL))  "Position 10 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-11', 1, NULL))  "Position 11 Header/Description"     
          ,COUNT(decode(a.position_abbreviation, 'POS-12', 1, NULL))  "Position 12 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-13', 1, NULL))  "Position 13 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-14', 1, NULL))  "Position 14 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-15', 1, NULL))  "Position 15 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-16', 1, NULL))  "Position 16 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-17', 1, NULL))  "Position 17 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-18', 1, NULL))  "Position 18 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-19', 1, NULL))  "Position 19 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-20', 1, NULL))  "Position 20 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-21', 1, NULL))  "Position 21 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-22', 1, NULL))  "Position 22 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-23', 1, NULL))  "Position 23 Header/Description"
FROM ALL_POSITIONS a
GROUP BY SD
order by SD;There are 23 distinct values for "position_abbreviation" and we go through them individually working out the counts.. The report displays as follows:
SD         TOTAL_OPEN TOTAL_HIRED Position 1 Header/Descript Position 2 H Position 3 Header         Position 4 Header   Position 5 Header/Description  ...etc all the way to the last position
SD-10               6         816                          1            1                         1                  1                              1 
SD-11              14         777                          0            1                         1                  1                              0 
SD-12              59         770                          0            1                         1                  1                              0
SD-13               2         975                          0            1                         0                  1                              0
SD-14              78         726                          1            1                         0                  1                              0 
SD-15              14         604                          1            1                         1                  1                              0
SD-16             113         651                          0            1                         1                  1                              1  How can we total up cols at the end of the report? For example the report will display like the following:
SD         TOTAL_OPEN TOTAL_HIRED     Position 1 Header/Desc Position 2      Position 3 Header/desc  Position 4 Header         Position 5 Header/Desc   ...etc all the way to the last position
SD-10               6         816                          1            1                         1                  1                              1 
SD-11              14         777                          0            1                         1                  1                              0 
SD-12              59         770                          0            1                         1                  1                              0
SD-13               2         975                          0            1                         0                  1                              0
SD-14              78         726                          1            1                         0                  1                              0 
SD-15              14         604                          1            1                         1                  1                              0
SD-16             113         651                          0            1                         1                  1                              1 
Total             286        5319                          3            7                         5                  7                              2Thanks in advance for your help.
Regards
Edited by: rsar001 on Nov 29, 2011 6:08 AM

As Frank said....use rollup
check below
SELECT  nvl(SD,'Total')
          ,SUM(open) total_open
          ,SUM(hired) total_hired
          ,COUNT(decode(a.position_abbreviation, 'POS-1', 1, NULL))   "Position 1 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-2', 1, NULL))      "Position 2 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-3', 1, NULL))   "Position 3 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-4', 1, NULL))   "Position 4 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-5', 1, NULL))   "Position 5 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-6', 1, NULL))   "Position 6 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-7', 1, NULL))   "Position 7 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-8', 1, NULL))   "Position 8 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-9', 1, NULL))   "Position 9 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-10', 1, NULL))  "Position 10 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-11', 1, NULL))  "Position 11 Header/Description"     
          ,COUNT(decode(a.position_abbreviation, 'POS-12', 1, NULL))  "Position 12 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-13', 1, NULL))  "Position 13 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-14', 1, NULL))  "Position 14 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-15', 1, NULL))  "Position 15 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-16', 1, NULL))  "Position 16 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-17', 1, NULL))  "Position 17 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-18', 1, NULL))  "Position 18 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-19', 1, NULL))  "Position 19 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-20', 1, NULL))  "Position 20 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-21', 1, NULL))  "Position 21 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-22', 1, NULL))  "Position 22 Header/Description"
          ,COUNT(decode(a.position_abbreviation, 'POS-23', 1, NULL))  "Position 23 Header/Description"
FROM ALL_POSITIONS a
GROUP BY rollup(SD)
order by SD;Edited by: newbie on Nov 29, 2011 6:20 AM

Similar Messages

  • PIVOT sql help

    Hi again
    I need some PIVOT sql help
    In this query:
    SELECT
    SUM([RATES]) as RATES
    ,SUM([CONVERSION])as CONVERSION
    FROM REPORTING
    outputs
    RATES CONVERSION
    23 234
    How would change this query to display a table like:
    Name Amount
    RATES 23
    CONVERSION 234
    Keep up the good work !

    nikos101 wrote:
    > How would change this query to display a table like:
    Do you *HAVE* to change the query... you could just display
    it in the
    desired format if that it the ultimate and only goal.
    <table>
    <tr>
    <td>name</td>
    <td>amount</td>
    </tr>
    <cfoutput query="sumQry">
    <tr><td>Rates</td><td>#rates#</td></tr>
    <tr><td>Conversion</td><td>#conversion#</td></tr>
    </cfoutput>
    </table>

  • I need help adding a mouse motion listner to my game. PLEASE i need it for

    I need help adding a mouse motion listner to my game. PLEASE i need it for a grade.
    i have a basic game that shoots target how can use the motion listner so that paint objects (the aim) move with the mouse.
    i am able to shoot targets but it jus clicks to them ive been using this:
    public void mouse() {
    dotX = mouseX;
    dotY = mouseY;
    int d = Math.abs(dotX - (targetX + 60/2)) + Math.abs(dotY - (targetY + 60/2));
    if(d < 15) {
    score++;
    s1 = "" + score;
    else {
    score--;
    s1 = "" + score;
    and here's my cross hairs used for aiming
    //lines
    page.setStroke(new BasicStroke(1));
    page.setColor(Color.green);
    page.drawLine(dotX-10,dotY,dotX+10,dotY);
    page.drawLine(dotX,dotY-10,dotX,dotY+10);
    //cricle
    page.setColor(new Color(0,168,0,100));
    page.fillOval(dotX-10,dotY-10,20,20);
    please can some1 help me

    please can some1 help meNot when you triple post a question:
    http://forum.java.sun.com/thread.jspa?threadID=5244281
    http://forum.java.sun.com/thread.jspa?threadID=5244277

  • Need help adding schedule to xcode 4

    I need help adding a tour schedule for an iphone app building an app for 13 djs and they want thier tour schedules added these need to be updated monthly is there a way to add this????

    I don't know if this is the easiest way but it works for me. I connect the DVD player to my camcorder (so it's the 3 plugs yellow/red/white on one end and a single jack into the camera). Then I connect my camcorder to the computer (I think it's through a firewire port). Then I just play the DVD and the footage is digitized via the camcorder and I import it into iMovie 4 as it's playing. I believe the camcorder is just in VCR mode.
    I have also used this method to transfer VHS tapes onto DVDs via the camera by connecting the VCR to the camera.
    I haven't had much luck with movies over about 40 minutes on iMovie. But if it's home movies, there may be a logical break. Do maybe 20 minute segments (it's also really easy on iMovie to add a soundtrack if these are OLD films with no sound.
    As you can see, I'm low tech!
    Good luck!
    Powerbook G4   Mac OS X (10.3.9)  

  • Help adding Input language Russian on 8330

    I'm on Verizon Curve 4.3.
    Can anyone help adding Russian as input language?
    Thanks.
    Greg.
    Solved!
    Go to Solution.

    Verizon should have a multi launguage package on the website.
    If not you can go here:
    http://na.blackberry.com/eng/support/downloads/download_sites.jsp
    Make sure you get the same version that is on your phone currently so you ca maintain support.
    Let us know when you get it, and well help you load it.
    Thanks
    Click Accept as Solution for posts that have solved your issue(s)!
    Be sure to click Like! for those who have helped you.
    Install BlackBerry Protect it's a free application designed to help find your lost BlackBerry smartphone, and keep the information on it secure.

  • Adding filter conditions dynamically in WHERE clause -dynamic SQL help

    Here I have a simple condition but very complicated query. Basically, I have to put a filter condition in my where clause. "Location" comes to the stored procedure as parameter. Plus there are other parameters as well.
    If location = "all", I can run the query simply and get the result. But when Location = "CA", which is just a subset of "ALL" then I am having hard time putting one -- AND statement in WHERE clause.
    This query is designed for location = 'ALL'
    open cv for
    'Select col1, col2, col3, Col4
    from t1, t2, t3
    WHERE condition1
    AND condition2
    AND condition3'
    AND location = location_id --- This should only run if location IS NOT ALL
    I have written a dynamic query but it doesn't work for that part. Any ideas will be appreciated. Thanks,

    From what I understood
    If location = 'ALL' then
    fetch all the records
    Else
    add extra filter location_id = <supplied location id>
    End If
    If this is the condition the following logic should solve your issue.
    open cv for
    'Select col1, col2, col3, Col4
    from t1, t2, t3
    WHERE condition1
    AND condition2
    AND condition3'
    AND ((location_id = location_id and location = 'ALL') or (location_id = location))Regards
    Raj

  • Help adding new Macs to the household, creating shared drive for iTunes,

    I have a few questions:
    My husband and I recently both got MacBook Pros. Our former set-up was a iMac which backs up to a 500 G Time Capsule. We have a large iTunes library and iPhoto library on the iMac. The iMac is going to turn in to the kids computer. I would like to do the following:
    1. transfer photos to my MBP (#1). Will the Time Machine backup for the iMac become significantly smaller, making room for the soon to be larger backup of the MBP #1? Little confused how that is going to work.
    2. have shared access to iTunes library? basically it would be nice for all 3 computers to have the complete iTunes library, but I would also like to backup all 3 computers using Time Machine and don't want to have triplicates of the library. I was trying to figure out if the way to go is to put the iTunes on a shared drive on the Time Capsule, but is there a way for the 3 computers to 'sync' to the shared drive when new music is added? Finally, if the iTunes is within a shared drive does that mean it won't be backed up?
    Much appreciation and thanks to anyone who can help make sense of this.

    Update: Downloaded free version of Syncopation, and am hopeful this is going to some what solve my iTunes issue.
    New question would be: when creating the Time Machine backups for MBP#1 and MBP #2 can I NOT back up the iTunes folders? That would save approx. 36G on each of these backups, right? 72G total of the Time Capsule space. And the assumption is that with Syncopation, as long as the iMac iTunes is backed up then, you have everything.

  • Need help adding audio to a slideshow in iDVD. I don't see my playlists.

    I'm a relatively new Mac user & am trying to create my first DVD ever. I'm just learning as I go. I'm trying to create a slideshow with about 400 pictures to show at a "Going Away" Party. I've created a playlist to go along with it, but when I click on Audio & then on iTunes, it pulls up all of my songs in my whole library, but doesn't show my playlists anywhere. When I click on "help" it tells me that I should be able to go to Audio, click on iTunes, click on "library", & then find my playlist. However, I don't see "library" under iTunes. Help!

    +but is it possible to make many different slideshows on the DVD but somehow have it play automatically from one to the other+
    No. You can do that in DVD Studio Pro.
    Here's a couple of examples of how I did these projects a couple of years ago:
    *Mediterranean 2003 cruise*
    I had over 1000 images from a Mediterranean cruise. I broke them down in to 24 Albums in iPhoto (fewer than 99 images each). In iDVD, I created 6 Folders which created sub-menus. Main Menu buttons (folders/slideshows) such as Barcelona, French Riviera, Florence, Rome, Naples, Malta. Then I added each of the corresponding 24 iPhoto Albums to those 6 slideshows, thereby creating 24 total slideshows on sub-menus. Takes some planning. All slideshows had transitions and music.
    *Ireland 2004 iDVD Project*
    Nearly 800 images dragged into iDVD as organized folders from the hard drive. Transitions on each image, and menus, sub-menus, and sub-sub menus. The sub-menus are created by clicking on the Folder icon on the iDVD interface.
    Main Menu has 6 buttons: Downpatrick, Antrim Coast, Letterkenny, Sligo, Trim, and Extras. Behind each button are additional buttons ranging from 3 to 6 buttons. The Extras button goes fairly deep. When you click on Extras, it gives you 3 choices on a new menu. The "B&Bs" button opens a new menu with 5 buttons. The "Movies" button opens a new menu with 4 buttons. If you click on the "Irish Music" button, you open a new menu with 2 buttons. At that point, you are at a "sub-sub-sub menu."
    Music was on most of the slideshows. Some movies converted to QT DV from Canon S400 digicam .AVI files (iDVD 4). Now convert to H.264 with QuickTime 7. Images are original 4MP (2MB) JPEG images from the same digicam. This DVD project is around 4GB with all pictures as DVD-ROM content.

  • Complex SQL help for a

    I do not know if this is the right place for thius type of post. If it is not please advise where the right place is.
    I need help generating a report, hopefully with SQL in 8.1.7
    SQL Statement which produced the data below the query :
    SELECT CHANGE.change_number, CHANGE.route_date as DATE_TO_CCB, nodetable.description AS Approver_required, (TRIM(BOTH ',' FROM CHANGE.PRODUCT_LINES)) AS PRODUCT_LINES /*, PROPERTYTABLE.VALUE as PRODUCT_LINES */
    FROM CHANGE, signoff, workflow_process, nodetable /*, PROPERTYTABLE */
    WHERE ( (CHANGE.ID = signoff.change_id)
    AND (CHANGE.process_id = signoff.process_id)
    AND ((nodetable.id = signoff.user_assigned) or (nodetable.id=signoff.user_signed))
    AND (CHANGE.process_id = workflow_process.ID)
    AND (CHANGE.ID = workflow_process.change_id)
    AND (CHANGE.workflow_id = workflow_process.workflow_id)
    AND (SIGNOFF.SIGNOFF_STATUS=0 )/* in (0, 2, 3)) */ /* 0=request needs attention, 2=request approved, 3=request rejected */
    AND (SIGNOFF.REQUIRED=5 or SIGNOFF.REQUIRED=1) /* 1=Approver 5= Ad Hoc Approver */
    AND (CHANGE.IN_REVIEW=1)
    AND (CHANGE.RELEASE_DATE IS NULL)
    AND (CHANGE.CLASS != '4928')
    /* AND (PROPERTYTABLE.PROPERTYID IN (SELECT TRIM(BOTH ',' FROM CHANGE.PRODUCT_LINES) FROM CHANGE)) */
    order by change.route_date desc
    **** Results **********
    CHANGE_NUMBER|DATE_TO_CCB|APPROVER_REQUIRED|PRODUCT_LINES
    C02190|11/14/2008 3:34:02 PM|Anurag Upadhyay|270354,270362|
    C02190|11/14/2008 3:34:02 PM|Dennis McGuire|270354,270362|
    C02190|11/14/2008 3:34:02 PM|Hamid Khazaei|270354,270362|
    C02190|11/14/2008 3:34:02 PM|Mandy York|270354,270362|
    C02193|11/14/2008 3:05:18 PM|Hamid Khazaei|274279,266339,266340,266341|
    C02193|11/14/2008 3:05:18 PM|Rob Brogle|274279,266339,266340,266341|
    C02193|11/14/2008 3:05:18 PM|Xavier Otazo|274279,266339,266340,266341|
    C02193|11/14/2008 3:05:18 PM|san|274279,266339,266340,266341|
    C02194|11/14/2008 2:51:34 PM|Diana Young|271503|
    C02194|11/14/2008 2:51:34 PM|Carl Krentz|271503|
    C02194|11/14/2008 2:51:34 PM|Dennis Yen|271503|
    C02194|11/14/2008 2:51:34 PM|Gordon Ries|271503|
    C02194|11/14/2008 2:51:34 PM|Sunil Khatana|271503|
    M00532|11/13/2008 1:34:42 PM|Dennis Yen|270356,270354,270360,274279,266339,266340,266341,276780,260784|
    M00532|11/13/2008 1:34:42 PM|Jin Hong|270356,270354,270360,274279,266339,266340,266341,276780,260784|
    M00532|11/13/2008 1:34:42 PM|Sunil Khatana|270356,270354,270360,274279,266339,266340,266341,276780,260784|
    Each value in the numeric comma delimited string has a corresponding ID for the actual test string value in another table as shown below.
    PROPERTYID|VALUE
    260775|product 1
    260776|Product 2
    260777|Product x
    260778|Product y
    260779|Internal
    260780|ORCA
    260781|Tiger
    260782|Orange product
    260783|Restricted
    260784|Product zz
    266259|Product YYY
    266260|Hercules
    266261|Tangerine
    *****Desired output****
    CHANGE_NUMBER|DATE_TO_CCB|APPROVER_REQUIRED|PRODUCT_LINES
    C02190|Nov/14/2008 03:34:02 PM|Anurag Upadhyay, Dennis McGuire, Hamid Khazaei, Mandy York|Product Y,Product 1
    C02193|Nov/14/2008 03:05:18 PM|Hamid Khazaei, Rob Brogle, Xavier Otazo, san|Hercules,Apple,Product 3,Product zz
    C02194|Nov/14/2008 02:51:34 PM|Diana Young, Carl Krentz, Dennis Yen, Gordon Ries, Sunil Khatana|Product 2
    M00532|Nov/13/2008 01:34:42 PM|Dennis Yen, Jin Hong, Sunil Khatana|Product 1,Product 4,product yy,product YYY,ORCA,Tiger,Orange product,Restricted

    Hi,
    Here's how you can do it in Oracle 8.1.
    To get the individual sub-strings from product_lines, join your current result set to this "counter table"
    (   SELECT  ROWNUM  AS n
        FROM    all_objects
        WHERE   ROWNUM <= 10 -- upper bound on number of items
    )  cntrIf you don't know the worst case of how many items might be in product_lines, it's a little more complicated:
    (   SELECT  ROWNUM  AS n
        FROM    all_objects
        WHERE   ROWNUM <= 1 +
                SELECT  MAX ( LENGTH (product_lines)
                            - LENGTH (REPLACE (product_lines, ','))
                FROM    table_name
    )  cntrJoin this to the existing result set like this
    WHERE   ...
    AND     INSTR ( product_lines || ','    -- one extra comma added
                  , 1
                  , n
                  ) > 0When you do the join, you will have
    one copy of all the rows with one item in producgt_lines,
    two copies of all the rows with two items in producgt_lines,
    three copies of all the rows with three items in producgt_lines,
    and so on.
    When a row has been copied, each copy will have a different value of cntr.n.
    To extract the n-th substring from product_lines:
    SELECT  ...
            SUBSTR ( product_lines
                   , INSTR ( ',' || product_lines,   ',',   1,   n)
                   , ( INSTR (product_lines || ',',   ',',   1,   n)
                     - INSTR (',' || product_lines,   ',',   1,   n)
                   )  AS product_lines_itemWhen you have derived this column, you can join to the table with the translations
    WHERE  TO_NUMBER (product_lines_item) = propertyidTo combine these rows into one row with a comma-delimited list, GROUP BY all the columns you want to select except the property_value ('produc 1', 'tangerine', etv.), and SELECT:
    LTRIM ( MAX (CASE WHEN n =  1 THEN ',' || property_value END) ||
            MAX (CASE WHEN n =  2 THEN ',' || property_value END) ||
            MAX (CASE WHEN n = 10 THEN ',' || property_value END)
          )I don't know a good way to re-combine the rows in Oracle 8 without assuming some limit on the number of items. I assumed there would never be more than 10 in the example above. You can say 20 or 100, I suppose, if you want to. If you guess too high, everything will still work: the query will just be slower.
    This is a just one example of why packing several values into a single column is a bad idea.

  • SQL Report with Total Salary

    I have a select statement like this:
    Select first_name, last_name, salary From Employee
    I am getting report properly with this query. But my question is : How can get total salary at the bottom of report?
    If I crate another region with a new SQL, I could do that but I want in single SQL or PL/SQL.
    Any help would be appreciated.
    Thanks,
    Mushtak

    Hi, you can do something like this:
    Select first_name, last_name, salary From Employee
    Union
    Select null first_name, 'Total salary' last_name, Sum(salary) From Employee
    order by first_name
    Hope this helps
    George

  • [11g] adding a virtual col to a binary XML table?

    Hi
    Is it possible to add a virtual col to an existing binay XML table ?
    CREATE TABLE compagnie_binaryXML OF XMLType
    XMLTYPE STORE AS BINARY XML
    VIRTUAL COLUMNS
    (vircolcomp AS (EXTRACTVALUE(OBJECT_VALUE,'/compagnie/comp')),
    vircolnomcomp AS (EXTRACTVALUE(OBJECT_VALUE,'/compagnie/nomComp')),
    vircolnompil AS (EXTRACTVALUE(OBJECT_VALUE,'/compagnie/pilotes/pilote/nom')),
    vircolbrevpil AS (EXTRACTVALUE(OBJECT_VALUE,'/compagnie/pilotes/pilote/@brevet')));
    OK, but
    ALTER TABLE compagnie_binaryXML ADD vircolsalpil AS (EXTRACTVALUE(OBJECT_VALUE,'/compagnie/pilotes/pilote/s
    alaire'));
    ORA-22856: impossible d'ajouter des colonnes à des tables objet

    Hi
    IMHO this has nothing to do with XMLType... They simply forget to change the checks performed before adding a column... In fact, this is a "known problem" with object tables.
    SQL> create type ttt as object (n number);
      2  /
    SQL> create table t of ttt;
    SQL> alter table t add v as (to_char(n));
    alter table t add v as (to_char(n))
    ERROR at line 1:
    ORA-22856: cannot add columns to object tables
    oracle@helicon:~/ [DBA11106] oerr ora 22856
    22856, 00000, "cannot add columns to object tables"
    // *Cause:   An attempt was made to add columns to an object table. Object
    //           tables cannot be altered to add columns since its
    //           definition is based on an object type.
    // *Action:  Create a new type with additional attributes, and use the new
    //           type to create an object table. The new object table will have
    //           the desired columns.In summary, I would open an SR and let fix the problem.
    HTH
    Chris

  • Help Adding a Printer!

    I got an HP deskjet 3054 printer as part of Apple's program and I set it all up, but I cannot add it.
    I go into print and scan within system preferences, press add a printer, click on my printer, and we're all good. But then a pop up comes up saying Apple must look for a software update for the printer to be used. It looks for an update, finds it, downloads it, then installs it, and an error comes up saying my software is not available at the time.
    I've tried installing the software from HP (for OSX Lion) multiple times and from Apple too. But every time the same process happens that I have described before. I add the printer via USB. My friend has the same macbook pro and can add the printer fine so I know it's the computers fault.
    If anyone can help me that'd be totally awesome. Thanks

    I've done that too before like I already said.
    I finished installation of the drivers. As you can see.
    I follow the instructions and try to add the printer
    And instead of adding the printer it does this. Even though I just installed the software
    And installs again?

  • Need help getting totals.  does nvl(' ',0)  return a numeric 0 ?

    I am having problems trying to total some columns and I think it has to do with the sql not seeing the information as numeric.
    I created this to test. With this nvl it displays ORA-01722: invalid number
    select bcount.b1,bcount.b2,bcount.b3,acount.a1,acount.a2,acount.a3,bcount.b1 + bcount.b2 + bcount.b3 + acount.a1 + acount.a2 + acount.a3 mytot
    from
    (select 10 item,nvl(' ',0) b1,2 b2, 3 b3 from dual) bcount,
    (select 10 item,1 a1,2 a2, 3 a3 from dual) acount
    where bcount.item = acount.item
    Actual sql
    select emp.file_no,nvl(reg.regcount,0) regcount,nvl(ded.dedcount,0) dedcount,rehrg.rehrgcount,rop.ropcount,vs.vscount,
    wtc.wtccount,timeline.tlcount,hl.hlcount,addl.addcount,op.opcount,oi.oicount,opoi.opoicount,
    regcount + dedcount mtotal
    if regcount = 8 and dedcount = 0 I get blank for my mtotal.
    I think its because the nvl returns a 0 but the sql does not know this to be a number.
    What do I do?
    Howard

    I hope this helps and thanks
    results
    FILE_NO REGCOUNT DEDCOUNT REHRGCOUNT ROPCOUNT VSCOUNT WTCCOUNT TLCOUNT HLCOUNT ADDCOUNT OPCOUNT OICOUNT OPOICOUNT MTOTAL
    898989 8 - - - 8 - 8 - 4 - - - -
    sql
    select emp.file_no,reg.regcount,ded.dedcount,rehrg.rehrgcount,rop.ropcount,vs.vscount,
    wtc.wtccount,timeline.tlcount,homeless.hlcount,addl.addcount,op.opcount,oi.oicount,opoi.opoicount,
    reg.regcount + ded.dedcount mTotal
    from
    (select file_no,OU_NAME,employee_level_id from tbl_employee where file_no is not null and employee_level_id = 4) emp,
    (select tca.assign_to_ahs,case.reh_reop_id,count(*) regcount from tbl_cases case,tbl_case_assigned tca
    where case.createdate between TO_DATE(:P_from,'mm/dd/yyyy') and to_date(:P_to,'mm/dd/yyyy')
    and tca.ats_no = case.ats_no
    and case.reh_reop_id is null
    group by tca.assign_to_ahs,case.reh_reop_id) reg, -- regular
    (select tca.assign_to_ahs,case.reh_reop_id,count(*) ropcount from tbl_cases case,tbl_case_assigned tca
    where case.createdate between TO_DATE(:P_from,'mm/dd/yyyy') and to_date(:P_to,'mm/dd/yyyy')
    and tca.ats_no = case.ats_no
    and case.reh_reop_id = 1
    group by tca.assign_to_ahs,case.reh_reop_id) rop, -- rop
    (select tca.assign_to_ahs,case.reh_reop_id,count(*) rehrgcount from tbl_cases case,tbl_case_assigned tca
    where case.createdate between TO_DATE(:P_from,'mm/dd/yyyy') and to_date(:P_to,'mm/dd/yyyy')
    and tca.ats_no = case.ats_no
    and case.reh_reop_id = 2
    group by tca.assign_to_ahs,case.reh_reop_id) rehrg, --
    (select tca.assign_to_ahs,tait.issue_type_id,count(*) dedcount from tbl_aid_issue_types tait,
    tbl_cases case,tbl_case_assigned tca
    where case.createdate between TO_DATE(:P_from,'mm/dd/yyyy') and to_date(:P_to,'mm/dd/yyyy')
    and tca.ats_no = case.ats_no
    and tca.ats_no = tait.ats_no
    and issue_type_id in (46,47)
    group by tca.assign_to_ahs,tait.issue_type_id) ded,
    (select tca.assign_to_ahs,count(*) as VSCOUNT
    from tbl_cases case,tbl_case_assigned tca
    where case.createdate between TO_DATE(:P_from,'mm/dd/yyyy') and to_date(:P_to,'mm/dd/yyyy')
    and tca.ats_no = case.ats_no
    and case.VS_OTHER_CNTY_AT_LA is not null
    group by tca.assign_to_ahs) vs,
    (select tca.assign_to_ahs,count(*) wtccount
    from tbl_aid_issue_types tait,
    tbl_cases case,tbl_case_assigned tca
    where case.createdate between TO_DATE(:P_from,'mm/dd/yyyy') and to_date(:P_to,'mm/dd/yyyy')
    and tca.ats_no = case.ats_no
    and tca.ats_no = tait.ats_no
    and tait.issue_type_id = 13 -- need to change to 49
    group by tca.assign_to_ahs, tait.issue_type_id) wtc,
    (select tca.assign_to_ahs,tait.aid_type_id,count(*) tlcount
    from tbl_aid_issue_types tait,
    tbl_cases case,tbl_case_assigned tca
    where case.createdate between TO_DATE(:P_from,'mm/dd/yyyy') and to_date(:P_to,'mm/dd/yyyy')
    and tca.ats_no = case.ats_no
    and tca.ats_no = tait.ats_no
    and tait.aid_type_id = 1 -- calworks
    group by tca.assign_to_ahs,tait.aid_type_id) timeline,
    (select tca.assign_to_ahs,tait.issue_type_id,count(*) hlcount
    from tbl_aid_issue_types tait,
    tbl_cases case,tbl_case_assigned tca
    where case.createdate between TO_DATE(:P_from,'mm/dd/yyyy') and to_date(:P_to,'mm/dd/yyyy')
    and tca.ats_no = case.ats_no
    and tca.ats_no = tait.ats_no
    and tait.issue_type_id = 38 -- homeless
    group by tca.assign_to_ahs,tait.issue_type_id) homeless,
    (select tca.assign_to_ahs,count(*) addcount
    from tbl_aid_issue_types tait,
    tbl_cases case,tbl_case_assigned tca
    where case.createdate between TO_DATE(:P_from,'mm/dd/yyyy') and to_date(:P_to,'mm/dd/yyyy')
    and tca.ats_no = case.ats_no
    and tca.ats_no = tait.ats_no
    and tait.ADDTL_FILING_DATE is not null
    group by tca.assign_to_ahs) addl,
    (select tca.assign_to_ahs,tait.aid_type_id,tait.issue_type_id,count(*) opcount
    from tbl_aid_issue_types tait,
    tbl_cases case,tbl_case_assigned tca
    where case.createdate between TO_DATE(:P_from,'mm/dd/yyyy') and to_date(:P_to,'mm/dd/yyyy')
    and tca.ats_no = case.ats_no
    and tca.ats_no = tait.ats_no
    and tait.aid_type_id not in (2,3,4,5,6,7,8,9,10) -- get only 1 calworks
    and tait.issue_type_id in (53,60,70)
    group by tca.assign_to_ahs,tait.aid_type_id,tait.issue_type_id) op,
    (select tca.assign_to_ahs,tait.aid_type_id,tait.issue_type_id,count(*) oicount
    from tbl_aid_issue_types tait,
    tbl_cases case,tbl_case_assigned tca
    where case.createdate between TO_DATE(:P_from,'mm/dd/yyyy') and to_date(:P_to,'mm/dd/yyyy')
    and tca.ats_no = case.ats_no
    and tca.ats_no = tait.ats_no
    and tait.aid_type_id not in (1,3,4,5,6,7,8,9,10) -- get only 2 foodstamps
    and tait.issue_type_id in (53,60,70)
    group by tca.assign_to_ahs,tait.aid_type_id,tait.issue_type_id) oi,
    (select tca.assign_to_ahs,tait.issue_type_id,count(*) opoicount
    from tbl_aid_issue_types tait,
    tbl_cases case,tbl_case_assigned tca
    where case.createdate between TO_DATE(:P_from,'mm/dd/yyyy') and to_date(:P_to,'mm/dd/yyyy')
    and tca.ats_no = case.ats_no
    and tca.ats_no = tait.ats_no
    and tait.aid_type_id not in (3,4,5,6,7,8,9,10) -- get only 1 and 2 foodstamps and calworks
    and tait.issue_type_id in (53,60,70)
    group by tca.assign_to_ahs,tait.issue_type_id) opoi
    where emp.OU_NAME = reg.assign_to_ahs(+)
    and reg.assign_to_ahs = rop.assign_to_ahs(+)
    and reg.assign_to_ahs = rehrg.assign_to_ahs(+)
    and reg.assign_to_ahs = ded.assign_to_ahs(+)
    and reg.assign_to_ahs = vs.assign_to_ahs(+)
    and reg.assign_to_ahs = wtc.assign_to_ahs(+)
    and reg.assign_to_ahs = timeline.assign_to_ahs(+)
    and reg.assign_to_ahs = homeless.assign_to_ahs(+)
    and reg.assign_to_ahs = addl.assign_to_ahs(+)
    and reg.assign_to_ahs = op.assign_to_ahs(+)
    and reg.assign_to_ahs = oi.assign_to_ahs(+)
    and reg.assign_to_ahs = opoi.assign_to_ahs(+)
    and emp.file_no = '898989'
    order by emp.file_no
    Edited by: csphard on May 9, 2009 8:36 PM

  • Help adding to an array

    Hello,
    I've added an Add button to a GUI. This feature should enable users to add itemName, numberUnitsStock, unitPrice, and itemNumber(one more than the previous last item). Can anyone help? I'm thinking that I need to extend the array size first and then figure a way to get the aforementioned included in the array. Any help would be greatly appreciated.
    public class DVD6
              protected int itemNumber; // item number
              protected String itemName; // name of product
              protected int numberUnitsStock; // number of units in stock
              protected double unitPrice; // price of each unit
            // constructor initializes DVD with int, String, and double as argument
            public DVD6 (int itemNumber, String itemName, int numberUnitsStock, double unitPrice)
            this.itemNumber = itemNumber; // initializes itemNumber
              this.itemName = itemName; // initializes itemName
              this.numberUnitsStock = numberUnitsStock; // initializes numberUnitsStock
              this.unitPrice = unitPrice; // initializes unitPrice
              } // end constructor
                // method to set the item number
              public void setitemNumber (int itemNumber)
              itemNumber = itemNumber; // store the item number
              } // end method setitemNumber
                // method to retrieve the item number
            public int getitemNumber()
            return itemNumber;
            } // end method getitemNumber
            // method to set the name of product
                public void setitemName (String itemName)
                itemName = itemName; // store the name of product
                } // end method setitemName   
                // method to retrieve the itemName
            public String getitemName()
            return itemName;
            } // end method getitemName
            // method to set the number of units in stock
                public void setnumberUnitsStock (int numberUnitsStock)
                numberUnitsStock = numberUnitsStock; // store the number of units in stock
                } // end method setnumberUnitsStock   
                // method to retrieve the number of units in stock
            public int getnumberUnitsStock()
            return numberUnitsStock;
            } // end method getnumberUnitsStock
            // method to set the price of each unit
                public void setunitPrice (double unitPrice)
                unitPrice = unitPrice; // store the price of each unit
                } // end method setunitPrice   
                // method to retrieve the price of each unit
            public double getunitPrice()
            return unitPrice;
            } // end method getunitPrice
                // method to retrieve the inventoryValue
                public double getinventoryValue()
                return (numberUnitsStock * unitPrice); // multiply numbers
                } // end method getinventoryValue   
                // method to get the value of entire inventory
                public static double getTotalValueOfAllInventory (DVD6 [] inv)
                   double tot = 0.0;
                     for (int i = 0; i < inv.length; i++)
                        tot += inv.getinventoryValue();
                   return tot;
              } // end method getTotalValueOfAllInventory
              public static DVD6[] sort(DVD6 [] inventory)
              DVD6 temp[] = new DVD6[1];
                   // sort
                   for (int j = 0; j < inventory.length - 1; j++)
                   for (int k = 0; k < inventory.length - 1; k++)
                        if (inventory[k].getitemName().compareToIgnoreCase(inventory[k+1].getitemName()) > 0 )
                             temp[0] = inventory[k];
                                  inventory[k] = inventory[k+1];
                                  inventory[k+1] = temp[0];
                             } // end if
                        } // end for
              } // end for
              return inventory;
              public String toString()
              StringBuffer sb = new StringBuffer();
                   sb.append("Item number: \t").append(itemNumber).append("\n");
                   sb.append("DVD Title: \t").append(itemName).append("\n");
                   sb.append("Units in stock: \t").append(numberUnitsStock).append("\n");
                   sb.append("Price of unit: \t").append(String.format("$%.2f%n", unitPrice));
                   sb.append("Inventory value of product: \t").append(String.format("$%.2f%n", getinventoryValue()));
                   return sb.toString();
    } // end class DVD6
    public class DVDs6 extends DVD6
        private String genre; // genre of DVD
          private double restockingFee; // percentage added to product's inventory value
           //constructor
         public DVDs6(String genre, int itemNumber, String itemName,
                     int numberUnitsStock, double unitPrice)
               super(itemNumber, itemName, numberUnitsStock, unitPrice);
              this.genre = genre;
         // method to set the genre of DVD
         public void setgenre (String genre)
         genre = genre; // store the genre
         } // end method setgenre
         // method to retrieve the genre
         public String getgenre()
         return genre;
         } // end method getgenre
         // method to retrieve the restockingFee
         public double getrestockingFee()
         return (super.getunitPrice() * 0.05);
         } // end method getrestockingFee   
         // Inventory value + restocking fee
         public double getinventoryValue()
            return super.getinventoryValue() + (super.getunitPrice() * 0.05);
         // String representation
         public String toString()
            StringBuffer sb = new StringBuffer();
              sb.append("DVD Genre:   \t").append(genre).append("\n");
              sb.append("Restocking fee:   \t").append(String.format("$%.2f%n", getrestockingFee()));
              sb.append(super.toString());
              return sb.toString();
    } // end class
    import java.awt.*;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import javax.swing.*;
    public class DVD6Test
         static int itemDisplay = 0; // ActionEvent variable 
         // main method begins execution of Java application  
       public static void main ( String args[] )
              double total = 0; // variable to get entire inventory value
              JPanel bttnJPanel; // panel to hold buttons
              JLabel label; // JLabel for company logo
              // instantiate object     
          final DVDs6[] a = new DVDs6[5];
          a[0] = new DVDs6("Action/Drama" , 041, "Rocky", 20, 15.00);
          a[1] = new DVDs6("Action" , 006, "Braveheart", 20, 20.00);
          a[2] = new DVDs6("Action" , 001, "Armageddon", 10, 10.00);
          a[3] = new DVDs6("Action" , 060, "Scarface", 15, 18.00);
          a[4] = new DVDs6("Action" , 021, "Goodfellas", 5, 15.00);
          DVDs6 temp[] = new DVDs6[1];
          // sort
          for (int j = 0; j < a.length - 1; j++)
             for (int k = 0; k < a.length - 1; k++)
                if (a[k].getitemName().compareToIgnoreCase(a[k+1].getitemName()) > 0 )
                   temp[0] = a[k];
                   a[k] = a[k+1];
                   a[k+1] = temp[0];
                } // end if
             } // end for
          } // end for
              // value of entire inventory
              for (int i = 0; i < a.length; i++)
                        total += a.getinventoryValue();
              // setup buttons
              JButton firstBtn = new JButton("First"); // button to display first inventory item
              JButton prevBtn = new JButton("Previous"); // button to display previous inventory item
              JButton nextBtn = new JButton("Next"); // button to display next inventory item
              JButton lastBtn = new JButton("Last"); // button to display last inventory item
              JButton addBtn = new JButton("Add"); // button to add item to inventory
              JButton delBtn = new JButton("Delete"); // button to delete item from inventory
              JButton modBtn = new JButton("Modify"); // button to modify DVD item
              JButton saveBtn = new JButton("Save"); // button to save inventory to a .dat file
              JButton srchBtn = new JButton("Search"); // button to search for item by name
              // create and setup panel to hold buttons
              bttnJPanel = new JPanel();
              bttnJPanel.setLayout(new GridLayout(1, 4));
              bttnJPanel.add(firstBtn);
              bttnJPanel.add(prevBtn);
              bttnJPanel.add(nextBtn);
              bttnJPanel.add(lastBtn);
              bttnJPanel.add(addBtn);
              bttnJPanel.add(delBtn);
              bttnJPanel.add(modBtn);
              bttnJPanel.add(saveBtn);
              bttnJPanel.add(srchBtn);
              //JLabel constructor
    Icon logo = new ImageIcon("C:/logo.jpg"); // load graphic
    label = new JLabel(logo); // create logo label
    label.setText("Java Solutions Inc."); // set company name          
              // text area and frame setup for product display
              final JTextArea textArea;      
              textArea = new JTextArea(a[0] + "\n");           
              textArea.append("\nValue of entire inventory: " + new java.text.DecimalFormat("$0.00").format(total) + "\n\n");
              textArea.setEditable(false); // uneditable text
              JFrame dvdFrame = new JFrame(); // JFrame container
              dvdFrame.setLayout(new BorderLayout()); // set layout
              dvdFrame.getContentPane().add(new JScrollPane(textArea), BorderLayout.CENTER); // add text area to frame
              dvdFrame.getContentPane().add(bttnJPanel, BorderLayout.SOUTH); // adds buttons to frame
              dvdFrame.getContentPane().add(label, BorderLayout.NORTH); // add company logo to JFrame
              dvdFrame.setTitle("DVD Inventory"); // title of frame
              dvdFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // terminate upon close
              dvdFrame.setSize(800, 575); // set size
              dvdFrame.setLocationRelativeTo(null); // set location
              dvdFrame.setVisible(true); // display the window     
         // inner class to handle button events
    firstBtn.addActionListener(new ActionListener() // register event handler
    public void actionPerformed(ActionEvent event) // process button event
    itemDisplay = 0;
    textArea.setText(a[itemDisplay] + "\n");
              prevBtn.addActionListener(new ActionListener() // register event handler
    public void actionPerformed(ActionEvent event) // process button event
                   --itemDisplay;
                        if (itemDisplay < 0)
                        itemDisplay = (itemDisplay + a.length) % a.length;
                        textArea.setText(a[itemDisplay]+"\n");
              nextBtn.addActionListener(new ActionListener() // register event handler
              public void actionPerformed(ActionEvent event) // process button event
                        itemDisplay++;
                        if (itemDisplay >= a.length)
                        itemDisplay = (itemDisplay) % a.length;
                        textArea.setText(a[itemDisplay]+"\n");     
              lastBtn.addActionListener(new ActionListener() // register event handler
              public void actionPerformed(ActionEvent event) // process button event
                   itemDisplay = a.length-1;
                        textArea.setText(a[itemDisplay]+"\n");
              addBtn.addActionListener(new ActionListener() // register event handler
              public void actionPerformed(ActionEvent event) // process button event
                        DVDs6[] as = new DVDs6[a.length + 1]; // increase array length
                        textArea.setText(new String());
         } // end method main          
    } // end class

    check this link,
    http://www.java2s.com/Tutorial/Java/0140__Collections/0160__ArrayList.htm
    U have lot of collections. always user like this
    List user=new ArrayList();
    user.add("username");
    This code helps u to make changes in future. In future, if u want to change from ArrayList to Vector then u can just easily make a modification like this.
    List user=new Vector();
    user.add("username");
    need to make changes only in the declaration part.

  • Query help on totalling 2 account balances

    Hi Experts,
    I have the following query:
    SELECT SUM(T0.[SYSDeb] - T0.[SYSCred]) AS 'Production'
    FROM JDT1 T0  INNER JOIN OJDT T1 ON T0.TransId = T1.TransId WHERE T0.[Account] = '_SYS00000000238' AND T0.[Account] = '_SYS00000000239'
    If I add the second WHERE statement the query gives me no results. I want to see the total of the 2 account balances in this query.
    Any help would be appreciated.
    Marli

    Hi Marli,
    Try this:
    SELECT SUM(T0.SYSDeb  - T0.SYSCred) AS 'Production'
    FROM JDT1 T0
    WHERE T0.Account in ('_SYS00000000238','_SYS00000000239')
    Thanks,
    Gordon

Maybe you are looking for

  • Title bar of standard page come with German, how to change to English

    Hi Experts,     I am creating an page contain an WebdynPro ABAP. When user click link in the WD it will pop up new browser for standard appraisal document provided by SAP. The problem is the title bar of the pop up come with German. So i have checked

  • HT1923 Cannot uninstall Apple Mobile Device Support

    It begins to uninstall, then seems to reverse itself?  I can uninstall all other pieces of iTunes?

  • Switch between % and px

    It would be great to have a shortcut that would convert positioning of the object from % to px and vice versa. Ideally would be good to choose if you want the default value to be % or px when adding new objects.

  • Mobile Flash Design / Flash Lite Workshop in San Francisco

    Hello, I will be running the Flash Design for Mobile Devices workshops this Spring: in San Francisco: 2 days, Saturday, May 10th & 17th, 10am — 5pm All mobile Flash development will be covered while emphasis will be placed on Flash Lite development f

  • Issue with Maintenence View generated using SE54

    Hello all, We generated a view V_T16FC with the tables T16FC T16FD T16FG when we try to see the data in the view , it is saying no data in the view , though the data is ther in all the three tables . I checked foreign key relations they are fine . ca