Union all too slow for my query any alternative?

Hello

The following query prints the desired results. What I'm trying to do is to add to my query below is to also retrieve information from different dates (for example 01.01.2012 - 30.4.2012), more information below, but with 0 amounts. The only solution I found is to duplicate the query to a union and entry dates you want below. The problem is that, then the query is too slow.
Any other recommendations are welcome
SELECT s.trans_datetime,s.alloc_ref,s.accnt_code,s.treference,s.DESCRIPTN,sum(s.amount*(-1)) as amount,s.conv_code,sum(s.other_amt*(-1)) as other_amt,s.anal_t1,ss.descr,
o.NTN_DESCR as flag,z.name as vessel_name
FROM  accounts s, customers ss,vessel a,nation o, analysis  z,
customers_anl_cat  z1
where s.trans_datetime BETWEEN to_date('01.01.2013','DD.MM.YYYY') AND to_date('30.04.2013','DD.MM.YYYY')
AND s.accnt_code=z1.acnt_code
AND z1.anl_cat_id=17
AND ss.ACNT_TYPE=2
AND s.accnt_code=ss.acnt_code
AND o.NTN_CODE=a.flg_code
AND z.anl_code=s.anal_t1
GROUP BY s.trans_datetime,s.alloc_ref,s.accnt_code,s.treference,s.DESCRIPTN,s.conv_code,s.anal_t1,ss.descr
,o.NTN_DESCR,z.name,z1.anl_code
Thanks in advance

794018 wrote:
Thank you very much for your answers.

Unfortunately, the lines of the new date in the amount and need to convert to 0 or null values

OK... What is not eligible for a situation to replicate the query to use UNION all clause You can simply do more in select:

Select  column_list1... column_listN,
case when s.trans_datetime BETWEEN to_date('01.01.2013','DD.MM.YYYY') AND to_date('30.04.2013','DD.MM.YYYY') then s.amount
       when s.trans_datetime BETWEEN to_date('01.01.2012','DD.MM.YYYY') AND to_date('30.04.2012','DD.MM.YYYY') then 0
end amount
from table_names
where (s.trans_datetime BETWEEN to_date('01.01.2013','DD.MM.YYYY') AND to_date('30.04.2013','DD.MM.YYYY') or s.trans_datetime BETWEEN to_date('01.01.2012','DD.MM.YYYY') AND to_date('30.04.2012','DD.MM.YYYY'))
Other conditions Follow

Tags: Database

