Need help for query joining views

Hi all

I need to run a query that joins a number of tables with multiple instances of the same view.  For example, a view named MY_VALUES, is an array of key / value resembles the following:

Application_ID Attirbute_Description value

1 1 000 basic benefit

1 multiplier 1 0.5

1 Multiplier_2 1.2

1 total profit 1,115

2 1 025 basic benefit

2 multiplier 1 0,268

2 Multiplier_2 1.3

Total profit 2 1.4500

Say I want a query that selects basic earnings and a multiplier 1 for Application ID 1, as well as, other information from a table called APPLICATION that has a relationship to display pk - fk. I would do the following:

Select the application. Name, mv1.value, mv2.value

from dbo. App APPLICATION, dbo. MY_VALUES mv1, dbo. Mv2 MY_VALUES

where app.id = mv1.application_id and mv1.attribute_description = "Basic benefits"

and app.id = mv2.application and mv2.attribute_description = id 'multiplier 1'.

and app.id = 1

My actual query is similar to this. However, I have many other attributes of the notice I need to select, which requires that the view be attached to several times. After 16 these joins, the request is fine. After 17, however, the query runs always, never return a result within 45 minutes I have let it run.

Is there a better way to write such a request or an indicator of optimization that would be useful here?

Any help is greatly appreciated.

....

For this type of application, it is often best to extract multiple lines in a single request on the view and their pivot in the output.

For example

Select the application. Name

, max (CASE when mv.attribute_description = "Core service" then mv.value any other purpose) BaseBenefit

, max (CASE when mv.attribute_description = 'Multiplier 1' then mv.value any other purpose) Multiplier1

, max (CASE when mv.attribute_description = 'Multiplier 2' then mv.value any other purpose) Multiplier2

, max (CASE when mv.attribute_description = 'Multiplier 3' then mv.value end to another null) Multiplier3

from dbo. App APPLICATION, dbo. MY_VALUES mv

where app.id = mv1.application_id

and mv.attribute_description IN ('benefits of home', 'multiplier 'multiplier 'multiplier 3' 2' 1')

and app.id = 1

This runs often much better than several joins to the table for the view or the value of the attribute.

Tags: Database

