How to do sum when using union

hi,
i am getting following example data from a query
which uses UNION which is mandatory.
is there a way to do sum of Units column to get a single
row ?
hire date units
01.08.2003 1,00
01.08.2003 12,50
like to see as a single row
01.08.2003 13,50
rgds,
Karna

SELECT hire_date, SUM(units) units
FROM (SELECT hire_date, units
      FROM table1
      UNION ALL
      SELECT hire_date, units
      FROM table2)
GROUP BY hire_dateTTFN
John

Similar Messages

  • How to retrieve character '#' when use Shift key + 3 instead of use Option key + 3?

    Hi everyone,
    Kindly advice how to retrieve character '#' when use Shift key + 3 instead of Option key + 3.
    Thank you in advance.

    Hi Tom,
    Thanks for your proposed solution. The problem has been solved.

  • Query takes long when using UNION

    Hi ,
    I habe a query as follows;
    SELECT
                        '9999' site_id,
                        m.ghi_prov_num provnum,
                           SUBSTR (l.seq_num, 1, 3)provloc,
                        t.dea_number dea,
                            t.license_number statelicensenumber ,
                            n.npi_num npi,
                            m.prefix prefixname,
                            m.lastname lastname,
                            m.firstname firstname,
                            t.middle_name middleinitial,
                            m.suffix suffixname,
                            null clinicname,
                            l.street1 addressline1,
                            l.street2 addressline2,
                            l.city city,
                            l.state state,
                            l.zip5 zip,
                            l.phone phoneprimary,
                            null ext,
                            null fax,
                            null email,
                            null alt_phone,
                            null alt_phone_ext
                     FROM provider m, LOCATION l, npi n,TEMP_VITAL_CACTUS t,test_provider_pin pin
                      WHERE m.ghi_prov_num=l.ghi_prov_num
                          and m.ghi_prov_num=n.ghi_prov_num(+)
                          and m.ghi_prov_num=t.ghi_prov_num(+)
                          and m.tax_id=pin.tax_id
         UNION
          SELECT   
                        '9999', m.ghi_prov_num ,
                            m.location provloc,
                           null  ,
                           null  ,
                            n.npi_num  ,
                            null ,
                            m.lastname ,
                            m.firstname  ,
                            null,
                            null  ,
                            null  ,
                            m.street1  ,
                            m.street2  ,
                            m.city ,
                            m.state  ,
                            m.zip5 ,
                            m.phone  ,
                            null  ,
                            null  ,
                            null  ,
                            null  ,
                            null
                           FROM dental_provider m, npi n,test_provider_pin pin
                       WHERE m.ghi_prov_num=n.tax_id(+)
                           and m.location=n.location(+)
                            and pin.tax_id=m.ghi_prov_num;The query takes for ever;
    But Individual query takes less than a sec to execute.Is there any way can i rewrite the query?
    Please help
    Hena.

    user11253970 wrote:
    But Individual query takes less than a sec to execute.Is there any way can i rewrite the query?Have a feeling you are using Toad/SQL Navigator or similar tool which returns data one screen at a time. If so, then it does not "takes less than a sec to execute" but rather to fetch first screen of rows. When you use UNION Oracle has to return distinct rows from both queries. Therefore it must fetch not just first screen but all rows. To verify, issue first query and in yiour GUI tool click on get last screen. Then you'll know how long whole select takes. Do the same for second query. Also, do you need distinct rows or akll rows? IF all rows, change UNION to UNION ALL.
    SY.

  • HT1495 how to delete apps when using one account for iphone 4s and ipod4, can delete from phone but not ipod

    How do we delete apps from ipod 4 when using same account as iphone 4s, we can delete from the phone but not the ipod, and when i get an app on my phone it automatically comes up on the ipod and visa versa, now ipod is full,

    Read the article from which the thread was posted, it clearly defines how to use multiple iDevices on a single computer.
    Sharing an Apple ID is not an issue.

  • K3011w - How disable the touchpad when using USB mouse?

    Is there a way to disable the touchpad on the docking keybd when using a USB mouse? It is a real pain typing along and be in the middle of sentence some where else on the page.

    hi whippetguy,
    Thanks for Posting,
       The touchpad on the dock uses a Windows driver and does not have any special Software to Disable it via shortcut,
    How I found to go around on what you need is
      With the tablet on the dock with no USB mouse yet
                      Press (Windows key+x) and choose device manager on the list
                            On Device Manager window open mice and pointing device and rightclick disable
    This should disable the dock touchpad and Now you can plu in your USB mouse,
    Before you unplu your USB mouse after use, Go to device manager again and Enable the device you disabled.
    Hope this helps
    Cheers!
    Did someone help you today? Press the star on the left to thank them with a Kudo!
    If you find a post helpful and it answers your question, please mark it as an "Accepted Solution"! This will help the rest of the Community with similar issues identify the verified solution and benefit from it.
    Follow @LenovoForums on Twitter!

  • Drill down problem when using union all combination

    Hi All,
    I have a simple report with a drill down. The report has three columns Region, Sales, Flag... which will drill down to detail level of sales. The Flag column has Y, N values and we added 'All' Value in flag so that the user can select Y, N and All from the table prompt in the report . We have used union all in the report using combination to add the ' All ' Value in the flag. The problem is that now the main report is not passing the Flag values to the detail report. Flag is prompted in the filter in detail report.
    If I remove the 'All' value from Analysis with only Y N selection criteria the drill down works.
    Is there any work around? I have to use table prompt and All value selection in flag for drill down.
    Thanks,
    Virat

    The problem is without union all when doing combination of analysis drill down works, when I use combination drill down does not work because it does not pass the parameters for flag . I have used union all to add All value in flag.

  • How to suppress SCHEMA_OWNER when using DBMS_METADATA.GET_DDL

    Hi,
    I was wondering, is it possible to suppress the owner when using dbms_metadata.get_ddl?
    SQL> select * from v$version where rownum = 1
    BANNER                                                         
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    SQL> exec dbms_metadata.set_transform_param (dbms_metadata.session_transform,'SEGMENT_ATTRIBUTES',false)
    SQL> select dbms_metadata.get_ddl('TABLE','EMP') from dual
    DBMS_METADATA.GET_DDL('TABLE','EMP')                                           
      CREATE TABLE "SCOTT"."EMP"                                                   
       (     "EMPNO" NUMBER(4,0) NOT NULL ENABLE,                                      
         "ENAME" VARCHAR2(10),                                                         
         "JOB" VARCHAR2(9),                                                            
         "MGR" NUMBER(4,0),                                                            
         "HIREDATE" DATE,                                                              
         "SAL" NUMBER(7,2),                                                            
         "COMM" NUMBER(7,2),                                                           
         "DEPTNO" NUMBER(2,0)                                                          
       )I would like to get rid of the "SCOTT". Alternatively to change it into something else.
    Is that possible, without post processing the output, that is?
    Regards
    Peter

    Hi Karthick,
    I was afraid that would be the answer. It can be done, but it seems rather convoluted:
    SQL> create or replace function get_table_ddl(table_name    varchar2
                                            ,schema        varchar2 default user
                                            ,new_owner     varchar2 default null)
       return clob
    is
       v_handle        number;
       v_transhandle   number;
       v_ddl           clob;
    begin
       v_handle := dbms_metadata.open('TABLE');
       dbms_metadata.set_filter(v_handle, 'SCHEMA', schema);
       dbms_metadata.set_filter(v_handle, 'NAME', table_name);
       v_transhandle := dbms_metadata.add_transform(v_handle, 'MODIFY');
       dbms_metadata.set_remap_param(v_transhandle,'REMAP_SCHEMA',schema,new_owner);
       v_transhandle := dbms_metadata.add_transform(v_handle, 'DDL');
       dbms_metadata.set_transform_param(v_transhandle,'SEGMENT_ATTRIBUTES',false);
       v_ddl := dbms_metadata.fetch_clob(v_handle);
       dbms_metadata.close(v_handle);
       return v_ddl;
    end;
    Function created.
    SQL> select get_table_ddl('EMP') from dual
    GET_TABLE_DDL('EMP')                                                           
      CREATE TABLE "EMP"                                                           
       (     "EMPNO" NUMBER(4,0) NOT NULL ENABLE,                                      
         "ENAME" VARCHAR2(10),                                                         
         "JOB" VARCHAR2(9),                                                            
         "MGR" NUMBER(4,0),                                                            
         "HIREDATE" DATE,                                                              
         "SAL" NUMBER(7,2),                                                            
         "COMM" NUMBER(7,2),                                                           
         "DEPTNO" NUMBER(2,0)                                                          
    1 row selected.Regards
    Peter

  • How to prevent email when using find my iphone

    Hi there,
    Am I the only that finds the email confirmations annoying when using find my iPhone?
    Is there any way to prevent these emails, or a preference somewhere to turn them off?

    Apple:
         Considering the threads here and on other Internet sites, this is clearly a safety issue.  As a parent who uses this feature on my children's phone - this feature should be optional.  Notifying the bad guy when you are searching for your phone/child is not an option.  Thank you.

  • Cannot export query output when using UNION ALL

    Hi
    I can run a query in SQL Developer 1.5.5 and if it's a SELECT statement it works fine, but if I output the result of several SELECT statements using UNION ALL after some 10,000 records the SQL Developer crashes and it generates a file whose size is 0 kb
    Is there a workaround for this??
    Thanks and Regards!
    Isaac

    Should be fixed in the upcoming 2.1... you can try the RC1 also...
    Regards,
    K.

  • How to define range when using oo environment

    Hi all,
    I have a doubt regarding this when using OO:
    DATA: spfli_wa TYPE spfli,
          r_carrid TYPE RANGE OF spfli-carrid,
          r_carrid_line LIKE LINE OF r_carrid.
    Is there a structure I can do "type" for the work-area?
    Thanks in advance,
    Edited by: orgasmics on Sep 9, 2010 9:23 PM

    Hello,
    if you maintain or develop your class in transaction SE24 for example, then you will find a button Local Types in the Icon Bar.
    Click on it and define a Type range.
    E.g.
    TYPES : rnge_bukrs TYPE RANGE OF bukrs.
    TYPES : rnge_line TYPE LINE OF rnge_bukrs.
    That will create a range table type and a structure of the same type.
    You can use these types in any data statements of any method in that class or attribute of your your class or interfaces of your methods.
    Hope that is what you are looking for.
    Cheers

  • How is image resampled when using Crop Tool Presets?

    If I use the Crop Tool preset of 4 X 6 inches on a 8 X 10 inch image of the same resolution, what type of interpolation does PS use to reduce the image size? I am reducing the size of a finished multilayered file to insert it into a greeting card template.
    I know that when using the Image Size dialogue, you can choose whatever type of image interpolation you want, like bicubic sharper for reducing the size of an image. Can you do the same with the Crop Tool? Thanks.

    chris -
    could this be included in the option bar to change the resampling per instance instead of a prefs setting?  I set up some actions to change the prefs for up and down scaling and then revert to the default pref setting. But it was never convenient so I don't use the actions.
    or maybe just and pref to use "smart scaling" that chooses the interpolation method based upon whether it is up or down scaling.
    j

  • Sum of a sum when using Top N in the Group Sort Expert

    Hi All,
    I have a small problem I can't quite seem to work out.
    I have a report where each line is for a particular Product, and is a summation of the Sales for that Product over several Locations. When you click on the line, it shows the breakdown of Sales over each Location.
    I use the Group Sort Expert to display the Top N results, where the 'N" is set in a formula to a parameter passed in to the report, so the user can select the top 5,10,50 etc. Products across all Locations.
    At the bottom of the report, I want to have a sum of a column of Sales $. I need that sum to only be a sum of the Top N records selected.
    Since each line is a summation of the all the products for the Locations, what I need is a sum of that sum for the Top N, but Crystal will not let you add the sum of a sum, so I'm not sure how to accomplish this.
    If I just do a sum of the underlying values I get a total for all the Products, regardless of the Top N.
    Hope that makes some sense !
    Many Thanks
    Paul

    Hi Sastry,
    I tried your suggestion, thanks, but I don't think it's the answer. For a start Crystal will not let me do that, it pops up a message box when I try to run the report "A running total cannot refer to a print time formula. Details: Record Number". I also added the record number field next to the lines in the report to see what the result would be, and I don't think it would work anyway.
    Here is an example using Units sold:
    Product Name--LocationUnits Sold--Record Number
    Product A -<All Stores>----8
    Store A--1--
    1
    Store B--3--
    2
    Store C--4--
    3
    Product B--<All Stores>--3      
    Store A--2--
    4
    Store B--1--
    5
    Product C--<All Stores>--
    1
    Store A--1--
    6
    Note that only the bold lines are shown in the report,. If you click on the bold line, then the breakdown of the stores is shown. For the above example, I am showing the Top 2 units across all stores (so Product C is not shown at all), but there are actually 5 records, so if I used a formula where RecordNumber <=N, where in this case N=2, I would get a total units sold of 1 + 3 (records 1 and 2) which is incorrect.
    I will have more of a think on this and see if I can find a solution, in the mean time, any other suggestions ? Is there some wya of checking if the line is visible maybe ?
    Thanks for your time !
    Paul

  • How to smooth text when using 720p HDTV as monitor?

    I know I'm not using the best choice for a Monitor, but want to tweak it the best I can.
    Sony Bravia BX 320, 720P TV as my monitor
    New Mac Mini bought yesterday
    1080P Display Setting in Mini's display profiles
    720P ibid
    Connected via HDMI
    Have tried tweaking around with different Mac Display profiles and color calibrations. Above look the best as far as resolution and picture when sitting far away from screen.
    Closer I get to screen, the more pixelated and crappy the text looks, which is really bad
    What are the tweakablle settings, both in the monitor and computer I would want to play with to smooth the text out as best as is possible given my monitor choice?
    What would be a better "TV" choice to use as a monitor for my Mini? I only run a Roku and OTA HDTV into the TV tuner.
    Is there a choice that looks good in both TV and Mini monitoring applications?
    Thanks so much.

    I have never used any of this, I have never needed to use it. I just know that the information is around and has been useful to others.
    I also saved this tutoial that I found once. Perhaps it can help you;
    SwitchResX Tutorial
    0. All of this is easier to do if you have a portable Mac, since you can configure the external display while viewing everything on the built-in display. You can do it with only the external display (your big TV, that is), but it's tedious.
    1. Get the proper cable to connect your Mac to the display (VGI, DVI, or DVI->HDMI, depending on your display's inputs; if you're using a portable Mac with only mini-DVI you'll need the adapter *and* a cable).
    2. Connect the display and turn on the Mac. Launch the SwitchResX Control application (if all you're doing is setting up a custom configuration, you don't need the preference pane and thus don't need APE either).
    3. In the SwitchResX Control application, select the display you want to configure in the "Settings of:" menu (if it isn't selected already) and click the "Display" tab. Then click the "Export DDC" button and select a location to save the file.
    4. Using the text editor of your choice (TextEdit works, or you may have a preference for something else) open that file you just exported. You should see at least one Monitor Description Block (mine has two, labeled Descriptor #0 and Descriptor #1). This should give you a starting point. Mine looks like this:
    Code:
        Descriptor #0 is Timing definition:
        Mode = 1920 x 540 @  60Hz
            H. Active...............1920 pixels
            H. Blanking.............280 pixels
            V. Active...............540 lines
            V. Blanking.............22 lines
            HSync Offset............88 pixels
            HSync Pulse Width.......44 pixels
            VSync Offset............2 lines
            VSync Pulse Width.......5 lines
            Pixel Clock.............74.25MHz
            Horizontal freq.........33.75kHz
            Vertical freq...........60.05Hz
            H Image Size............16mm
            V Image Size............9mm
            H Border................0 pixels
            V Border................0 lines
                Interlaced
                Sync: Digital separate with
                    * Positive vertical polarity
                    * Positive horizontal polarity
    Note that the Mode is described as 1920 x 540 @ 60Hz, interlaced. It's actually 1920 x 1080, interlaced. I'm not sure why the vertical resolution is half what it should be there, but that's an important detail to note. If yours looks like it's half what it should be, you'll have to double it below. Use your common sense here.
    The next step depends on what problem you need to solve. If you have a picture and you just need to adjust its position and/or size, you have the easier task and these instructions can help you. If you don't have a picture at all, the values provided by your display are invalid, and you'll have to do some research to find valid values (I can't help you find them). Search and/or ask on this forum, and also try Google.
    5. Click on the "Custom" tab in the SwitchResX Control app. Click the "+" button to create a new resolution. Select "Custom" in the menu at the top (as opposed to "Scaled"). Start by entering the values in the Monitor Description Block you exported and opened in a text editor. The thing to realize as you get started is that all the numbers interact with each other, and as you change one value the application will recalculate the others if they're affected by the change. At a given resolution, the number of horizontal pixels and the number of vertical lines in each box always have to add to the same totals, and you can get those values by adding the "Active" and "Blanking" values in the Monitor Timing Block. To stick with my display, the horizontal pixel values must add up to 2200 (1920 (H. Active) + 280 (H. Blanking)), and the vertical line values must add up to 1124 (2 * (540 (V. Active) + 22 (V. Blanking))). The horizontal and vertical scan rates are calculated using those total values and the pixel clock value.
    This is a very important concept to understand. With a constant pixel clock value and constant totals of Active + Blanking in both axes, the scan rates should also remain constant. If you have changed your active, porch, or sync width values and the scan rates don't add up, you won't get any picture. To use my display as an example again:
    Code:
    Pixel Clock 74.25 Mhz, Interlaced
                Horizontal      Vertical
    Active:     1920 pixels     1080 lines
    Frt. porch: 88 pixels       4 lines
    Sync width: 44 pixels       10 lines
    Back porch: 148 pixels      30 lines
    Scan rate:  33.75 kHz       60.05 Hz
    Note that 1920 + 88 + 44 + 148 = 2200, and 1080 + 4 + 10 + 30 = 1124.
    6a. Adjust the values to fit your display (heh). This is the trial-and-error portion of the task, and is also slightly counterintuitive. You can get an idea of the adjustments you need to make if you use DisplayConfigX to display an "Image Size Test" (in the "Test Screen" tab). It'd make life easier if that were built into SwitchResX, but anyway:
    If you need to shrink the visible area, decrease the Active value and increase the front or back porch values by the same amount. If you need to increase it, do the opposite. It helps to work incrementally (say, by multiples of 8) and save and test your work as you go along. Note that you may not actually need to restart the computer: I found that I could just unplug the HDMI cable from the back of my display and plug it back in, and the new settings would take effect. Remember to click "OK" (and not "Cancel") in the Timing Parameters window, then "Apply" in the main window, before you do this, or before you reboot. Otherwise your changes will be lost.
    The porch values are counterintuitive. The horizontal "front porch" is the right edge of the screen (not the left as you might expect); the vertical "front porch" is the bottom edge of the screen. To move the image to the right, decrease the horizontal front porch and increase the horizontal back porch; to move it to the left increase the front porch and decrease the back porch. To move the image up, increase the vertical front porch and decrease the back porch, to move it down, decrease the front porch and increase the back porch. Again, it helps to save and restart or disconnect/reconnect the display to test these adjustments. The "Quick change" buttons in the bottom right-hand corner of the Timing Parameters window will adjust the porches for you, but note that in older versions the buttons were reversed (down means up and left means right, if you catch my drift). That's been fixed in version 3.7.6, apparently.
    Also, remember as you adjust porch values that you shouldn't ever need to change the sync width.
    6b. You know how I said you might not need to restart the computer? That's not actually 100% true for some displays. When I boot my computer with the display connected, the image is shifted to one side. If I subsequently change resolutions in software or disconnect and reconnect the display, the image will shift back. I got around this problem by first coming up with a configuration that was properly aligned after such a switch. After I had that I rebooted and estimated how far the image was shifted to one side. I then adjusted the porch values, saved, rebooted, and tested again. I now have two configurations, one for "fresh boot" that's adjusted for that sideways shift, and one I can use if I've changed the resolution for some reason. After all that, my default settings are now:
    Code:
    Pixel Clock 74.25 Mhz, Interlaced
                Horizontal      Vertical
    Active:     1834 pixels     1024 lines
    Frt. porch: 120 pixels      40 lines
    Sync width: 44 pixels       10 lines
    Back porch: 202 pixels      50 lines
    Scan rate:  33.75 kHz       60.05 Hz
    Again, 1834 + 120 + 44 + 202 = 2200, and 1024 + 40 + 10 + 50 = 1124. The Pixel Clock and both scan rates are the same as I found in the DDC.
    Note also that if you have the same sideways shift problem, your two resolutions can't be identical (the system won't know which one to select). I made mine different by two pixels of horizontal resolution, which turns out to be rounded off in practice anyway (so one's 1832 x 1024, and the other's 1834 x 1024, with porch values adjusted accordingly, but they both look the same).
    At this point you should be able to align your desktop to your display by iterating through these steps, applying your changes, and either disconnecting and reconnecting the display or rebooting.
    7. If ever you go horribly wrong and go from having a misaligned picture to having no picture at all, you'll have to delete the override installed by SwitchResX. Boot the computer into Safe Mode, launch the SwitchResX Control app again, and click the "Factory settings" button, then the "Apply" button, and reboot.
    And as a preemptive strike: no, I probably don't own your display and don't know the numbers for it offhand, and my consulting rate is $45/hr (really!). 
    Copyright Fedward. All rights reserved, all wrongs reversed.

  • How to publish changes when using a personal domain

    Hi,
    I am about to publish my first website using MobileMe but with a personal domain.
    I have learned how to publish the site for the first time using File>Set up personal domain but what do I use when I want to publish any changes ?
    Do I use the File>Publish to MobileMe option or some other method ?
    Thank you

    f1stevef wrote:
    Do I use the File>Publish to MobileMe option...?
    Yes. You can read more about using personal domains with iWeb here.

  • How to back up when using Disk Utility off the DVD

    Hello. i ran into some problems installing snow leopard and can't get back into 10.5. i can only boot into my windows partition. how would i go about creating a back up from Disk Utility being run off of the installation dvd?

    If your OS X partition cannot be accessed then you may not be able to back it up. If you have another computer with FireWire then you can try booting the computer into Target Disk Mode. If you can access the drive from the other computer, then you can try recovering your files. Otherwise see the following:
    Basics of File Recovery
    Files in Trash
    If you simply put files in the Trash you can restore them by opening the Trash (left-click on the Trash icon) and drag the files from the Trash to your Desktop or other desired location. OS X also provides a short-cut to undo the last item moved to the Trash -press COMMAND-Z.
    If you empty the Trash the files are gone. If a program does an immediate delete rather than moving files to the Trash, then the files are gone. Recovery is possible but you must not allow any additional writes to the hard drive - shut it down. When files are deleted only the directory entries, not the files themselves, is modified. The space occupied by the files has been returned to the system as available for storage, but the files are still on the drive. Writing to the drive will then eventually overwrite the space once occupied by the deleted files in which case the files are lost permanently. Also if you save a file over an existing file of the same name, then the old file is overwritten and cannot be recovered.
    General File Recovery
    If you stop using the drive it's possible to recover deleted files that have not been overwritten with recovery software such as Data Rescue II, File Salvage or TechTool Pro. Each of the preceding come on bootable CDs to enable usage without risk of writing more data to the hard drive.
    The longer the hard drive remains in use and data are written to it, the greater the risk your deleted files will be overwritten.
    Also visit The XLab FAQs and read the FAQ on Data Recovery.

Maybe you are looking for

  • Multiple crashes everyday. Help? :(

    Howdy, My FCP is crashing all the time these days, I've tried reinstalling it, I even tried wiping the system and going from fresh. Nothing seems to have much of an affect. My system details are as follows: Mac Pro 2x2.66ghz Dual-Core Intel Xeon 7gb

  • What is wrong with my ipod touch 2nd gen?

    Ive had this iPod since mid 2010. It's running iOS 4.2.1 and it's not jailbroken. A few months ago I encountered a problem with it. It started to fast forward my songs and pause them and skip them as if it had a mind of it's own. I thought it was a o

  • WYSIWYG Font menu in AppleWorks

    Still can't function without AppleWorks. It has been working just fine, even under Leopard on our new Intel iMacs. But ... Installed Adobe CS3 Web Standard a couple of days ago. Loads of extra Adobe fonts were installed with it. Now when I try to set

  • Cats: No Approver column in Cats _DA

    Hi, Recently we noticed a Wierd issue, where in the approved by, approved date, columns were missing in Cats table. Since these values wiill be pulled directly from the org unit assignment and for contractors from a custom table. But the problem here

  • Column level security

    Hi, While changing PROJECT_INACCESSIBLE_COLUMN_AS_NULL to YES in NQSConfig file to implement the column level security, we get an error saying 'A general error has occurred. [nQSError: 46036] Internal Assertion: Condition m_CountFields == static_cast