reduce the number of columns in the case query

Hi all

I'm running on 10 G R/2.

I have a query that produces columns with the number of steps.

SUM (CASE WHEN LTRIM (RTRIM (W_O)) = 'ROKOLBIN' THEN 1 ELSE 0 END) AS "O_ROKOLBIN."
SUM (CASE WHEN LTRIM (RTRIM (W_I)) = 'ROKOLBIN' THEN 0 OTHERWISE 1 END) AS "I_ROKOLBIN."
sum (case when LTRIM (RTRIM (W_O)) = "SYLVAIN", then 1 else 0 end) as "O_GULURU."
sum (case when LTRIM (RTRIM (W_I)) = "SYLVAIN", then 1 else 0 end) as "I_GULURU."
sum (case when LTRIM (RTRIM (W_ON)) = 'PURE' then 1 else 0 end) as "O_PURE."

I want to reduce the number of columns to 2,

A column is for Division.Division can be O_ROKOLBIN, I_ROKOLBIN, O_GULURU, I_GULURU, O_PURE
The other column is Subtotal.Subtotal are the sums as above, SUM (CASE WHEN LTRIM (RTRIM (W_O)) = "ROKOLBIN", 1.)

Can anyone advie how I acheiev it.

Thank you.

Hello

CrackerJack wrote:
... Data are from Jan 12 to today, 1 million + records, that's why I'm unable to provide comprehensive data and simply copied an example of data.

Nobody wants you to post 1 million rows. 10 lines can be many. Just examples of data make sure that validation really produces the results you post.
>

I copied data from 16 Jan just differentiate different dates.

I also tried trunc, but who has still not the sum of each divisions.

Highlight a few places where the query I posted produces erroneous results and explain how to get good results in these places. Give concrete examples showing how to get the correct results of the sample data.

Tags: Database

