How do the sum of several columns with grouping different criteria

Currently I am doing a project where I needed to generate the report which retrieved from the table. the table as shown below

CURRENCY_A AMOUNT_A CURRENCY_B AMOUNT_B CURRENCY_C AMOUNT_C

USD 100 EURO 100 POUNDS 100

EURO 200 BOOKS 200 200 USD

BOOKS USD EURO 300 300 300

My expectations is the grand total of the Group (AMOUNT_A + AMOUNT_B + AMOUNT_C) currency

USD:

EURO:

BOOKS:

Is it possible to do this output in oracle alone?

Hello

UNPIVOT before consolidation / summary:

SELECT currency, flat

DE)

SELECT CASE WHEN 1 THEN currency_a n

WHEN 2 THEN currency_b

WHEN 3 currency currency_c end THEN

CASE WHEN 1 THEN amount_a

WHEN 2 THEN amount_b

WHEN 3 amount of end of amount_c THEN

From your_table

CROSS JOIN (select column_value table n (sys.odcinumberlist (1,2,3))) t

)

GROUP BY currency

Tags: Database

Similar Questions

  • The sum of a column with 2 values using Forms 6i

    Hello world
    I have 2 blocks, a main block and the other is
    my block of retail and my block of retail element is a list item
    When I have 2 options to choose, we're for described video and the
    Another is for delay.
    My question is:
    How can I add an item in my form where I will summarize the
    amount of A and L is inserted on this column?

    I forgot about it. DECODE cannot be used in SQL. This time I tried the solution myself in Forms 6i, so I know it works. Set the formulas

    InStr(:Item,'A')

    This returns 1 if the value is A, 0 otherwise. Ditto for the L value of course.

  • How to change the extensions on several files with Windows 7?

    * Original title: Extentions

    How to change the extensions on several files with Windows 7?

    You hear no doubt, is that your movie software will only recognize certain types of image file formats.  If this is the case, you will need to reformat format files to any format PNG is recognizable by the software.

    Rather than we guess, please identify your «film» software

    Download and install IrfanView, which is a free utility for images.  http://www.IrfanView.com/

    IrfanView has the ability to read a great many formats of image files.  It can also convert image files formats.  And even better - for you - it can do all these things on a batch of files.

    As test, after I installed IrfanView, open one of your PNG files.  Now click on file > save as, and select the 'Save as Type' to be little matter the file type of your movie software will accept.  Save the file.  Make sure your movie software can accept the new file.

    Once you are convinced that you can modify files that you have in a format that you can use, use IrfanView

    File > Batch Conversion/Rename command.  If necessary, see IrfanView help on this topic.

  • Please let me know how I can add a new column with a constraint not null, table already has data, without falling off the table... Please help me on this issue...

    Hello

    I have an emp_job_det with a, b, c columns table. Note that this TABLE ALREADY has DATA OF THESE COLUMNS

    IAM now add a new column "D" with forced not null

    Fistly I alter the table by adding the single column "D", if I do, the entire column would be created with alll of nulls for the column DEFAULT D

    ALTER table emp_job_det Add number D; -do note not null CONSTRAINT is not added

    Second... If I try to add the constraint not null, get an eoor as already conatained null values...

    (GOLD)

    In other words, if I put the query

    ALTER table emp_job_det Add number D NOT NULL; -THROWS ERROR AS TABLE ALREADY CONTAINS DATA

    So my question is how how can I add a new column with a constraint not null, table already has the data, without falling off the table

    Please help me on this issue...

    Add the column without constraint, then fill the column. Once all the rows in the table are given in the new column, and then add the constraint not null.

  • Calculation of the sum of a column on a XML editor RTF with NULL values

    Hello

    I have a problem to get the sum of a column in XML editor RTF, if one of the lines has a null value.

    say, I have 4 columns and values

    CASES1:
    NULL, NULL, 4, NULL
    Sum, I expect is: 4

    CASE2:
    NULL, NULL, NULL, NULL
    I'm waiting for is a null

    Is there a way to do this?

    Thank you
    Anita

    Try this

    AMT's column

  • Is there an alternative way to compute the sum of a column without accessor view

    Hi Experts,

    JDev 12 c,

    I have a column A and I'm total calculation of column A with the same VO as a view accessor. And calculating as below

    EmployeeViewAccessor.sum ("ColumnA").

    But this way, it loads the VO 2 times as it loads the accessor aswell.

    So is there an alternative way to calculate the sum of a column.

    Thank you

    Roy

    Use the analytical function, please see below Ex

    http://docs.Oracle.com/CD/B19306_01/server.102/b14200/functions163.htm

  • only get a single photo on board contact despite the selection of several columns.

    When you select the photo and contact sheet then, there is only a single photo in the upper left column. Unable to get several copies despite the selection of several columns.

    The contact sheet shows only the photos you selected in the library before going to the page of Contacts.

    If you want to have multiple copies of the same image, you need to duplicate this image enough times so that you get the number you want on the contact page.  Select the thumbnail and use the key combination command + D to duplicate the photo.

    Select all duplicate images, and then go to the Contacts option in the printing process.

  • Hello, I would like to know if I can install the software on several computers with my creative cloud. Thank you

    Hello, I would like to know if I can install the software on several computers with my creative cloud. Thank you

    Hello

    You can install and activate creative Cloud on two computers applications, regardless of the operating system of the individual associated with the composition of the creative cloud. See the page of the product license agreements for more information.

    Link: http://www.adobe.com/in/products/creativecloud/faq.html#what-cc

    Let us know if this helps!

  • I'm trying to upgrade a site from Muse and it keeps telling me that the site has been created with a different version of Muse. I have updated Muse and still can not access the site to make changes.

    I'm trying to upgrade a site from Muse and it keeps telling me that the site has been created with a different version of Muse. I have updated Muse and still can not access the site to make changes.

    Hi rgarden95,

    Can you please confirm the exact version of Muse, you open the file with?

    To check the version of Muse, please click Help-> on Adobe Muse CC.

    Kind regards

    Akshay

  • How to get the last row and the sum of all columns in a query

    Hello

    is there a way to get the last record for a column and the sum of all the Archives to another column in the same query.

    Best regards

    You must set your needs correctly volunteers to help here...

    Your data are not good enough to bring you a precise solution. Purpose, you do not have a column, which draws a distinction between the first and the last entry.

    The solution becomes easy based on your design.

    I introduced a grouping called 'id' column and a time column called 'time_of_insert' (only this way you can say with confidence that you can differentiate between the first and last (also a foolproof solution) - you can possibly use sequence (instead of date but if you say that you can insert two lines at the same time) ((and then likely sequence would be a better choice to differentiate instead of a timestamp field) etc...)

    With your sample data, something like this can be done to get the desired results.

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

    WITH dataset AS

    (SELECT 1 id, 10 used, 8 remain, systimestamp + 1/24 time_of_insert FROM DUAL

    UNION ALL

    SELECT the 1 id, 1, 7, systimestamp + 2/24 FROM DUAL

    UNION ALL

    SELECT the id 1, 2, 5, systimestamp + 3/24 FROM DUAL

    UNION ALL

    SELECT 1 id, 1, 0, systimestamp + 4/24 FROM DUAL

    UNION ALL

    SELECT 1 id, 0, 0, systimestamp + 5/24 FROM DUAL

    UNION ALL

    SELECT the 1 id, 1, 4, systimestamp + 6/24 FROM DUAL)

    SELECT *.

    (SELECT SUM (used) ON sum_all)

    FIRST_VALUE (stay)

    COURSES (PARTITION BY id ORDER BY time_of_insert DESC)

    last_row

    Of THE dataset)

    WHERE ROWNUM = 1;

    Output:

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

    SUM_ALL LAST_ROW

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

    15                  4

    See you soon,.

    Manik.

  • How graphic how the sum of several metrics of in a dashboard.

    I'm looking to find out how the graph of the sum of multiples of the metric, as CPU ready, or latency of disk in one graph on a dashboard / report.

    An example would be showing collective management s VM in balloning of CPU and memory of the pool on line on a chart.

    Thank you!

    If you want the chart to reflect everything that you can do the stacking graphics option which will be sleeping all values.

  • Does anyone know how to change the date of the capture of several images with LR CC?

    Does anyone know how to change the date of the capture of several images in LR CC

    Hi Jguy,

    Please see this thread time changing capture several Images on

    Let us know if this helps

    Kind regards

    Assani

  • How to use break a column during extraction of the results of several columns

    Hi friends
    I am confused a bit I query to retrieve results of 3 tables and I want to use the pause on a column, but it is not work goes I just described my query

    SQL > select a.-, a-, b-, b-, c. - a, b, c, where certain conditions
    When I'm with break on a.-, a..
    the pause does not work

    BREAKING does not support multiple columns. You can break on a.
    http://docs.Oracle.com/CD/B19306_01/server.102/b14357/ch12009.htm

  • [8i & 10g XE] How to compare a column with the text of a column with numbers

    This is probably a simple question, but I can't seem to find the answer. I tried variations on use to_number to_char and interpreters, all nothing will do.

    The real problem is that I have a table with a column of numbers in a database 8i (datatype = NUMBER (3)) and a column with the text (datatype = CHAR (3)), and I need to compare two values.

    This table has thousands of lines, but here's an example of the data in these two columns:
    TXT     CHR
    -----------
    001     1
    001     2
    002     2
    XXX     1
    003     3
    What I want to do is select the lines where the TXT and CHR VALUES do not match, then it would be (given my example):
    TXT     CHR
    -----------
    001     2
    XXX     1
    But, I'm having difficulties in comparing two columns, because they are not the same type of data.

    I tried to work on a simplified version of the problem in the 8i database both my 10g XE database:
    SELECT     *
    FROM     (
         SELECT     1.000               AS nbr
         ,     TO_CHAR(1.000,'000')     AS txt
         ,     CAST('001' AS CHAR(3))     AS chr
         FROM     dual
         )
    WHERE     txt = chr
    ;
    But this also returns any line, and it isn't even the "XXX" in the text column to treat in this example.

    Can someone help me understand what it is that I'm missing?

    Thank you!

    Hello

    user11033437 wrote:
    This is probably a simple question...

    Simple if you know the secret; maddening if you do not have.

    ... I tried to work on a simplified version of the problem in the 8i database both my 10g XE database:

    SELECT     *
    FROM     (
         SELECT     1.000               AS nbr
         ,     TO_CHAR(1.000,'000')     AS txt
         ,     CAST('001' AS CHAR(3))     AS chr
         FROM     dual
         )
    WHERE     txt = chr
    ;
    

    Try:

    TO_CHAR (1.000, 'FM000')
    

    By default, TO_CHAR leaves place the beginning of the string to a sign less, in which case he should ever one, TO_CHAR (1,000, '000') returns makes 4 characters, not 3. "FM" in the format said TO_CHAR do not add a space.

    If it does not, after the release of DUMP (txt) for the few lines that you can't match, so that we can see exactly what is in them.

  • The research of a column with comma separated values with ora-text

    I use the Oracle 11 g 2 XE and Oracle Text to a web search engine.

    I've now created and text indexed a CLOB keywords column that contains words separated by spaces. This allowed me to expand the search, as Oracle Text returns the rows that have one or more keywords that are stored in this column. The contents of the column are visible to the user and serves to 'expand' the search. This does not work as expected.

    But now I need support several words or even sentences. With the current configuration, Oracle Text will only search for each keyword. How should I store the phrases and configure Oracle text so that it will search entire sentences (exact match is better, but the partial match is fine too)?

    Example of content column of two lines (values separated semicolon):
    "Hello, Hello; y at - it anyone out there? Nope; »
    "the just; basic facts; »
    I found a similar question: looking for a column with values separated by commas, except that I need a solution for Oracle 11 g with it's freetext search.

    Possible solutions:
    1st solution: I thought to redraw the DB as follows. I would like to make a new array of keywords (pkID NUMBER, nonUniqueID NUMBER, singlePhrase VARCHAR2 (100 BYTE)). And I want to change the column previous keyword to KeywordNonUniqueID, holding the ID (instead of a list of values). At the time of the research I had INNER JOIN with the new keyword table. The problem with this solution is that I will get several lines containing the same data except for the sentence. I guess this will destroy the ranking?

    2nd solution: is it possible to store sentences as an XML in the column key of origin and somehow say Oracle text to search for in the XML?

    3rd solution: separate individual phrases with spaces, but replace the spaces in sentences with the underscore or something (making a single word). If a phrase "why Hello there, Johnny!" is saved as "Why_hello_there, _Johnny!

    4th solution?:

    Note that, generally, there is a lot of sentences (less than 100), nor that they will be long (one sentence will be up to 5 words).

    Also note that I am currently using CONTAINS, and needs some of its operators, to my full-text searches.

    When you talk about "phrase", do you mean "a list of words separated by a comma other sentences?

    Isn't that the definition of "sentence" used by Oracle Text, where it simply means "a list of words in the order defined."

    If I understand your requirement, you want to have data such as:

    "aa bb cc dd".
    "aa ee dd ff.

    and give priority to the first on the second if someone looking for "dd".

    First, to conduct research in the comma separated list, you should look for in a section. You can either explicitly define sections of field such as
    AA bb cc dd
    Or you can use the PHRASE special section and set the sentence delimiters correctly. This is done with the attribute BASIC_LEXER punctuation

    Then you have the number you want to find only words where they are the only words in the section. That's the same problem, I address in the last post of this forum entry:
    Contains: match exactly

    Our solution will be substantially the same, some surrounding text with special markers, and then prioritize a phrase search with these special markers each side of the word.
    We need to do a treatment some additional, although, as we need to surround each "sentence" (in your terminology) with special markers. I did it by surrounding the text with "XX1"... Condition2"then by replacing every comma with"Condition2, XX1"as part of a MULTI_COLUMN_DATASTORE:

    drop table names;
    create table names (id number primary key, text varchar2(50));
    
    insert into names values( 1, 'just and kind, kind and loving' );
    insert into names values( 2, 'just, kind' );
    
    exec ctx_ddl.drop_preference  ( 'mylex' )
    exec ctx_ddl.create_preference( 'mylex', 'BASIC_LEXER' )
    exec ctx_ddl.set_attribute    ( 'mylex', 'PUNCTUATIONS', ',' )
    
    exec ctx_ddl.drop_preference  ( 'mcds' )
    exec ctx_ddl.create_preference( 'mcds',  'MULTI_COLUMN_DATASTORE' )
    exec ctx_ddl.set_attribute    ( 'mcds', 'COLUMNS', '''XX1 ''||replace(text, '','',''XX2, XX1'')||'' XX2''' )
    
    exec ctx_ddl.drop_preference  ( 'mywl' )
    exec ctx_ddl.create_preference( 'mywl', 'BASIC_WORDLIST' )
    exec ctx_ddl.set_attribute    ( 'mywl', 'SUBSTRING_INDEX', 'YES' )
    
    create index namesindex on names(text)
    indextype is ctxsys.context
    parameters( 'datastore mcds wordlist mywl' )
    /
    
    select score(1),id,text from names where contains( text, '
    
      
        
           XX1 kind XX2 
           kind
        
      
    
    ', 1) > 0
    order by score(1) desc
    /
    

    Output of this is:

      SCORE(1)        ID TEXT
    ---------- ---------- --------------------------------------------------
         52         2 just, kind
          2         1 just and kind, kind and loving
    

Maybe you are looking for