Similar Questions

  • but wireless connection can't get all web pages for display on any browser

    connected to a wireless connection but can't get all web pages for display on any browsersit is connected with good strengh but does not connect

    Hello

    What happens when you connect to the router via a wired connection?

    Method 1: Reset the Internet (TCP/IP) Protocol:

    One of the components of the Internet connection on your computer is a package of instructions called TCP/IP. TCP/IP can sometimes become damaged or altered. If you are unable to connect to the Internet, TCP/IP can be causing it.

    TCP/IP is a main component of Windows, you cannot delete it. However, you can reset TCP/IP to its original state by using the NetShell (netsh) utility. Reference:

    Reference:

    How to reset the Internet (TCP/IP) Protocol:

    http://support.Microsoft.com/kb/299357

    Method 2: Reset the default Hosts file

    The "hosts" file is an important Windows system file which maps hostnames to IP addresses. Its a simple text file that is stored in the folder "%windir%\System32\drivers\etc\" in Windows NT, 2000, XP, Server 2003, Vista, Server 2008 and Windows 7 32-bit editions. In the 64-bit editions, it can be also stored in the folder "%windir%\SysWOW64\drivers\etc\".

    Structure of the hosts file is very simple. It contains lines of text containing the IP address, followed by the host name.

    Sometimes this hosts file is hijacked by viruses, adware, spyware or Trojan software and is changed to redirect your browser to various websites containing malicious code. It could also block security Web sites and the Windows Update Web site in your system so that you can not install virus definitions and security updates in your operating system.

    Reference:

    How can I reset the default Hosts file?

    http://support.Microsoft.com/kb/972034

  • Help! My Lenovo T60 Thinkpad too slow for life...

    Hello

    So I got my Lenovo T60 for like a year and a half, and until two months ago, it worked well enough (he got the occasional fan at first error message place however) and then all of a sudden he started bluescreening, as it would not go past the Welcome screen. So I installed Windows 7 and it worked fine for 3 weeks, then again bluescreening. So I decided to go back to XP. Establishment lasted 2 days (no, I'm not exaggerating) and since then, it takes 30 minutes just to start. And although I can't do anything on this issue because it is too slow; a simple command such as opening a folder takes 10 minutes! Has it damaged something by installing Windows 7? What can I do to make it normal again? Thanks in advance

    Looks like a bad HD for me. You need to check the bad sectors, which can be easily made to initialize with a linux LiveCD/USB and by running disk utility it. It will report on the SMART status of your drive, and I suspect that your HD to be riddled with bad sectors, ergo long boot time and BSOD.

  • What happens if my pc is too slow for Flash CS6? can I try (and find) old version?

    Hi all
    I tried the trial version Flash CS6 but my computer is too slow (less than 2 GB of RAM available) and I am not able to use it . I need to do animation cartoons and I have not need of order code to make... What do you recommend me, please? If I use an old version (the one who? ) Flash 8 ? is there a trial version on the site? ) It can work ? I mean I can what he valid for my works or is a point of against me for the market?

    I want to be sure before you buy the product...

    (what is the right place to ask?)

    Thank you anyway
    Adelina

    You can catch Macromedia Studio 8 on Amazon for $ 50. Flash 8 has a great under XP, a half decent machine should have no problem with this version. I remember that I ran with 512 MB of RAM on a Pentium IV.

    http://www.Amazon.com/GP/offer-listing/B000AQHMK0/ref=dp_olp_used?ie=UTF8&condition=used

    And you won´t find better freeware imo.

  • Too slow for Toshiba 3.0 transfer speed

    Hello

    I just bought a toshiba external hard drive 3.0.
    I use windows 7 genuine.

    My pc specs are pretty ok cos I'm able to run games like crysis 2.
    The problem is my external hard drive has a slow transfer rate. This problem, I started facing along 3 months ago. My hard drive is out of warranty.

    My USB ports are ok and I connect it to the main port.
    Transfer speeds are 10 Mbit/s, and sometimes it falls to Kbps!

    In addition, it does not copy certain files and gives the error 'Cannot read from the source disk' or something like that.
    There is no Virus in there, I activated the write cache. I've defragmented it.
    My OS is fine, and also, I checked it on other operating systems.

    Also, I tried to use "check the drive for errors" with the proper procedure, but it crashes somewhere in the Middle after he treats 500000 sectors or so.

    I got my HDD of my cousin, such that it has used no more PC and with no cover so I have no idea of the model (although if there is any utility to find the model then please let know me).
    In addition, it has worked well during the time. Me and my cousin come only from the India.

    How can I solve this problem?
    Please help me.

    Post edited by: Emeric

    null

    Please don t understand me wrong, but if the matter is urgent you can call Toshiba in your country or the nearest Toshiba service provider contact.
    It is the only forum user.

  • Replace the subset of table w/Shift Register too slow for my Application

    This is similar to other posts, but I have not found one that addresses the limitations of an approach of shift register.

    I have a part of an application that I'm turning to 500-1, 000Hz.  The process extracts a block of data from the ADC, and I need to store this data, then collects more of the ADC.

    I've set up what seems to be the bottleneck of the present in the attached .zip file.  When I run the attached code with profiling (see. PNG file), it tells me that it takes on average 3.8ms for the Subvi to run.  At this rate, I can only run around 260 Hz.  I have a Subvi similar to this in my code and the code can run at 1000 Hz without this Subvi, but slows down to about 160 Hz when it is activated.

    Is it possible that I may collect data about 1.7 KB tables and run at the speed I need?  Any input would be appreciated.

    For purposes of reference. Debugging should be disabled on the sub - vi.

    Looking at the code you provided - don't just disable debugging -! you have some other options of "exécution" to reset.

    This should speed up the Sub - vi SR will be your friend again!

  • Shortcuts for Photoshop CS6 brush size is too slow for my work

    Hi all, need help here.

    When we paint with Photoshop brushes (while seriously urgent works, especially since my boss is hunting...), we need more big brushes or to change small brushes, at such tense moment, I find the so so so slow [] shortcut and I can only click on the [] as hard as possible, I quietly shouting "come." faster... »

    So, is there a way to double or triple the speed?

    Thank you

    Instead of using the range keys, you use could the shortcuts below to change the size of the brush much faster.

    Windows

    ALT + right click, drag to the left or right

    Mac

    CTRL + Option + drag to the left or right

    It of the shortcuts above with any of the paint tools and drag left or right in the area of document

    Drag upward or down to change the hardness

    (you can change opacity in photoshop preferences)

  • Too slow for Skype

    We have an older NB300 of 1 month with 1 GB into standard. When you try to use Skype (battery or sector) Skype shows this computer runs slowly. We can hear people on the other end, but our conversation faints. This also happens on Skpe testing. All other programs are closed and switched to high performance.
    Any suggestions? Purchase of another GB of hard drive will help. Running Windows 7 starter edition. Thank you

    Hello

    Personally, I have never used Windows 7 starter. But I know, Skype does not require much Cpu resource to run. 1 GB installed memory is sufficient to run it. Have you tried using older versions of Skype?

  • The video is too slow for audio, the file is .mp4, he recorded with my webcam with Toshiba Qosmio X 75 - A7170. Also sometimes audio rehearsals.

    Hello

    For videos when I record with my webcam on my Toshiba Qosmio X 75 - A7170 and then place it in Premiere Pro the video seems behind the audio.

    Stats on my laptop:

    Processor: Intel Core i7-4700MQ CPU @ 2.40 GHz

    RAM: 16 GB

    System type: 64-bit

    Memory speed: 1600 mhz

    Hard drive: 1000 GB mechanical_hard_drive

    Graphics card: NVIDIA GeForce GTX 770 M

    Graphics RAM: 3072 MB

    Hard Drive rotation speed: 7200 RPM

    If the video is behind and, occasionally, for some reason, the audio will be repeat or even start again from what sounds are going on at the beginning.

    The file is saved with my webcam recording is .mp4. I don't know what else to say to halp please.

    The video file is played as usual when I use windows media player.

    I use first Pro CC v8.1

    Hi Bellebacon,

    You have variable speed of frame video. RIP to the handbrake and you will have a file, you can use: https://handbrake.fr/downloads.php

    Thank you
    Kevin

  • UNION ALL destroyed performance

    Strangely, we have 2 queries, which, when they run independently, running fast enough (2 seconds on the one hand, instantaneous to the other), but when they are concatenated into a UNION ALL query without the ORDER BY clause, it takes 45 seconds for him to run.

    We tried to push the SQL code in a WITH clause and some other rewrites of the subquery, but no performance boost. Anyone seen this before?

    version 10.1.0.4
    -= Chuck

    just a thought... I didn't really study plans explain it... (I find these very difficult to read, you do not have these SQL * Plus, you did?)

    Tom Kyte mentioned somewhere (I find the thread later) you can use ROWNUM in two UNION ALL queries to "refine" the query. You might want to try it.
    Because of the ROWNUM materialize you each request separately before combining the results.

  • DVD player is too slow on the Satellite A100-507

    the stack of reader dvd * a dvd - ram uj - 841 s my satellite a100-507 is too slow. (~ 1000 kb/s - far too slow for a movie - and it does not depend on the player.)

    specifications technical manufacturer is 8 x reading + writing for DVD, even I can write DVD up to 2.4 x

    is this a software problem? (I use Windows XP)

    Hello

    You are not able to watch DVD on your laptop, or what is the problem?

    I studied a bit and found a few player features:
    Maximum read speed:
    CD 24xMax
    DVD-ROM 8xMax

    Maximum write speed:
    CD - R 24xMax
    CD - RW 4xMax
    HS CD - RW 10xMax
    US CD - RW 10xMax
    US + CD - RW N/A
    DVD-R 8xMax
    DVD-R(Double Layer) 2xMax
    DVD - RW 4xMax
    DVD + R 8xMax
    DVD + R (Double Layer) 2.4xMax
    DVD + RW 4xMax
    DVD-RAM 5xMax

    So you info about 8 x reading + writing of DVD is not exactly true. It is based on the DVD.
    In addition, it is important to mention that these are the max values.
    Sometimes the drive reads or writes with a lower speed. It depends on the cache status.

  • HP Laserjet M1132 MFP is too slow on the network!

    Hello

    My HP Laserjet M1132 MFP is too slow on the network!

    I connect the printer to the windows XP 32 bits SP3 using UBS port. The printer works fine on the local computer, but when he shared on the network running too slow, for example with the print test page it takes about 45 seconds to print and other documents, it takes much longer.

    I installed the last form HP driver site and update the firmware it the latest version.

    It happens on other Windows XP machines as well.

    I have connected the printer to my laptop (Windows 7 64-bit) and it works very well (no delay on the network) and it seems that this problem have some relationship with the windows XP Driver.

    I used the trick of local port on computers remote (instead of the normal method) like this:

    "add a local printer.
    "new port".
    "localport".
    \\XPcomputer\HPPrinterName port name

    but still nothing!

    There is nothing wrong with the network, allows us to use a Samsung printer on the same machines on the network without problem.

    I really appreciate your HELP!

    It seems that no one on the planet has the answer to this question!

    The only available option is to upgrade your operating system to windows 7 (vista can work, I have no idea!).

    He wat the only solution for me.

  • HP 6029de RAID 0 too slow

    I changed my 6029de HP in RAID 0. But the writing speed is 30 MB/s.
    Is not too slow for a RAID 0 system?

    Will there be an update of firmware for it? or can I pay what?

    translated by google

    If you have changed from RAID 0 that normally you have to reinstall the operating system or run the recovery as far as I know and then try some points of reference.

    Also where do you see that read/write speed?

    It is when copying, cutting or trasnfer files?

    Mine appears lower than that and im current raid 0 and I can say it's faster and I do not trust fully the speed that Windows says it is trasnfering.

    It's even slower when you transfer to or from a usb device, which is normal.

  • ICloud sync broken between Yosemite (too old for El Capitan) Mac and iOS9.3 on devices, for all Apple applications. Any solution?

    Since that is new iPad and iPhone one last week, with iOS 9.3.4, I can't rely on iCloud (iCloud Drive) for synchronization between these devices and my iMac on docs or entries that I create in Pages, Numbers, calendar, Contacts, Notes, reminders.

    With no synchronization goes, I am now frustrated with Apple based applications.  The only solution is to buy a new iMac that can do El Capitan for iCloud to synchronize?

    My 2008 iMac cannot go beyond the latest version of Yosemite.  Even apps that I continue to use without problems - except iCloud who can't do what it should.  According to me, only yosemite on the iMac in 2008, was made bankrupt by the last iOS.

    That's the problem - unless someone has found a workaround.  Without a functional iCloud, sync that I've been waiting for has disappeared.  I need to change how to manage what I do on the devices and the computer.

    I would like to find a way to "merge" safe documents created in these applications on both devices and the computer. Initially a merger will have duplicates.  I can't let the docs on any device replace the docs on the other.

    To avoid any loss of docs on any device and computers, I'm afraid to try to use iTunes.  So I won't try it.  Maybe I need to go "manual" and look at the files on each and do the merge manually, by sending an e-mail.  Help!  I discovered this by accident and now that I look closer I see that synchronization does not occur.

    between Yosemite Mac (too old for El Capitan)

    Any Mac that can run in Yosemite can run El Capitan. Early 2008 iMacs can run El Capitan.

  • How to filter records in a UNION ALL query

    Hi all

    I have only one requirement to filter records in a query UNION all. If we do not all matching records to one of the union, all question them.

    create table test_1(n1 number,n2 number,n3 number)
    
    insert into test_1 values(1,2,3);
    insert into test_1 values(11,22,33);
    insert into test_1 values(55,66,77);
    
    Case-1 :
    
    SELECT N1,N2,N3
    FROM TEST_1
    WHERE N2=2
    UNION ALL
    SELECT N1,N2,N3
    FROM TEST_1
    WHERE N3=3
    
    Output is : This is desired output(so we are good)
    
    1,2,3
    1,2,3
    
    Case 2 :
    
    SELECT N1,N2,N3
    FROM TEST_1
    WHERE N2=22
    UNION ALL
    SELECT N1,N2,N3
    FROM TEST_1
    WHERE N3=44
    
    Output : (Here is the problem: If we don't have matching records for anyone union all query we don't want any records)
    
    Output is coming : 11,22,33
    
    Out put : No Records (We want this output.)
    

    I hope I have given the clear example of my requirement.

    Thank you.

    with

    test_1 as

    (select 1 n1, n2 2, n3 3 of all the double union)

    Select 11,22,33 from all the double union

    Select double 55,66,77

    )

    Select the n1, n2, n3

    from (select n1, n2, n3

    of test_1

    where n2 =: n2

    Union of all the

    Select the n1, n2, n3

    of test_1

    where = n3: n3

    )

    where exists (select null from test_1 where n2 =: n2)

    and it exists (select null from test_1 where = n3: n3)

    Concerning

    Etbin