Similar Questions

  • How can I reduce my number of connections to the server to overcome this error message?

    Trying to open Thunderbird but I get this message: "unable to connect to your IMAP server. It is possible have exceeded the number of connections to this server. in this case, use the advanced settings of IMAP server dialogue to reduce the number of cached connections"under my settings of the account server settings - advanced, I changed 'no server connections max' 5-3, but it has no effect.

    If you have a mail getting the apple device turn it off. they have no limits in the number connections they will use. makes it difficult to share.

  • Performance of the ADG number of columns?

    Hi all

    I was wondering if there is a correlation between the time it takes for an ADG update itself after the modification of the data and the number of columns. I want to know in case it's just my bad code :-). For example, I noticed that the ADG is much slower under 31 columns as 15 for this simple example. I'm a beginner at this so I guess I don't know what I'm doing, but the difference in speed is an order of magnitude different.

    "" < mx:AdvancedDataGrid xmlns:mx = ' http://www.adobe.com/2006/mxml ' rowHeight = "25" sortItemRenderer = "SortItemHider".
    "creationComplete =" init () ' allowMultipleSelection = 'true' selectionMode = "single-celled" itemClick = "setStart (event)" xmlns:local = "" * ">"

    < mx:columns >
    < mx:AdvancedDataGridColumn dataField = 'task' id = "task" headerText = "task" width = "60" textAlign = "center" resizable = "true" / >
    < / mx:columns >

    ...

    private function initColumns (): void //This function creates a lot of dynamic columns and adds them to the adg
    {
    var test1:Array = This.colonnes;
    var test2:ArrayCollection = new ArrayCollection (test1);
    test2. RemoveAll();
    for (var int index = 0; index < this.columns.length; index ++)
    {
    test2. AddItem (this.) Columns [index]);
    }
    defaultColumns = test2.length - 1;
    for (var x: int = 0; x < MAX_COLS; x ++)
    {
    var newColumn:AdvancedDataGridColumn = new AdvancedDataGridColumn ("day" +(x+1));
    newColumn.dataField = "day" + (x + 1);
    newColumn.setStyle ("textAlign", "Center");
    var day: Number = todaysDate.getDate ();
    newColumn.headerText = String (x);
    test2. AddItem (newColumn);
    }
    This.colonnes = test1;
    }

    ...

    private void setStart(event:ListEvent):void //when you click on a cell that is not the first, it will create data in the ADG
    {
    task of the var: String = event.itemRenderer.data.task;

    var selectedRow:int = dataArray.getItemIndex (event.itemRenderer.data);
    var selectedItem:Object = dataArray [selectedRow];

    var totalHours:int = selectedItem.unscheduled;
    selectedItem.unscheduled = 0;
    var startDay:int = this.selectedColumnIndex - defaultColumns;
    If (startDay > 0 & & selectedRow! = - 1).
    {
    var HoursPerDay:int = 8;
    var dailyHours:int = totalHours / HoursPerDay;
    var leftoverHours:int = totalHours HoursPerDay %;
    var days: int = dailyHours + (leftoverHours! = 0? 1: 0);
    var endDay:int = startDay + days;
    selectedItem.start = startDay;
    Void var;
    for (var int index = startDay; index < endDay; index ++)
    {
    columnName = 'day' + index;
    if(index < This.Columns.Length)
    {
    If (index == endDay-1 & & leftoverHours > 0)
    {
    selectedItem [columnName] = leftoverHours;
    return;
    }
    selectedItem [columnName] = HoursPerDay;
    }
    }
    }
    }
    }

    Sorry, wrong forum

  • Need to limit the number of columns

    When a tab in the last cell of the row, I want the cursor to the next line down. Instead, it creates a new useless column. Can't seem to find a setting that allows me to limit the number of columns in a page - someone ' one knows how to do this?

    Thanks for your wisdom shared, Oh wise Ones.

    I'm not aware of do what you want.  You can post your comments directly to Apple using the menu item "numbers > provide Feedback numbers.

    You can still use the key combinations:

    < command > + < right arrow > to access at the end of a line

    < command > + < left arrow > to move to the beginning of a line

    < command > + < down > to pass at the end of a column

    < command > + < arrow > to move to the beginning of a column

  • Display the icon change the number of columns

    I'm sure it must be a way to change the number of columns in the display icon, not the space between columns, not the size of the icons, but the number of columns, for example, that dumpster has 4 columns and I want to see those hidden on the right I have to use the scroll bar, I want to do I want to see ONLY for columns of the filling finder window?

    Thank you very much

    Roger

    "BTW that seems to only happen when I consult with ANY ' arrange by" or "sort by"!

  • I tried to view my tabs on other computers and received this message: XML Parsing Error: undefined entity location: on: sync-tabs line number 7, column 1: the window id = "tabs-display" ^ How can I fix?

    "Error message has been: XML Parsing Error: undefined entity location: on: sync-tabs line number 7, column 1: window (weeks =" "3 =" "4 =" "5 =" "7 =" "< =" "^ =" "a =" "Add - on. =" "it y =" ' am = "" a = "" and = "" are = "" avg = "" believe = "" time = "" but = "" impossible = "" some = "" computers = "" firefox = "" for = "" I = "" I = "" id = 'tabs-view' in = "" installed.. = "" it = "" months) = "" = "" on. "" "" "" "" = "" or = "" other = "" p = "" paid = "" remember = "" running = "" sometimes = "" sync = "" tabs = "" version = "" look a = "" was = "" we = "" some = "" when = "" windows = "" worked = "" > < / window > "

    Hello!

    Can you give us some details? When this message display? Is in your phone or your computer? What is your language? More information you can give us the best.

    You use the add-on and Firefox 4? If so, I'll ask you to disable and remove the add-on: Sync is now part of the Firefox browser and you don't need the add-on. [https://bugzilla.mozilla.org/show_bug.cgi?id=644894 some users solved this problem by uninstalling the add-on.]
    ]

  • How to reduce the number of significant digits after the decimal point, not only displays for example, 0.12345678 convert to 0.123 in all cells

    I imported a. Table TSV having 4000 rows and 20 columns in numbers, by changing its extension .tsv in .txt. Then, drag and drop in numbers.

    The actual values have too many significant digits to be useful and may be beyond the capacity of the numbers to calculate or to find 262.825892344384

    If there is a way to have the SS (4000 x 20) 'Numbers' to reduce the values currently stored in the entire document or a particular column or row

    262.825892344384 to 262.8259 I am not interested to the value, but the value actually stored and used for calculations.

    I have a table that uses the formula of round and takes as input the data that you have imported.  Then you can select the data in the round table, copy

    then paste the data in the original table by using the menu item "Edition > paste formula results.

    Ibn chart at right

    B2 = ROUND (Original Data::B2, 3)

    It's abbreviation dethrone select cell B2 and type (or copy and paste it here) the formula:

    = ROUND(Original Data::B2, 3)

    now select cell B2, copy

    Select the cells B2 to C2, dough

    A2 = Data::A2 Original

    Select cells A2 through C2, copy

    Select cells A2 through the last cell in column C, paste

    now select the data in the table 'Data rounded' copy

    Select the corresponding cells in the original table, select the menu item "Edition > paste formula results.

  • Is it good to keep my macbook on charge all the time? This reduces the number of cycles of battery I would have otherwise?

    I have a 2015 13-inch macbook pro Retina display. What is the best way to keep the battery in good conditions? In particular: When should I charge it? Only when the power is low)<20%) or="" anytime="" that="" i="" can?="" more="" in="" particular:="" if="" i="" keep="" it="" in="" charge="" all="" the="" time,="" will="" this="" be="" good="" or="" bad="" for="" the="" battery?="" will="" it="" reduce="" the="" number="" of="" battery="" cycles="" that="" i="" would="" otherwise="" have?="" many="">

    Keep the computer plugged in whenever possible.

    If you keep the computer always connected, make sure that at least twice a month

    Run it on battery until battery charge level falls to about 40-50%.

    Please don't completely discharge the battery. Discharge the battery completely will reduce wear and tear on the battery.

    Trying to keep the number of Cycles of battery low does ' t help.

    For more information:

    Section: To optimize the battery life

    http://support.Apple.com/en-us/HT204054

    Best.

  • How can I know the number of columns and lines on excel file

    How reading the number of columns and rows on an excel file after you open the file in excel with ActiveX.

    Using the example of excel200dem, I read that the file data is excellent.

    However, in this example, I just give the number of lines and columns.

    I want to know the number of lines and columns not giving those in C code automatically.

    Who knows this things? -?

    Help me please.

    Hello

    (1) this forum provides a search option, you must use in doing so, you will find this post

    (2) don't solve you your earlier questions? If so, you must mark responses that have helped you find a solution.

  • Reduce the number of ticks on a xy plot

    Hi all

    I have a chart that looks very busy on the x axis.

    Anyone know a way to reduce the number of ticks that only, say 5, are visible?

    Thank you

    Sean

    Like this for example

  • How to query the total number of columns and lines filled with data?

    How to get the number of rows and columns in Exel file data using Excel report?

    Since you have posted this question in the forum of LabWindows/CVI, I guess you want to know how to do with CVI.

    You need to know how to open and activate the Excel data file.

    Depending on the function returns the total number of columns and lines col_count row_count, respectively.

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

    int CountColumnsAndRows (void)
    {
    Error HRESULT = 0;
    CAObjHandle rangeCurrentRegionHandle = 0;
    CAObjHandle rangeColumnsHandle = 0;
    CAObjHandle rangeRowsHandle = 0;
      
    unsigned long col_count = 0, row_count = 0;
      
    Must use the 'A1' property and CruuentRegion count the total of columns and lines, including the drafts!
      
    error = CA_VariantSetCString (& MyCellRangeV, 'A1');
      
    error = Excel_WorksheetRange (ExcelWorksheetHandle, NULL, MyCellRangeV, CA_DEFAULT_VAL, & ExcelRangeHandle);
    If (error<0) goto="">
      
    error = Excel_GetProperty (ExcelRangeHandle, & ErrorInfo, Excel_RangeCurrentRegion, CAVT_OBJHANDLE, & rangeCurrentRegionHandle);
    If (error<0)  goto="" error="">
      
    error = Excel_GetProperty (rangeCurrentRegionHandle, & ErrorInfo, Excel_RangeColumns, CAVT_OBJHANDLE, & rangeColumnsHandle);
    If (error<0)  goto="" error="">
      
    error = Excel_GetProperty (rangeColumnsHandle, & ErrorInfo, Excel_RangeCount, CAVT_LONG, & col_count);
    If (error<0) goto="">
      
    error = Excel_GetProperty (rangeCurrentRegionHandle, & ErrorInfo, Excel_RangeRows, CAVT_OBJHANDLE, & rangeRowsHandle);
    If (error<0)  goto="" error="">
      
    error = Excel_GetProperty (rangeRowsHandle, & ErrorInfo, Excel_RangeCount, CAVT_LONG, & row_count);
    If (error<0) goto="">

    Error:

    CA_VariantClear (& MyCellRangeV);
    CA_VariantClear (& MyVariant);
    ClearObjHandle (& ExcelRangeHandle);
    ClearObjHandle (& rangeCurrentRegionHandle);
    ClearObjHandle (& rangeColumnsHandle);
    ClearObjHandle (& rangeRowsHandle);
      
     
    If (error<>
    ReportAppAutomationError (error);
      
    error return;
    }

  • So I recently found my game Age of Mythology. The disc is very good and works, but I have not the case with the number of products to this topic. What should I do?

    So I recently found my game Age of Mythology. The disc is very good and works, but I have not the case with the number of products to this topic. What should I do?

    Hi GuyT6,

    ·         What version of the operating system is installed on the computer?

    I suggest you contact the customer assistance form help and more information.

    How and when to contact Microsoft and support Customer Service

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

  • Lost on my computer recovery CD. I have xp sticker number on the case from my pc how to do a repalcement?

    Lost on my computer recovery CD. I have xp sticker number on the case from my pc how to do a repalcement?

    Hello

    Contact the computer manufacturer and ask them to send XP Recovery discs to reinstall the dos operating system as it was when you bought it

    they do it for a nominal cost of $

    How to replace Microsoft software or hardware, order service packs and replace product manuals

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

  • Window Live Mail 2011 - was a bug - in the case of "sent" folder by clicking on the To: column head seems to sort emails by topic instead of field

    Window Live Mail 2011 - was a bug - in the case of "sent" folder by clicking on the To: column head seems to sort emails by topic instead of field

    In short, many users of Window Live Mail 2011 had the same problems. Please Microsoft Ltd fix!

    1: you send messages in a forum XP and WLMail 2011 does not work on XP.

    2: the Windows Live Mail Forum is located here.
    http://www.windowslivehelp.com/forums.aspx?ProductID=15

    Bruce Hagen
    MS - MVP October 1, 2004 ~ September 30, 2010
    Imperial Beach, CA

  • How can I know the number of columns in a TYPE?

    Hello

    If we have a guy like below

    type vc_arr2 is table of the varchar2 (32767) index directory.

    How can I get the number of columns?

    Minoo.TK wrote:

    Hello

    If we have a guy like below

    type vc_arr2 is table of the varchar2 (32767) index directory.

    How can I get the number of columns?

    It is a type of associative array definition. A table has no columns. It is a collection of elements (variables or values). An array location is usually called a cell.

    The standard method Count() exist in Oracle for all table types.

    As for the definition of the table, as in structures, variables make the table contain - associative array is defined in the PL/SQL code and does not exist in the layer of metadata to the database as a new user-defined type. For the definition, you must read the declaration of PL/SQL defining the table.

    Note that there is very rarely the need for associative tables in PL/SQL - 99% of the time they are used without any idea as to what as a table associative is also.

Maybe you are looking for