Help of query output

Oracle 11.2.0.1

Windows

create the table storetab

(

deptName varchar2 (20).

grpcode varchar2 (10),

grpname varchar2 (10),

ItemName varchar2 (10),

Plug varchar2 (10),

number of quantity,

number of rates,

number amount

);

insert into storetab values ('KEEP', 'GRP1', 'GRP1', 'ITEM1', ", 0,0,0);

insert into storetab values ('KEEP', 'GRP2', 'GRP2', 'ITEM2', ", 0,0,0);

insert into storetab values ('KEEP', 'GRP3', 'GRP1', 'ITEM3' ", 0,0,0);

insert into storetab values ('BUY', 'GRP7', 'GRP9', 'ITEM6' ", 0,0,0);

insert into storetab values ('SALE', 'ACM2', 'GRP3', 'ITEM4' ", 0,0,0);

insert into storetab values ('SALE', 'ACM5', 'GRP6', 'ITEM5' ", 0,0,0);

insert into storetab values ('SALE', 'QOW2', 'GRP3', 'ITEM7' ", 0,0,0);

insert into storetab values ('KEEP', 'IDS9', 'GRP10', 'ITEM1', ", 0,0,0);

insert into storetab values ('KEEP', 'KKZ0', 'GRP2', 'ITEM6' ", 0,0,0);

insert into storetab values ('ACCOUNTS', 'GRP3', 'GRP23', 'ITEM4' ", 0,0,0);

insert into storetab values ('IT', 'PQM7', 'GRP221', 'ITEM2', ", 0,0,0);

insert into storetab values ('IT', 'GRP1', 'GRP32', 'ITEM3' ", 0,0,0);

insert into storetab values ('IT', 'PQM3', 'GRP1', 'ITEM5' ", 0,0,0);

Select * from storetab;

GRPCODE DEPTNAME GRPNAME ITEMNAME QTY FORM THE RATE AMOUNT

-------------------- ---------- ---------- ---------- ---------------------------------------- ---------- ---------- ----------

STORE                GRP1      GRP1      ITEM1                                                    0    0          0

STORE                GRP2      GRP2      ITEM2                                                    0    0          0

STORE                GRP3      GRP1      ITEM3                                                    0    0          0

PURCHASE GRP7 GRP9 ITEM6 0 0 0

SALES                ACM2      GRP3      ITEM4                                                    0    0          0

SALES                ACM5      GRP6      ITEM5                                                    0    0          0

SALES                QOW2      GRP3      ITEM7                                                    0    0          0

STORE                IDS9      GRP10      ITEM1                                                    0    0          0

STORE                KKZ0      GRP2      ITEM6                                                    0    0          0

ACCOUNTS GRP23 ITEM4 GRP3 0 0 0

IT                  PQM7      GRP221    ITEM2                                                    0    0          0

GRPCODE DEPTNAME GRPNAME ITEMNAME QTY FORM THE RATE AMOUNT

-------------------- ---------- ---------- ---------- ---------------------------------------- ---------- ---------- ----------

IT                  GRP1      GRP32      ITEM3                                                    0    0          0

IT                  PQM3      GRP1      ITEM5                                                    0    0          0

13 selected lines.

Power required:

GRPCODE          GRPNAME          ITEMNAME     SPECS     QTY     RATE     AMOUNT
ACCOUNTS--->GRP3          GRP23          ITEM4
IT--->PQM7          GRP221          ITEM2
GRP1          GRP32          ITEM3
PQM3          GRP1          ITEM5
PURCHASE--->GRP7          GRP9          ITEM6
SALES--->ACM2          GRP3          ITEM4
ACM5          GRP6          ITEM5
QOW2          GRP3          ITEM7
STORE--->GRP1          GRP1          ITEM1          
GRP2          GRP2          ITEM2     
GRP3          GRP1          ITEM3
IDS9          GRP10          ITEM1
KKZ0          GRP2          ITEM6

Thank you.

SQL > select grpcode
2, grpname
3, itemname
4, plug
5, Qty
6, rate
7, amount
8 of storetab
model 9
10 partition by (deptname)
dimension 11 by (row_number() on NWR (partition by deptname order grpcode))
12 measures (cast (grpcode as varchar2 (50)) grpcode, grpname, itemname, dname, deptname, qty, rate, amount)
13 rules upsert
(14)
15 grpcode [0] = dname [1] | '----->'
16)
Order 17
18 by deptname
19, NWR;

GRPCODE GRPNAME ITEMNAME QTY CHARGE RATE CARD
------------------------- ---------- ---------- ---------- ---------- ---------- ----------
ACCOUNTS--->
GRP3                      GRP23      ITEM4                          0          0          0
IT--->
GRP1                      GRP32      ITEM3                          0          0          0
PQM3                      GRP1       ITEM5                          0          0          0
PQM7                      GRP221     ITEM2                          0          0          0
PURCHASE--->
GRP7                      GRP9       ITEM6                          0          0          0
SALES--->
ACM2                      GRP3       ITEM4                          0          0          0
ACM5                      GRP6       ITEM5                          0          0          0
QOW2                      GRP3       ITEM7                          0          0          0
STORE--->
GRP1                      GRP1       ITEM1                          0          0          0
GRP2                      GRP2       ITEM2                          0          0          0
GRP3                      GRP1       ITEM3                          0          0          0
IDS9                      GRP10      ITEM1                          0          0          0
KKZ0                      GRP2       ITEM6                          0          0          0

18 selected lines.

SQL >

Tags: Database

Similar Questions

  • Need help with query outputing group names

    I'm trying to find a way for groups of output headers, then all the records in each group etc header. It would be easy, except there is a key with what I want to do.

    Normally, if I have this data set (that I've ' borrowed' a site that showed the closest to what I was looking for):

    Example table:

    TABLE [number]

    (Name, NUMBER)

    Dave Bower 843-444-4444

    Dave Bower 843-555-5555

    Matthew Small 843-111-1111

    Matthew Small _843-222-2222

    Matthew Small 843-333-3333

    I could use the following code:

    < cfoutput query = "somequery" group = "name" >

    #name # < br >

    < cfoutput >

    #phonenumber # < br >

    < / cfoutput >

    < hr >

    < / cfoutput >

    And get this:

    Dave Bower

    843-444-4444.

    843-555-5555.

    -------------------

    Matthew Small

    843-111-1111.

    843-222-2222.

    843-333-3333.

    -------------------

    BUT my actual tables are not set up like that. Rather than recording of every name of every record, I would have an ID that is the foreign key to another table.

    Current table set up is as follows:

    TABLE [people]

    (ID, NAME)

    1 Dave Bower

    2 small Matthew

    TABLE [Phones]

    (PEOPLE_ID NUMBER)

    1 843-444-4444

    1 843-555-5555

    2 843-111-1111

    2 843-222-2222

    2 843-333-3333

    If this output actually would this give me with my current setup and request above code:

    1

    843-444-4444.

    843-555-5555.

    -------------------

    2

    843-111-1111.

    843-222-2222.

    843-333-3333.

    -------------------

    How can I keep my current setup but create a query that produces the same result from the top? (The table names of people like the group headers, but data from the phones table under that output)

    You must gather the two tables, and then group the output.

    Something along the lines of the (may vary slightly depending on your DB and the exact table structure)

    SELECT ppl.name, ph.number

    PEOPLE ppl

    INNER JOIN phones ph ON ppl.id = ph.people_id

    ORDER BY ppl.name

    See you soon

    Kai

  • Help of query output: display self-referential table

    Hello

    I'm trying to display a table referring to itself in a cfoutput. I'll start by showing some of the data in the table.

    There are only 3 columns, pl_id (auto increment id pri - keys), pl_name and pl_parent_id (0 if it is a parent, otherwise it is the value of pl_id for the parent).

    pl_id pl_name pl_parent_id
    1 country 0
    Food 2 0
    3. WE 1
    4 Japan 1
    5 Burger 2
    6 Idaho 3
    Florida 7 3
    8 cheese 2

    What I am trying to output is something like this:
    Country - United States - Idaho (3 levels here) or
    Country - United States - Florida (or if there are only 2 levels as the following line)
    Food - cheese

    I tried using a cfoutput with a cfloop as well as grouping but does not have a chance. Could someone clear my head on this one?

    Thank you very much

    Joe

    PS. Adobe should really use a police fixed-width for these forums, it is impossible to align the table info!

    Well Yes, who do. After you have changed a little this puppy will be completed. Thanks to the people who reduced to chips in this thread.

  • Insert a blank line in the query output

    Is it possible to insert a blank line between two rows of the query output?

    In the EMP table, the column LINES is as follows:

    LINES
    1
    2
    3
    4
    1
    2
    3
    1
    2
    3
    4
    5

    I want to insert a blank line after every 1

    Please suggest.

    Sanjay

    I'm quite puzzled why you need rows in the dataset returned by a select statement that is empty.
    If you are using Oracle reports to the release date, you define the presentation of the report to have spaces between the rows returned by the select and have do not need to have the select statement returns a blank line after each line of data. If the output should be obtained by using another client, I think that the customer will have facilities for output formatting.

    Admit that you really need "blank lines" between data lines, I see only one way: use a temporary table and do an insert into select temporary_table (...) ... from... where... Then, in this temporary table, you can insert 'empty rows', which is actually not really empty, because they must have some fields that give the order of the rows. And then select in temporary_table, you place your order by the columns that are used to give the order for the release.
    Thus

    insert into temporary_table (
    ....
    )
    select ...
    from ...
    where ...
    ;
    for r in (
    select col1, col2, col3  -- columns used for order by
    from temporary_table
    order by col1, col2, col3
    )
    loop
      insert into temporary_table (col1, col2,col3, col4)
      values (r.col1,r.col2,r.col3, null);
    end loop;
    -- this way, a select * from temporary_tabel order by col1, col2, col3, col4 will return a blank row after each data row
    
  • 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.

  • Blank line between lines of query output

    Is it possible to add a blank line between two rows of the query output?

    Sanjay

    user12957777 wrote:
    Is it possible to add a blank line between two rows of the query output?

    Sanjay, it's a problem of client - customer is responsible for rendering data. If whites are needed, then the customer must make as a result.

    Under the projection of the cursor SQL is not a good idea.

  • Help with query Oracle?

    Help with query Oracle?

    Take a look at the query

    Select channel_desc, sum (unit_cost), AVG (Unit_price) of channels C, cost S

    where C.channel_id = S.channel_id

    Group 1,2,3



    the first time the error is "channel_desc not a group by expression"-desc is a varchar type there are 6 channels

    II remove the group by clause and then pops up an error "" not only - group expression to group "".

    All the ideas!

    Select channel_desc, sum (unit_cost), AVG (Unit_price) of channels C, cost S
    where C.channel_id = S.channel_id
    Channel_desc group

  • 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.

  • How to remove the newline from the query output?

    Hello

    How to remove the newline from the query output?
    have tried to replace select (column_name, Chr (10), ' ') from table_name.

    Published by: GreenHorn 11 Sep, 2008 12:53 AM

    Please consider, that windows uses a sequence of chr13 | Chr (10) Unix uses only a single character CHR (10).
    The new line characters may depend on the operating system.

    You might consider with:

    Replace (replace (column_name, Chr (13) |)) CHR (10), ' '), CHR (10),' ')

    Hartmut

    Published by: hartmutm on 11.09.2008 01:32

  • Need help with the output of the query formatting

    Hello

    Here are the scripts to create the table and create test data:

    create table result (acct number(10), acct_nm varchar2(100), stage varchar2(10), target_pc number(10,2), long_target_pc number(10,2))
    /
    Insert into RESULT
       (ACCT, ACCT_NM, STAGE, TARGET_PC, LONG_TARGET_PC)
    Values
       (47042, 'Dora the explorer', 'AFTER', 33.6, 48)
    /  
    Insert into RESULT
       (ACCT, ACCT_NM, STAGE, TARGET_PC, LONG_TARGET_PC)
    Values
       (47042, 'Dora the explorer', 'BEFORE', 33.6, 48)
    /  
    Insert into RESULT
       (ACCT, ACCT_NM, STAGE, TARGET_PC, LONG_TARGET_PC)
    Values
       (41142, 'Bob the Builder', 'AFTER', 9.18, 20.4)
    /  
    Insert into RESULT
       (ACCT, ACCT_NM, STAGE, TARGET_PC, LONG_TARGET_PC)
    Values
       (41142, 'Bob the Builder', 'BEFORE', 9.18, 20.4)
    /  
    Insert into RESULT
       (ACCT, ACCT_NM, STAGE, TARGET_PC, LONG_TARGET_PC)
    Values
       (41086, 'Sofia the first', 'AFTER', 17.96, 51.3)
    /  
    Insert into RESULT
       (ACCT, ACCT_NM, STAGE, TARGET_PC, LONG_TARGET_PC)
    Values
       (41086, 'Sofia the first', 'BEFORE', 2.98, 8.5)
    /  
    Insert into RESULT
       (ACCT, ACCT_NM, STAGE, TARGET_PC, LONG_TARGET_PC)
    Values
       (41086, 'Sofia the first', 'BEFORE', 14.98, 42.8)
    /  
    COMMIT
    /
    
    

    I need output in the following format when I query this table:

    Account         Account Name        Stage       Target PC       Long Target PC
    41086           Sofia the first   
                                       BEFORE            2.98                  8.5
                                                        14.98                 42.8
                                       AFTER            17.96                 51.3
    41142           Bob the Builder                                                     
                                       BEFORE            9.18                 20.4
                                       AFTER             9.18                 20.4
    47042           Dora the explorer                                                     
                                       BEFORE           33.6                  48.0
                                       AFTER            33.6                  48.0
       
    Total Accounts = 3
    
    
    

    Here is what I tried but it does not gives me out I want (below referred to as the code):

    spool c:\break_test.txt
    column acct format 9999999999
    column acct_nm format a50
    column stage format a15
    column target_pc format 999.99
    column long_target_pc format 999.99
    break on acct, acct_nm, stage
    select * from result order by acct, stage desc
    
    
    

          41086 Sofia the first                                    BEFORE              2.98           8.50
          41086 Sofia the first                                    BEFORE             14.98          42.80
          41086 Sofia the first                                    AFTER              17.96          51.30
          41142 Bob the Builder                                    BEFORE              9.18          20.40
          41142 Bob the Builder                                    AFTER               9.18          20.40
          47042 Dora the explorer                                  BEFORE             33.60          48.00
          47042 Dora the explorer                                  AFTER              33.60          48.00
    
    

    Please tell us how to get there.

    Thanks in advance!

    Go back and check the syntax of the PAUSE command.

    SQL> column long_target_pc format 999.99
    SQL> break on acct, acct_nm, stage
    SP2-0158: unknown BREAK option "acct_nm,"
    

    The syntax must be

    sql> break on acct on acct_nm on stage
    

    SQL formatting * more reports

  • Need help with query

    Have the rank as below,

    name of the sum

    100 A1

    -A2 200

    A3 300

    50 A1

    -A2 700

    A3 80

    10 A1

    -A2 90

    30 A3

    Need to query to extract the output like this:

    B1                     B2

    A1 + a3 (Sum) A2 (sum)

    Please help me out of this...

    Hello

    It is difficult to understand what you want... A guess based on many assumptions:

    -B1 and B2 are column headers,
    -"A1 + A3" and "A2" in the 'exit' is simply to indicate that you want the sum of the amounts for the first names.

    -Some of the AI have all their amounts > = 0, others have their amounts<=>
    -You want to make the sum of all positive numbers in the first column and all the negatives in the second column

    SELECT SUM (GREATEST (0, t.amount)) b1

    , B2 SUM (LESS (0, t.amount))

    MYTABLE t

    ;

    (I think there is only a bit of luck it's really what you want, but provide a full test case and the output that you really want and why not, try to explain / explicit rules, then we can give better help)

    Best regards

    Bruno Vroman.

  • 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.

  • Helps the query using LESS

    Hello Experts

    I can't in select the record_sequence in the output. Please see the part of the desired effect.
    Please help solve this problem.

    Is the version of Oracle, I'm working on that

    Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production
    With partitioning, OLAP, Data Mining and Real Application Testing options

    Thank you

    RB

    TABLE1 AS
    (
    SELECT '28' EXAM_CD1, EXAM_CD2 '29', '10' EXAM_CD3, 111' CAND_ID FROM DUAL UNION ALL
    SELECT '21' EXAM_CD1, EXAM_CD2 '39', '20' EXAM_CD3, 112' CAND_ID FROM DUAL UNION ALL
    SELECT '22' EXAM_CD1, EXAM_CD2 '49', '30' EXAM_CD3, 113' CAND_ID FROM DUAL UNION ALL
    SELECT 'EXAM_CD1 23', '59' EXAM_CD2, EXAM_CD3 ' 40', 114' CAND_ID FROM DUAL UNION ALL
    SELECT '24' EXAM_CD1, EXAM_CD2 '69', '50' EXAM_CD3, 115' DOUBLE CAND_ID)
    AS TABLE2
    (
    SELECT EXAM_CD '28', '111' CANDID, 1 RECORD_SEQ OF DOUBLE UNION ALL
    SELECT '30' EXAM_CD, '113' CANDID, 2 RECORD_SEQ FROM DUAL UNION ALL
    SELECT EXAM_CD '94', '111' CANDID, 3 RECORD_SEQ OF DOUBLE UNION ALL
    SELECT EXAM_CD '69', '115' CANDID, 4 DOUBLE RECORD_SEQ)
    (
    SELECT EXAM_CD FROM TABLE2, CANDID
    LESS
    SELECT CAND_ID,
    MAX (L CASE WHEN 1 EXAM_CD1 THEN WHEN 2 THEN of OTHER EXAM_CD2 EXAM_CD3 END) exam_code
    FROM TABLE1,
    (SELECT LEVEL L FROM DUAL CONNECT BY LEVEL < = 3)
    CAND_ID GROUP, L)

    The aim is

    CAND_ID, EXAM_CD, RECORD_SEQ
    * 111, 94, 3 *.

    Hello

    Rb2000rb65 wrote:
    The solution use not less as long as I get my results using the latest features, it is good with me.

    Good idea!
    UNMIS is not the best tool for this task. The saved query gets the exam_cd and the Candide you want, but you can't find the record_seq because there of nothing like record_seq in table1.

    You can do this way:

    SELECT     *
    FROM     table2     m
    WHERE     NOT EXISTS (
                        SELECT  1
                    FROM    table1
                    WHERE   m.candid      = candid
                    AND     m.exam_cd  IN ( exam_cd1
                                             , exam_cd2
                                 , exam_cd3
                                 )
                 )
    ;
    

    I guess you could use LESS, like this

    SELECT     *
    FROM     table2
    WHERE     (exam_cd, candid)
         IN (
                SELECT  ...  -- The MINUS query you posted goes here
            )
    ;
    

    but it is unecessarily complicated.

  • need help with query can find data back please help.

    Hi guys I have a table such as
    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)
      )
    and I have a data as such
    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 ('240055','240055','7600','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','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','7600','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','7470','4730','02','10','2','200');
    I need bascially to get the total of the budget column. However this is not as simple as it sounds good (at least not for the me.) totals carried forward to the new period. you will notice that you have a period column. Basically, what im is that
    fgl_grant_year 10 1 period = account 7600 its $100 and $100 for the period 2, you see $ 100 more, it wants to not be added to this is the door on the balance. that is $100.
    So im trying to write a query that basically does the following.
    IM considering a period for the sake of this example let period 1 I get anything else. I find that the greates contributes dumpster year the amount for the period 14 (which corresponds to the total of the previous year) and add it to the amount of the current year. in this case period 1 grnt_year 11
    the expected result is therefore $700
    240055     240055     7240     4730     02     10     14     200
    240055     240055     7600     4730     02     10     14     100
    240055     240055     7600     4730     02     11     1     400
    do not forget that I am not given a just a period of the year.
    any help you guys can give would be immensely appreciated. I tried to get this to work for more than 3 days now.
    Finally broke down and put together this post

    Published by: mlov83 on Sep 14, 2011 20:48

    Hello

    Thanks for posting the CREATE TABLE and INSERT statemnts; It is very useful.

    I'm not sure that understand your needs.
    The correct output will be just one line:

    TOTAL_BUDGET
    ------------
             700
    

    or will it be 3 ranks that you posted? I guess you want just line after line.

    Do you mean that you are given a period (for example, 1).
    First you have to find the largest gfl_grnt_year which is related to this period (in this case, 11).
    Then you need to add fgl_budget lines that have to be
    (1) the specific period and the largest fgl_grnt_year, or
    (2) perriod = 14 and the previous fgl_grnt_year (in this case, 10).
    Is this fair?

    If so, here's a way to do it:

    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
         )
    ;
    

    If you want the 3 lines you have posted, then change the main SELECT clause to ' SELECT * ' (or, instead of *, youcan the columns you want to see the list).

  • need help with query-please help

    Hi all
    I want to convert the query to a view online below. I write examples of data that I used
    create table pde(empno number(10),act_hour varchar(10 byte));
     
    Table created
     
    insert into pde values(211,'12:20');
    insert into pde values(211,'06:00');
    insert into pde values(213,'07:00');
    insert into pde values(213,'07:20');
     
    WITH  got_total_hours     AS
    (
         SELECT SUM (   TO_NUMBER (SUBSTR (act_hour, 1, 2))
                    + ( TO_NUMBER (SUBSTR (act_hour, 4, 2))
                      / 60
                      )
                    ) AS total_hours  
         from      pde
     
    )
    SELECT        TO_CHAR (FLOOR (total_hours))
           || ':'
           || TO_CHAR ( MOD (total_hours, 1) * 60
                  , 'fm00'
                   )     AS hh_mm,empno,act_hour
    FROM     got_total_hours ,pde
     
    this is the output i am getting  
     
    HH_MM  EMPNO  ACT_HOUR
    32:40     211     12:20
    32:40     211     06:00
    32:40     213     07:00
    32:40     213     07:20
    
    i tried changing the above query to an inline view given below
    SELECT        TO_CHAR (FLOOR (total_hours))
           || ':'
           || TO_CHAR ( MOD (total_hours, 1) * 60
                  , 'fm00'
                   )     AS hh_mm,act_hour from(SELECT SUM (   TO_NUMBER (SUBSTR (act_hour, 1, 2))
                    + ( TO_NUMBER (SUBSTR (act_hour, 4, 2))
                      / 60
                      )
                    ) AS total_hours  
         from      pde)
    
    ORA-00904:''ACT_HOUR":invalid identifier
    Please help me
    thanking in advance
    Kind regards
    oracleuser

    Published by: makdutakdu on January 5, 2010 11:41

    Just push "with the clause" within the main request and give an alias of the table for him... something like

     SELECT TO_CHAR (FLOOR (total_hours))
      || ':'
      || TO_CHAR ( MOD (total_hours, 1) * 60 , 'fm00' ) AS hh_mm,
      empno                                                     ,
      act_hour
       FROM
      (SELECT SUM ( TO_NUMBER (SUBSTR (act_hour, 1, 2)) + ( TO_NUMBER (SUBSTR (act_hour, 4, 2)) / 60 ) ) AS total_hours
         FROM pde
      ) got_total_hours ,
      pde
    

    Ravi Kumar

Maybe you are looking for