Similar Questions

  • Need help for query flat_file type clobdata oracle table data.

    Hi Sir,

    I need help to query oracle table flat file data having given clob type.
    Oracle Version:
    
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    PL/SQL Release 10.2.0.1.0 - Production
    "CORE     10.2.0.1.0     Production"
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    
    
    
    Source table
    
      CREATE TABLE order_details 
       (     QUEUE_SEQNUM NUMBER(10,0) NOT NULL ENABLE, 
         LINE_SEQNUM NUMBER(10,0) NOT NULL ENABLE, 
         CHAR_DATA CLOB, 
         OPTIMISTIC_LOCK_KEY NUMBER(20,0)
       ) 
    COLUMN FOR CHAR_DATA FLAT_FILE
    EU,6067AT,AT10,000000402004,NexiumGERDManagementProject,Z435,,ZZ29,NIS-GOLD,AT
    EU,6067AT,AT10,000000402038,NIS-OEU-ARI-2007/1,Z450,,ZZ29,NIS-OEU-ARI-2007/1,AT
    EU,6067AT,AT10,000000402039,SymbicortNISinCOPD,Z450,,ZZ29,NIS-REU-DUM-2007/1,AT
    EU,6067AT,AT10,000000402040,D1443L00044SeroquelXRRuby,Z450,,ZZ29,D1443L00044,AT
    EU,6067AT,AT10,000000402041,NIS-GEU-DUM-2008/1,Z450,,ZZ29,NIS-GEU-DUM-2008/1,AT
    EU,6067AT,AT10,000000402042,SonstigeAktivitätenLCM,Z450,,ZZ29,.,AT
    EU,6067AT,AT10,000000402134,D1680L00002Saxagliptin,Z450,,ZZ29,D1680L00002,AT
    EU,6067AT,AT10,000000402199,SeroquelWaveNIS,Z450,,ZZ29,NIS-NEU-DUM-2009/1,AT
    EU,6067AT,AT10,000000402313,SeroquelExtra(D1443L00082),Z450,,ZZ29,D1443L00082,AT
    EU,6067AT,AT10,000000402517,AtlanticD5130L00006(AZD6140),Z450,,ZZ29,D5130L00006,AT
    EU,6067AT,AT10,000000554494,ArimidexSt.Gallen(13+2),Z142,,ZZ09,,AT
    EU,6067AT,AT10,000000554495,ArimidexASCO(5delegates),Z142,,ZZ09,,AT
    EU,6067AT,AT10,000000554496,ArimidexSanAntonio6delegates,Z142,,ZZ09,,AT
    EU,6067AT,AT10,000000554497,ArimidexBreastCancerSummit(13+2),Z130,,ZZ09,,AT
    EU,6067AT,AT10,000000554498,ArimidexEIH(15delegates),Z130,,ZZ09,,AT
    EU,6067AT,AT10,000000554499,ArimidexNIFA(200delegates),Z135,,ZZ09,,AT
    EU,6067AT,AT10,000000554500,ArimidexNIFAworkshops(8x25),Z135,,ZZ09,,AT
    EU,6067AT,AT10,000000554501,ArimidexPraktischeGyn.Fortbildung,Z147,,ZZ09,,AT
    EU,6067AT,AT10,000000554502,ArimidexAGO,Z147,,ZZ09,,AT
    EU,6067AT,AT10,000000554503,ArimidexHämato/OnkologieKongress,Z147,,ZZ09,,AT
    EU,6067AT,AT10,000000554504,ARIMIDEXGYNäKOLOGENKONGRESS,Z147,,ZZ09,,AT
    EU,6067AT,AT10,000000554505,ArimidexChirurgenkongress,Z147,,ZZ09,,AT
    EXPECTED RESULTS:
    AFFIRM_CODE COMPANY_CODE INTERNAL_ORDER_CODE INTERNAL_ORDER_DESC ENIGMA_ACTIVITY             SUB_ACTIVITY_CODE IN_AFF_IND ORDER_TYPE EXTERNAL_ORDER COUNTRY        
    EU          6067AT       AT10                 000000402004       NEXIUMGERDMANAGEMENTPROJECT     Z435           NULL        ZZ29       NIS-GOLD        AT             
    EU          6068AT       AT11                 000000402005       NEXIUMGERDMANAGEMENTPROJECT     Z435           NULL        ZZ29       NIS-GOLD        AT             

    Sorry, my bad. Without database at hand, I'll try 'baby steps' (borrowed from Frank) so you don't confuse it with errors that I might add (happens far too often already, but at least you won't "swallow" as forum members think is one of the main goals of this fighter - help her learn - providing not only the proverbial fish.)
    Search the Forum - your problem is one of its best sellers. Watching {message identifier: = 10694602} ("split string into" was the key word used in research) you can try something as

    select table_row,
           level clob_row,
           regexp_substr(char_data,'[^' || chr(13) || chr(10) || ']+',1,level) the_line
      from (select to_char(queue_seqnum)||':'||to_char(line_seqnum) table_row,
                   char_data
              from order_details
           )
     connect by regexp_substr(char_data,'[^' || chr(13) || chr(10) || ']+',1,level) is not null
            and prior char_data = char_data
            and prior table_row = table_row
            and prior sys_guid() is not null
    

    to get all the s the_lineall CLOB and after that the use of the example even to get your columns of each the_line.

    Concerning

    Etbin

    Edited by: Etbin on 3.2.2013 09:01

    .. .but I m connected to do things according to the instructions, I can't do something.

    Used to happen to me too and I did as told to the but only after explaining any disadvantages, I was aware of in time. The last sentence is usually: "O.K. now be just and Don't come back with that kind of thing when it turns out that this isn't the right thing."
    rp0428 post - something to remember.

  • I need help for query AVG

    I need help with a simple query in an ORACLE database. I tried a lot of things that I found on the internet, but none of them worked for me.

    The following query retrieves four lines:

    SELECT sampled_date AS VALUE1, VALUE2 AS result, 0 as value3

    Of asw_lab

    WHERE template_result = 'A' AND analysis = 'B' AND ROWNUM < 5

    ORDER BY sampled_date DESC;

    I would like to calculate a moving average of the last four values with the date of the sample of the last line.

    For example, I have this result for the query above:

    Value1 value2 value3

    01/04/14-16:00 1 0

    01/04/14 15:00 2 0

    01/04/14 14:00 3 0

    01/04/14 13:00 4 0

    I want to extract the below my average/query calculation result:

    Value1 value2 value3

    01/04/14-16:00 2.5 0

    Can you help me create a request to that effect?

    Thank you

    Maybe it's

    Select max (VALUE1) VALUE1, VALUE2 avg (VALUE2), avg (VALUE3) value3

    Of

    (

    SELECT sampled_date AS VALUE1, VALUE2 AS result, 0 as value3

    Of asw_lab

    WHERE template_result = 'A' AND analysis = 'B' AND ROWNUM<>

    )

  • Need help for a join query

    Hi, I'm a little stuck on getting the results of a join query. Let's say I have three tables that make up one of many to go from left to right:
    Project-> work-> work
    Each task can have many tasks. Each task in a job can be repeated by several users, each with a different assigned_name. The tasks of a job have a value of sequence (seq), so if the same task is repeated for a job, the seq will be different.
    I need to get the assigned_name of the last run of the task for each job. Here is the ddl:
    CREATE TABLE project (
    id          NUMBER PRIMARY KEY,
    name     VARCHAR2(20));
    
    INSERT INTO project (id, name) VALUES (1, 'Test Project 1');
    INSERT INTO project (id, name) VALUES (2, 'Test Project 2');
    
    CREATE TABLE job (
    id          NUMBER PRIMARY KEY,
    project_id NUMBER,
    name     VARCHAR2(20),
    CONSTRAINT fk_project 
       FOREIGN KEY (project_id) 
       REFERENCES project(id));
    
    INSERT INTO job (id, project_id, name) VALUES (11, 1, 'Test Job 1-11');
    INSERT INTO job (id, project_id, name) VALUES (12, 1, 'Test Job 1-12');
    INSERT INTO job (id, project_id, name) VALUES (13, 2, 'Test Job 2-13');
    INSERT INTO job (id, project_id, name) VALUES (14, 2, 'Test Job 2-14');
    INSERT INTO job (id, project_id, name) VALUES (15, 2, 'Test Job 2-15');
    
    CREATE TABLE task (
    id          NUMBER,
    seq NUMBER,
    job_id NUMBER,
    name     VARCHAR2(20),
    assigned_name          VARCHAR2(20),
    CONSTRAINT pk_task
       PRIMARY KEY (id, seq),
    CONSTRAINT fk_job
       FOREIGN KEY (job_id) 
       REFERENCES job(id));
    
    INSERT INTO task (id, seq, job_id, name, assigned_name) 
    VALUES (101, 1, 11, 'Test Task 1-11-101', 'Bob');
    INSERT INTO task (id, seq, job_id, name, assigned_name) 
    VALUES (102, 2, 11, 'Test Task 1-11-102', 'Jack');
    INSERT INTO task (id, seq, job_id, name, assigned_name) 
    VALUES (103, 1, 12, 'Test Task 1-12-103', 'Mary');
    INSERT INTO task (id, seq, job_id, name, assigned_name) 
    VALUES (104, 2, 12, 'Test Task 1-12-104', 'Phil');
    INSERT INTO task (id, seq, job_id, name, assigned_name) 
    VALUES (104, 3, 12, 'Test Task 1-12-104', 'Bill');
    INSERT INTO task (id, seq, job_id, name, assigned_name) 
    VALUES (105, 4, 12, 'Test Task 1-12-105', 'Ed');
    INSERT INTO task (id, seq, job_id, name, assigned_name) 
    VALUES (105, 5, 12, 'Test Task 1-12-105', 'Tom');
    INSERT INTO task (id, seq, job_id, name, assigned_name) 
    VALUES (105, 6, 12, 'Test Task 1-12-105', 'John');
    COMMIT;
    Now, if I run a query
    SELECT p.name project_name, j.name job_name, t.name task_name, t.seq, t.assigned_name
    FROM     project p, job j, task t
    WHERE p.id = j.project_id
    AND     j.id = t.job_id
    AND     t.job_id = 12
    ORDER BY 1,2,3,4;
    Then, I get:
    PROJECT_NAME         JOB_NAME             TASK_NAME                   SEQ ASSIGNED_NAME
    -------------------- -------------------- -------------------- ---------- --------------
    Test Project 1       Test Job 1-12        Test Task 1-12-103            1 Mary
    Test Project 1       Test Job 1-12        Test Task 1-12-104            2 Phil
    Test Project 1       Test Job 1-12        Test Task 1-12-104            3 Bill
    Test Project 1       Test Job 1-12        Test Task 1-12-105            4 Ed
    Test Project 1       Test Job 1-12        Test Task 1-12-105            5 Tom
    Test Project 1       Test Job 1-12        Test Task 1-12-105            6 John
    While I would like to:
    PROJECT_NAME         JOB_NAME             TASK_NAME                   SEQ ASSIGNED_NAME
    -------------------- -------------------- -------------------- ---------- --------------------
    Test Project 1       Test Job 1-12        Test Task 1-12-103            1 Mary
    Test Project 1       Test Job 1-12        Test Task 1-12-104            3 Bill
    Test Project 1       Test Job 1-12        Test Task 1-12-105            6 John
    i.e.
    For each combination of project.id/job.id/task.id, I need to get the record with the highest task.seq

    Any ideas? I'm puzzled.

    Thank you.

    I'm on 10g
    SQL> SELECT p.name project_name, j.name job_name, t.name task_name,
      2  max(t.seq) seq,
      3  max(t.assigned_name) keep (dense_rank first order by t.seq desc) assigned_name
      4  FROM project p, job j, task t
      5  WHERE p.id = j.project_id
      6  AND j.id = t.job_id
      7  AND t.job_id = 12
      8  GROUP BY p.name, j.name, t.name
      9  ORDER BY 1,2,3,4
     10  /
    
    PROJECT_NAME         JOB_NAME             TASK_NAME                   SEQ ASSIGNED_NAME
    -------------------- -------------------- -------------------- ---------- --------------------
    Test Project 1       Test Job 1-12        Test Task 1-12-103            1 Mary
    Test Project 1       Test Job 1-12        Test Task 1-12-104            3 Bill
    Test Project 1       Test Job 1-12        Test Task 1-12-105            6 John
    
    SQL> 
    

    SY.

  • need help for query, accumulative sum

    We have a room with two doors, one of which is installed with biometric devices

    so total devices are 4-two IN and two out

    a table we where these enteries are saved:

    name, record type, id,

    a, 1, June 4, 2015 09:00:13 ', '1 - IN'

    "a, 1, June 4, 2015 09:10:13 ', ' 1 - OUT"

    a, 1, June 4, 2015 09:30:13 ', '2 - IN'

    "a, 1, June 4, 2015 11:00:13 ', ' 1 - OUT"

    create table DRC (varchar2 (40) name, identification number, registration timestamp, type varchar2 (10));

    insert into rec values ('a', 1, June 4, 2015 09:00:13 ', '1 - IN');

    insert into rec values ('a', 1, 4 June 2015 09:10:13 ', ' 1 - OUT');

    insert into rec values ('a', 1, June 4, 2015 09:30:13 ', '2 - IN');

    insert into rec values ('a', 1, 4 June 2015 11:00:13 ', ' 1 - OUT');

    I am designing the query result as below:

    power required

    identification, intype intimate outtime outtype

    a, 1, 04/06/2015-09:00:13 1 - IN 04/06/2015-09:10:13 1-OUT

    a, 1, 04/06/2015-09:30:13 IN. 2-04/06/2015 11:00:13 1-OUT

    Displaying data with name = 'b' (adjusted for hh24) added that he does not understand the OP

    with

    REC as

    (select 'a' name, 1 id, the to_date (June 4, 2015 09:00:13 ',' dd-mm-yyyy hh24:mi:ss') (timestamp,"1-IN' type of union double all the)

    Select 'a', 1, to_date (June 4, 2015 09:10:13 ',' dd-mm-yyyy hh24:mi:ss'), '1 - OUT' of all the double union

    Select 'a', 1, to_date (June 4, 2015 09:30:13 ',' dd-mm-yyyy hh24:mi:ss'), '2 - IN' of all the double union

    Select 'a', 1, to_date (June 4, 2015 11:00:13 ',' dd-mm-yyyy hh24:mi:ss'), '1 - OUT' of all the double union

    Select 'b', 2, to_date (June 4, 2015 11:30:13 ',' dd-mm-yyyy hh24:mi:ss'), '2 - IN' of all the double union

    Select 'b', 2, to_date (June 4, 2015 14:00:13 ',' dd-mm-yyyy hh24:mi:ss'), '2 - OUT' Union double all the

    Select 'b', 2, to_date (June 4, 2015 14:30:13 ',' dd-mm-yyyy hh24:mi:ss'), '2 - IN' of all the double union

    Select 'b', 2, to_date (June 4, 2015 18:00:13 ',' dd-mm-yyyy hh24:mi:ss'),'1 - OUT "of the double

    )

    SELECT name, id, to_char (timestamp, 'dd-mm-yyyy hh24:mi:ss') in_time, typ in_type, to_char (outtime, 'dd-mm-yyyy hh24:mi:ss') out_time, outtype out_type

    (select name, id, timestamp, type,

    cases where instr(typ,'IN') > 0 then lead (timestamp) on the end (partition by name, by order of the identification by timestamp) outtime.

    cases where instr(typ,'IN') > 0 then lead (typ) on the end (partition by name, by order of the identification by timestamp) outtype

    REC

    )

    where coalesce (to_char (outtime, 'yyyymmddhh24miss'), outtype) is not null

    order by name, id, in_time

    NAME ID IN_TIME IN_TYPE OUT_TIME OUT_TYPE
    one 1 04/06/2015-09:00:13 1. 04/06/2015-09:10:13 1-OUT
    one 1 09:30:13 04/06/2015 2. IN 04/06/2015 11:00:13 1-OUT
    b 2 04/06/2015 11:30:13 2. IN 04/06/2015 14:00:13 2 OUTPUTS
    b 2 14:30:13 04/06/2015 2. IN 04/06/2015-18:00:13 1-OUT
  • need help for query

    Hello

    I have a table produced, have two columns and below the sample data and I want to select distinct values in this table on the two columns. Please let me know how can achieve us.

    x                                                                y

    ===                                                       ===

    Sony Erricson ~ Lithion Sony Erricson ~ Lithion ~ 6

    Sony Erricson ~ Lithion Sony Erricson ~ Lithion Essentials ~ 2

    Sony Erricson ~ Lithion Sony Erricson ~ Lithion ~ 6

    Lithion ~ Tmobile Lithion Lithion ~ Tmobile Lithion ~ 6

    Sony Erricson ~ Lithion Sony Erricson ~ Lithion ~ 7

    Sony Erricson ~ Lithion Sony Erricson ~ Lithion ~ 8

    output:

    =====

    x                                                                y

    Sony Erricson ~ Lithion Sony Erricson ~ Lithion ~ 6

    Lithion ~ Tmobile Sony Erricson Lithion ~ Lithion Essentials ~ 2

    NULL the Sony Erricson ~ Lithion ~ 7

    NULL the Sony Erricson ~ Lithion ~ 8

    Help is very appreciated.

    THX in advance

    one of the ways below, if this does not help please share create table statement and the data from the sample as insert the script with desired output

    with data
    as
    (
    select 'Sony Erricson~Lithion' prd1,'Sony Erricson~Lithion~6' sub_prd from dual
    union all
    select 'Sony Erricson~Lithion','Sony Erricson~Lithion Essentials~2'  from dual
    union all
    select 'Sony Erricson~Lithion','Sony Erricson~Lithion~6'  from dual
    union all
    select 'Lithion~Tmobile Lithion','Lithion~Tmobile Lithion~6' from dual
    union all
    select 'Sony Erricson~Lithion','Sony Erricson~Lithion~7' from dual
    union all
    select 'Sony Erricson~Lithion','Sony Erricson~Lithion~8' from dual
    )
    select case when rn > 1 then null else prd1 end prd1,
    sub_prd,
    rn2
    from (
    select prd1, sub_prd, row_number() over(partition by prd1 order by prd1) rn,
    row_number() over(partition by prd1,sub_prd order by prd1,sub_prd) rn2 from data
    )
    where rn2 = 1
    order by prd1
    
  • need help for query with case

    Hi, I have the following requirement based on the terms
    Here's the test tables and data
    create table test_r_cd (id , role_code,org_id)
    as 
    select 100,'LOC' ,10 FROM DUAL UNION ALL
    select 100,'LIQ',20  FROM DUAL UNION ALL
    SELECT 100,'STE' ,30 FROM DUAL
    
    CREATE TABLE TEST_SEC_TYP(id,type)
    as
    select 100,1 from dual union all
    select 100,2 from dual 
    
    
    select * from
    test_r_cd cd ,TEST_SEC_TYP typ
    where cd.role_code in (case when (typ.type =1 )
                                             then ('LOC','LIQ')
                                             when (typ.type = 2) 
                                             then ('STE') 
                                             ELSE null
                                             end )
    The expected output is:
    org_id   role_code   type
    10            'LOC'        1       
    20            'LIQ'         1      
    30            'STE'        2    
    Thank you
    SQL> select *
      2  from test_r_cd t1,test_sec_typ t2
      3  where t1.ID = t2.id
      4  and case when role_code in ('LOC','LIQ') then 1
      5           when role_code = 'STE' then 2
      6           else null end = t2.type;
    
            ID ROL     ORG_ID         ID       TYPE
    ---------- --- ---------- ---------- ----------
           100 LOC         10        100          1
           100 LIQ         20        100          1
           100 STE         30        100          2
    
  • Need help with query SQL Inline views + Group

    Hello gurus,

    I would really appreciate your time and effort on this application. I have the following data set.

    Reference_No---Check_Number---Check_Date---description---Invoice_Number---Invoice_Type---Paid_Amount---Vendor_Number
    1234567 11223 - 05/07/2008 -paid for cleaning- 44345563-I-* 20.00 *---19
    1234567 11223 - 05/07/2008 - 44345563 -a--10,00---19 ofbad quality adjustment
    7654321 11223 - 05/07/2008 - setting the last billing cycle - 23543556 - A - 50.00 - 19
    4653456 11223 - 05/07/2008 - paid for cleaning - 35654765 - I - 30, 00-19

    Please ignore '-' added for clarity

    I'm writing a paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, aggregate query Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Type, Invoice_Number, Vendor_Number. When there are no more records I want to display the respective Description.

    The query should return the following data set

    Reference_No---Check_Number---Check_Date---description---Invoice_Number---Invoice_Type---Paid_Amount---Vendor_Number
    1234567 11223 - 05/07/2008 -paid for cleaning- 44345563-I-* 10.00 *---19
    7654321 11223 - 05/07/2008 - setting the last billing cycle - 23543556 - A - 50.00 - 19
    4653456 11223 - 05/07/2008 - paid for cleaning - 35654765 - I - 30, 00-19
    Here's my query. I'm a little lost.

    Select b., A.sequence_id, A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
    de)
    Select sequence_id, check_number, check_date, invoice_number, sum (paid_amount) sum, vendor_number
    of the INVOICE
    Sequence_id group check_date, check_number, invoice_number, vendor_number
    ) A, B OF INVOICE
    where A.sequence_id = B.sequence_id


    Thank you
    Nick

    It seems that this is a duplicate thread - correct me if I am wrong in this case->

    Need help with query SQL Inline views + Group

    Kind regards.

    LOULOU.

  • need help for a conditional query

    guys this is just. as an extension of this post that Frank was helping me. IM reposting because my needs change slightly and im having a hell of a time trying to change the query.
    Here are the previous post.
    need help with query can find data back please help.
    CREATE TABLE "FGL"
      (
        "FGL_GRNT_CODE" VARCHAR2(60),
        "FGL_FUND_CODE" VARCHAR2(60),
        "FGL_ACCT_CODE" VARCHAR2(60),
        "FGL_ORGN_CODE" VARCHAR2(60),
        "FGL_PROG_CODE" VARCHAR2(60),
        "FGL_GRNT_YEAR" VARCHAR2(60),
        "FGL_PERIOD"    VARCHAR2(60),
        "FGL_BUDGET"    VARCHAR2(60)
      )
    data
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','11','00','400');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','1','100');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','1','0');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','11','1','400');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('360055','360055','7200','4730','02','10','1','400');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('360055','360055','7600','4730','02','10','1','400');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','14','200');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','10','14','100');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','14','200');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','2','100');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','11','2','600');
     
     
    I need to find the year of greater subsidy for the granting by a period setting.
    Once I found the great year, I need to check the value of the period 14 this grant for the previous year and add it to the amount of the budget for this grant. However if there is an entry in the biggest year for period 00 so I need to ignore the period 14 of the previous year and the current calculation period + (current period - more great year 00)

    hope that makes sense, so in other words, with the new data above. If I asking me a second period of the grant year 11. I'd end up with $800

    because the greatest year is 11 it contains one point 0 with $ 400, so my total should be
    amount of period $2,600
    period $0 400 - period $2 600 = $200

    600 + 200 = $800

    If I have question period 1 grant 360055 I'd end up just with 800 grnt year 10.

    I tried to edit this query you have provided me with no luck. I tried for several embarrassed day but I'm saying I can just do what im trying to do.
    can you please help me.


    Here's the query provided by frank kulash who graciously put it together for me.
    WITH     got_greatest_year     AS
    (
         SELECT     fgl.*     -- or whatever columns are needed
         ,     MAX ( CASE 
                     WHEN  fgl_period = :given_period 
                     THEN  fgl_grnt_year
                    END
                  ) OVER ()     AS greatest_year
         FROM     fgl
    )
    SELECT     SUM (fgl_budget)     AS total_budget     -- or SELECT *
    FROM     got_greatest_year
    WHERE     (     fgl_grnt_year     = greatest_year
         AND     fgl_period     = :given_period
         )
    OR     (     fgl_grnt_year     = greatest_year - 1
         AND     fgl_period     = 14
         )
    ;
    Miguel

    Hi, Miguel.

    You are waying that when larger year who has: given_period also a period = '00' (or '0', or whatever it is you want to use), then you want to double the budget of the given_period (subtract the '00' budget and do not count '14' year pevious)? If so, add another condition to the CASE statement that decides what you've summarized:

    WITH     got_greatest_year     AS
    (
         SELECT       TO_NUMBER (fgl_grnt_year)     AS grnt_year
         ,       fgl_period
         ,       TO_NUMBER (fgl_budget)     AS budget
         ,       MAX ( CASE
                       WHEN  fgl_period = :given_period
                       THEN  TO_NUMBER (fgl_grnt_year)
                      END
                    ) OVER ()     AS greatest_year
         FROM       fgl
    )
    ,     got_cnt_00     AS
    (
         SELECT     grnt_year
         ,     fgl_period
         ,     budget
         ,     greatest_year
         ,     COUNT ( CASE
                       WHEN  grnt_year     = greatest_year
                       AND       fgl_period     = '00'
                       THEN  1
                         END
                    ) OVER ()          AS cnt_00
         FROM    got_greatest_year
    )
    SELECT       SUM ( CASE
                        WHEN  grnt_year     = greatest_year                    -- New
                  AND       fgl_period     = :given_period                    -- New
                  AND       cnt_00     > 0            THEN  budget * 2     -- New
                        WHEN  grnt_year     = greatest_year
                  AND       fgl_period     = :given_period       THEN  budget
                        WHEN  grnt_year     = greatest_year
                  AND       fgl_period     = '00'            THEN -budget
                        WHEN  grnt_year     = greatest_year - 1
                  AND       fgl_period     = '14'
                  AND       cnt_00     = 0            THEN  budget
                    END
               )          AS total_budget
    FROM       got_cnt_00
    ;
    

    You will notice it is the same as the previous query, I posted, with the exception of 3 lines marked 'new '.

  • Need help for optical safety circuit.

    I buy these parts and prototype with real components, but since I multisim, I thought it would be nice to create the circuit and maybe work through issues I can practically.

    I need a circuit that takes 120 VCA, generates 5 VDC and 1.5Vdc power of optical transmitter and receiver.  I actually use a data port because he has great range and is pretty cheap.  Rather than send the binary code well I just send a light stead that is broken or not broken through doors and windows in my house.  Then the receiver sees this as an entry and order a relay.

    I tried several voltage regulators that come with multisim, but I get an error of execution of my circuit.  Really I can't the 120 VAC to power levels necessary for the functioning of the optics.

    Otherwise I might want to run on a system 120Vdc with battery backup, so throw a 120Vdc up to 20 v DC switching power supply - but I have not found a SMP in the library which takes 120 as input and as output 20.

    Basic plan: 120VAC source-> transform to 24Vac-> Full bridge rectifier to ~ 20 v DC-> voltage capacitor filter on the input of two voltage regulators (1 to 5 VDC, 1 to 1.5Vdc) - then circuit since the two power supply of the transmitter and the receiver.

    I just need help for 5V and 1.5V, from there, I know that the real world circuit will work component tests already carried out.  Thanks for reading.

    I didn't Multism so I can't advise you on the compatible models. I ran the model on semiconductors with slight modifications of format on my SPICE simulator based on Berkeley Spice 3f5. I had to change the format of model resistance semiconductors appeal but has not changed any values.

    The output of your power supply circuit 3 (with 5 V, not the 1.5 V regulator regulator) was 4.99995 V.

    There are a few messages about changing templates published for compatibility Multisim woth. You can search those to see if there are any suggestions on what you'll need to fix in the model.

    Lynn

  • I need help for the upgrade of my current system.

    I need help for the upgrade of my current system.

    I have SBS 2008 with (Exch 2007, SQL 2005, Sharepoint, backupexec 2010 for sbs) licenses.

    I want to make the larger environment using the following:

    (1) apply Virtualization

    (2) apply to the failover process (clustering)

    "(3) the environment must support adding server terminal server, ERP server, exchange server, domain controller, backup manager.

    Storage 4) that supports Raid (1 and 5)

    UTM excellent 6) that supports (SSL VPN, VPN Global)

    suitable backup solution 7)

    (8) good antivirus for clients

    my questions:

    (1) can you provide me with a good design for this environment

    (2) should I choose what operating system:

    Microsoft datacenter or company

    I know datacenter provide us the unlimited VM but needs per processor license

    so if I have two Grouped servers I want to buy 4 licenses

    and just 4 VMs per company license... to say that we have two servers and maintain 8 vms so wat happened if 1 goes down... How can I migrate the 4 virtual machines on the server failed to another server group... ? should I buy enterprise license?

    (3) if I get the SAN storage for data... How can I save this storage... should I get another SAN?

    (4) how can I upgrade SBS stad single server (windows standrad) without losing the licenses as Exch 2007, SQL 2005, sharepoint.is it a must to buy an edition full std server or there is a way to upgrade (license wise, I mean)?

    (5) what about win2k8 license for VM:

    lets say we have physical that has windows license so that enough to have windows for VM or should I buy windows for VM licenses?

    (6) can I use backExec license for SBS with windows 2008 standard

    (7) who better to virtualization AMD or INTEL

    (8) hyper V or VMware?

    (9) what of Microsoft data protection Manager... is this good?

    (10) what virtual machine manager? What are the benefites keys

    Thanks in advance

    Hello AnasAI,

    You can find the Server forums on TechNet support, please create a new post at the following link:

    http://social.technet.Microsoft.com/forums/en/category/WindowsServer/

  • I need help for activation of the real administrator account.

    I have a problem with Adobe reader 9 standard, Adobe customer service asked the unhide real administrator account before you can continue to help me.

    I need help for that.

    http://www.Vistax64.com/tutorials/67567-administrator-account.html

    http://www.howtogeek.com/HOWTO/Windows-Vista/enable-the-hidden-administrator-account-on-Windows-Vista/

    Read the above info.

    See you soon. Mick Murphy - Microsoft partner

  • I need help for my reader to USB drive on my windows 10 ACER?

    I need help for my reader to USB stick on my chrome windows 10 plug ins acer. Can you help me?

    What Adobe application that you use?

    This is the Adobe Media Encoder forum, and you did not mention anything on this subject. If you can let us know what Adobe application, you need help, we can help you make the right forum.

    Thank you

    Regalo

  • Hello, I need help for cancel the payment on my adobe account.

    Hello, I need help for cancel the payment on my adobe account. I'm from Peru, Im paying a monthly fee as a student. Help, please...

    Cancel your membership creative cloud

  • Hello, need help for Adobe Reader DC playing animation files that are specified in the pdf output by script Latex Beamer. My Adobe Reader DC refuse to open any format that I gave him.  Thank you very much

    Hello, need help for Adobe Reader DC playing animation files that are specified in the pdf output by script Latex Beamer. My Adobe Reader DC refuse to open any format that I gave him.  Thank you very much

    Hey ihorl18351266,

    Please note that you can open PDF files using only the CD player. Any other format will not be supported by the software.

    Kind regards

    Ana Maria

Maybe you are looking for