Maybe you are looking for

  • Upgrade of Windows 8 results in 0kb (empty) scan files, Officejet Pro 8500 A910

    It's totally weird.  I used my printer wide for analysis while on the original install on Windows 7.  I always use the touchkeyboard of 8500 and "scan to network folder" and put in a file name.  After 8 of Windows Installer, I get the name of file in

  • Where can I get a Power Mac Quicksilver monitor connector?

    I withdrew my Power Mac G4 (Quicksilver?) in 2010 in favour or an IMac 27 ".  Now after having sitting in storage for years, I plug it into my IMac as an external hard drive to wipe and move.  I did not set the monitor and cable connection for some r

  • OfficeJet pro 8000: does not print color Cyan

    I have printed about 20 photos and color was great. All of a sudden the color gone wrong. Printed a test page and black, yellow and Magenta were perfect, but lacked the Cyan completely. All the ink levels were 50% or better, Cyan was 80%. Printhead s

  • How to add this bar of the spectrum in labview?

    Anyone know how to add the bar spectrum (see attachment file, arrow6) in labview and make the plot shows different color when the value goes down there in different range? Thank you very much

  • How can I downgrade from Vista to XP?

    It's a constant battle just maintaining a wisp of stability using Vista as my platform.  I would can the Vista and replace it with XP Pro.  My computer is very unstable and the software is such that when I type an icon on my desktop, I too never know