Avoid using the same query...

How can I avoid to use the same query again and again using a single query, such as

SELECT
a,
b * (SELECT COUNT (C1) FROM T2);
c * (SELECT COUNT (C1) FROM T2);
d * (SELECT COUNT (C1) FROM T2)
Of
T1;

Fanny says:
How can I avoid to use the same query again and again using a single query, such as

SELECT
a,
b * (SELECT COUNT (C1) FROM T2);
c * (SELECT COUNT (C1) FROM T2);
d * (SELECT COUNT (C1) FROM T2)
Of
T1;

A few cross join?

select a, b*cnt, c*cnt, d*cnt
  from t1, (select count(c1) cnt from t2)

Tags: Database

Similar Questions

  • I use the same query in two difference db (exp/imp) but run different times!

    Hello

    I have 2 database. One of the remote server, one at my local. I used exp/imp to retrieve data from remote to my local database. Structers, tables and indexes is the same.
    My local machine is more powerful than the remote computer. (Ram, cpu County ext)

    But when I connect remotely from my local computer, this application runs 4 second (with view). But when I connect to my local db, this query run 5 minutes.
    Number of rows returned is 18,500

    What's wrong? Why get the bytes of the value are different?

    Local explain plan is:
    SELECT STATEMENT ALL_ROWS Cost: 203 Bytes: 19,062,160 Cardinality: 18,329                                         
    Remote control explain plan is:
    SELECT STATEMENT ALL_ROWS Cost: 226 Bytes: 3,855,214 Cardinality: 18,446                                         
    My plans to explain (remote and the) and other (auto track, oracle params) data is in excel file (because of this forum not to accept more than 30,000 words);

    http://www.eksicevap.com/tech/explainplan.xls
    for winrar:
    http://www.eksicevap.com/tech/explainplan.rar

    Thanks for help

    Oracel version information:
    Local:
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    Distance:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi

    Published by: Melike on 15.Mar.2011 02:42

    Published by: Melike on 15.Mar.2011 03:39

    Melike says:
    Thanks, Johan, I'll try.
    My first post for local oracle param, I got it 3 days ago. or I confuse my file params to oracle. (This problem continues from last week)
    Now I'm waiting still current oracle local params and these value is worse:

    Local:
    pga_aggregate_target 0
    SGA_MAX_SIZE 536.870.912
    SGA_TARGET 0

    I update the new oracle local params in my previous message.

    I'll try the update of these values, but I hope, my local oracle is not drop down :)

    Can't be worse...
    You have a parameter memory_target (and max_memory_target)? If so, you could add memory to these settings as well and only set pga_aggregate_target (no CMS or sga_max)

    My settings (on a test/dev/lab-box):
    System@oracle11 SQL > see the memory settings

    VALUE OF TYPE NAME
    ------------------------------------ ----------- ------------------------------
    hi_shared_memory_address integer 0
    whole big memory_max_target 3G
    whole large memory_target 3G
    shared_memory_address integer 0
    System@oracle11 SQL > show parameter sga

    VALUE OF TYPE NAME
    ------------------------------------ ----------- ------------------------------
    lock_sga boolean FALSE
    PRE_PAGE_SGA boolean FALSE
    SGA_MAX_SIZE large integer 0
    SGA_TARGET large integer 0
    System@oracle11 SQL > show parameter pga

    VALUE OF TYPE NAME
    ------------------------------------ ----------- ------------------------------
    pga_aggregate_target large integer 0

    This way I pushed things like Oracle by itself, memory allocation to everywhere where oracle needs him the most.

    Brgds
    Johan

  • Using the same application with filters prompted by guided Navigation

    Hi gurus,


    I have a requirement in which I need to show a report only when it returns results.

    To do this, I put the request in a section and applied a guided navigation using the same request as a source of demand.

    Can I use the same query in the navigation guided as request to the source?

    In the application there are filters which are invited

    My question - > in demand of guided Navigation Source, what I have to do the filters that you are prompted, or what I need to make it equal to the variables of presentation, which are populated by dashboard guests.

    I also have one of the guest as a guest of multiple selection...


    Thank you
    Ashish

    Ashish,

    Yes, you can use the same request here.

    For the application, you can use "IsPrompted" if same column is used in the guest of another use variable presentation here which is populated from the dash prompt. Just, 'specific' selected value based shud report results.

    Refer
    http://varanasisaichand.blogspot.com/2010/02/dashboards-as-prompts-in-OBIEE.html?m=1
    http://bischool.WordPress.com/category/guided-navigation/

    I hope that its useful...

  • How can I integrate my tree using the tree query in combobox

    Hi all

    I have a request of tree and you want to use the same query tree to put a tree inside a ComboBox as combobox category in this link
    http://forums.Oracle.com/forums/search! default.jspa

    Can someone help me to do it... I also use my fine navigation tree.

    With respect,
    Sunil Bhatia

    Hello

    LEVEL is not a real column - it's a nickname, so it shouldn't be on your table, because it generates the SQL.

    Your statement could be something like:

    SELECT LPAD(' ', 2 * (LEVEL-1), '.') || "NAME" d, "PAGE_NO" r
    FROM APEX_PAGES
    WHERE PAGE_NO NOT IN (SELECT "PAGE_NO" FROM "#OWNER#"."APEX_USER_PAGES" WHERE "APP_USER" = :APP_USER)
    START WITH PAGE_NO = 1
    CONNECT BY PRIOR PAGE_NO = PARENT_PAGE_NO
    

    I don't know what would be your starting page number - it would be to the top of the tree - so I just put 1 in this example.

    Here is a page that I put in place using my example of EMP table, just to show what would be the result: [http://apex.oracle.com/pls/otn/f?p=35917:22]

    Andy

  • Determine the maximum length of a column and its use in the same query?

    I would like to determine the maximum length of a column and use it in the same query. Is this possible? IE:

    SELECT RPAD (last_name, SELECT MAX (LENGTH (last_name)) + 5 FROM user, '-')
    OF the user.

    Thank you

    Hello

    Welcome to the forum!

    jfraley wrote:
    I would like to determine the maximum length of a column and use it in the same query. Is this possible? IE:

    SELECT RPAD (last_name, SELECT MAX (LENGTH (last_name)) + 5 FROM user, '-')
    OF the user.

    Thank you

    Sure. You almost go in your message: a scalar subquery . Just put brackets around the subquery:

    SELECT      RPAD ( last_name
              , (
                 SELECT  MAX (LENGTH (last_name)) + 5
                 FROM    user_tbl          -- USER is not a good table name
                )
              , '-'
              )          AS padded_last_name
    FROM      user_tbl
    ;
    

    Scalar subqueries in SQL are like tape in your garage in canvas: they are used for thousands of different things and open, maybe 1% of them. Usually, there are better ways to achieve the same results, such as the analytical functions:

    SELECT      RPAD ( last_name
              , 5 + MAX (LENGTH (last_name)) OVER ()
              , '-'
              )          AS padded_last_name
    FROM      user_tbl
    ;
    

    Still another way is to make the subquery and then join his game as if it were a table of results:

    WITH     got_max_length     AS
    (
         SELECT     MAX (LENGTH (last_name))     AS max_length
         FROM     user_tbl
    )
    SELECT      RPAD ( u.last_name
              , m.max_length + 5
              , '-'
              )          AS padded_last_name
    FROM           user_tbl     u
    CROSS JOIN     got_max_length     m
    ;
    

    Published by: Frank Kulash, December 12, 2011 21:17
    Added cross join example

  • Every day I receive a notice that someone on my computer using the same I.P. address

    Title of the Moose: I. Address of P.

    Every day I receive a notice that someone on my computer using the same I.P. address but yet I found nothing of canoe

    Hello

    (1) work on a domain network?

    (2) how long have you been faced with this problem?

    (3) what is you receive the exact error message?

    Method 1:  If it is a small network of computers on homegroup, contact the person with administrative rights system on your network.

    Method 2:  Make sure that the network card is configured according to the manufacturer's specifications and that the configuration is not incompatible with the other hardware configurations.

    Method 3: Run Microsoft Security scanner (MSS) to any threat and try to correct
    http://www.Microsoft.com/security/scanner/en-us/default.aspx

    Note: Infected files can be deleted from your computer; There is a chance of data loss.

    Method 4: download and install all available Windows Update

    Install Windows updates
    http://Windows.Microsoft.com/en-us/Windows-Vista/install-Windows-updates

    If you are working on a domain network, then please post your query on the TechNet forums for more specialized help.

    TechNet Forum

    http://social.technet.Microsoft.com/forums/en/w7itpronetworking/threads

  • Uses the same drivers as Windows 7 Windows 8?

    Hello! I was wondering if Windows 8 uses the same base drivers under Windows 7. I considered dual-boot on my old Windows 7 computer that had defective drivers, to avoid the risk of my newer computer. Would I be able to dual boot and have different drivers, or Windows 8 uses the same drivers on Windows 7? On a side note, it would even work, or have I missed some crucial detail?

    Windows 8 and Windows 7 share the same driver model. Windows 8 comes with a standard set of class for the peripheral communes drivers. Usually, drivers that are preloaded with the OS offer basic functionality and you must go to the website of manufacturers of device for drivers optimized for the device, this includes devices such as your video card or a printer.

    According to the edition that you run, you can keep your personal files, applications, and settings. Apart from that, I recommend strongly dual boot with your existing operating system rather than replace it with the output preview Windows 8. Preview release is still in heavy development and do not replace a copy of production Windows with it (be it XP, Vista or Windows 7).

    http://techingiteasy.WordPress.com/2012/03/05/How-to-dual-boot-Windows-Vista7-and-Windows-8/

  • Can I enroll in two Windows 8 computers using the same account at the same time?

    I just bought another laptop Windows 8 and want to set up using my Microsoft account, can I use the same account on both computers at the same time, or do I have to sign up an account?

    Hi Disuhall,

    Thanks for posting your query in Microsoft Community.

    From your description, it seems that you want to know if you can register in two other computer using the same account existing Microsoft at a time in your operating system to Windows 8.

    I'll be happy to help you.

    You can register in both computers using the same account to Microsoft and you have to sign on the account to be used in another computer.

    For all windows questions do not hesitate to contact us and we will be happy to help you.

  • Why I have two different execution plans for the same query on two different servers

    Hello everyone.

    I need your help to solve the problem quickly.

    In a nutshell, we have two servers that have the same version of Oracle RDBMS (11.2.0.4 EE). One of them for purposes of development and another is a production one.

    We have therefore two different execution plans for the same query executed on both servers. The only case of execution is OK and another is too slow.

    So I have to slow down the work of query using the same scheme to explain that young.

    Fence wire.

  • Use the same image twice column in a report

    Hello

    I have a question which is, I can use the same column (column A in the example) picture twice in a report? first occurrence (column A) will show the thumbnail of the image and the second occurrence (column A) will display the image download link that opens the picture in a new window. Is this possible?

    Thank you

    Alexander

    -APEX-perf wrote:

    Yes, it is possible. However, if you intend to have two different images, then I would suggest you use javascript to link or download the blob.

    What's happening on Earth? Why JavaScript is necessary to download two different images? Even if he was in any real way, the OP is clear that the link posted of thumbnails and download involves the same image.

    To accomplish this task, you use decode or create a union query.

    No, all that should be necessary is the image column twice in the projection of the reference report query and apply a mask download format to a column and one mask of the image to the other. That the OP apparently did not this probably indicates that they are unnecessarily complicate things.

    For example:

    Select '' link_col

    table

    where allow_view = 'Y '.

    Union of all the

    Select '' link_col

    table

    where allow_view = ' don't

    or

    Select decode (allow_view, 'Y',

    '',

    ("") link_col

    table

    What is downloadImg? It is not a Standard API JavaScript APEX. Therefore, it is highly unlikely that this is of no use to the op.

  • Loading multiple files using the same interface in ODI

    Hi all

    We load multiple files using the same interface and get the error "java.sql.SQLException: ORA-00942: table or view does not exist" while inserting record in the staging table. It looks like the same temporary table is used when loading multiple files and the error. Grateful if someone offers a solution to avoid this error.
    We use the following KMS:

    (1) LKM SQL file
    (2) IKM Oracle SQL COMMAND append.

    Receive a quick response.

    Thank you
    RP

    Hello

    See this http://odiexperts.com/interface-parallel-execution-a-new-solution

    Thank you
    Fati

  • Query with almost the same query as a subquery, can it be optimized?

    I have a query using almost a duplicate of itself (table 1) as a subquery, and I wonder if it can be rewritten better, like she just doesn't seem the right way to do it, but everything I try I can't get the same number of lines back.

    If anyone can see a better way, it would be a great help.

    Thank you very much
    SELECT t.pol_number||t.check_digit
    FROM   transactions t, policies p, funds f
    WHERE f.fnd_code = t.trn_fnd_code
    AND     t.trn_pol_number = p.pol_number
    AND     p.pol_status IN (1,2)
    AND     t.trn_status = 'NEW'
    AND     t.trn_trn_number IN
       (SELECT t2.trn_trn_number
        FROM   transactions t2, policies p2
        WHERE t2.trn_pol_number = p2.pol_number 
        AND     p2.pol_status IN (1,2)
        AND     t2.trn_status = 'NEW'
        AND     t2.trn_fnd_code = :PARAMETER)
    Surely it is not the best way to write it as you use the same table twice and restrictions?

    Published by: Scott Hillier on March 16, 2010 15:11

    It looks like you want all the lines of the siblings who do not personally meet the restriction on trn_fnd_code. You can use analytical functions;

    not tested

    select *
      from (select pol_number || check_digit col1,
                   max(case
                          when t.trn_fnd_code = :parameter then
                           1
                          else
                           0
                        end) over(partition by trn_trn_number) max_trn_number
              from transactions t, policies p, funds f
             where f.fnd_code = t.trn_fnd_code
               and p.pol_status in (1, 2)
               and t.trn_status = 'NEW')
     where max_trn_number = 1;
    
  • Can I use the same disc hard ext I used for El Capitan Yosemite without losing my data?

    Can I use the same disc hard ext I used for El Capitan Yosemite without losing my data?

    Yes. You should not lose any data, but always have a backup. In this case, you have your internal drive as a backup.

  • Hi all OneHow can you buy an IBook UK not available in Indian store a store; When you change the status of your country, your billing information and credit cards won't work; is there a solution for this using the same method of billing.

    Hello world

    How can buy you an IBook of UK not available in Indian store a store; When you change the status of your country, your billing information and credit cards won't work; is there a solution for this using the same method of billing

    There is no solution, if it is not available in your area, you can't buy it.

  • How to separate 2 IPADs using the same Apple ID

    Problem: I have 2 iPad (IPAD 2/IPAD Air) using the same Apple ID.  To maximize the storage capacity on two IPADs, how can we separate the two so that each IPAD will show its max 16 GB storage?   I have to reconfigure the old IPAD back to factory setting?  I create an AppleID separated for the IPAD 2?  Your comments are greatly appreciated

    I'm not sure I understand what you're talking about. If you have two 16 GB iPads, they have only about 13 GB of storage available out of the box. Using the same Apple ID on both devices does not affect the amount of space you are using, if you sync the same content for both and in everything you turned on automatic downloads and use iCloud photo library on both devices.

    -What are you trying to achieve? What exactly do you do?

Maybe you are looking for

  • Update satellite 1005-S157

    How can I improve it?

  • Qosmio F60 and Seagate Momentus XT problem

    Hello! I need help to solve a problem.I tried to change the hard drive of my Qosmio F60 for a Seagate momentus XT (hybrid SSD). I have even if it was simple First of all, my new HARD drive was not recognized in the BIOS. So I put a rider to force the

  • Logging of additional results of step before reminder

    In my sequence, the recall of SequenceFilePreStep checks if a step is a test step (e.g. NumericLimitTest). If this is the case, a value of temperature of an overall picture must be kept at additional step results. Let's say the array of temperature i

  • M17x R3, plugged in, does not support

    Hi guys,. Please help me. I have computer m17xR3 laptop alienware and today I noticed that my battery won't charge. How to solve this problem, do you have any ideas? I tried to stop the laptop and reboot twice and doesn't help not. Help, please. Than

  • Reset password without disks

    I forgot pass login password and can not even get on my computer is there a way to reset this password with disks?