Group One column in different conditions

My Test Table has column as PENDING its null or "D"
DESC TEST
COde           varchar2 (5)
Pending      Varchar2 (1)
I want to get a listing as follows .(Total count and not null count)
CODE total COUNT PENDING count
HOLD 8892 500
ANZ 9 9
RNEW 24880 8
NORM 3646 33
LB 715 0
BT2K 779 779
BNEW 2204 2204
TRI 26 0
CELL 3 0
RT2K 580 0
ZERO 17782 0
Please explain how to do it in single sql statment

We can do this, but please explain what you mean by pending count. Does pending hold only NULL and 'D's? If so, the total of NULLs and 'D's is what I consider to be total count. The one only with NULL is pending right?
select code, sum(pending) total_count,
sum(decode(pending, NULL, 1, 0)) pending_count
from test
group by test;Cheers
Sarma.

Similar Messages

  • Update one column in different conditions

    Is there any way by which I can merge following two update statements into a single statement without using plsql. Here the same column of one table is being updated in different conditions.
    UPDATE week_table
    SET present_week=NULL
    WHERE week_table.pay_statusk=(
                        SELECT value
                        FROM panel
                        WHERE pname='PRESENT_WEEK')
    UPDATE week_table
    SET present_week='Y'
    WHERE week_table.pay_status=(
                        SELECT value+1
                        FROM panel
                        WHERE pname='PRESENT_WEEK')
    --waiting for a solution, thanks in advance.
    null

    Or like...
    SQL> select * from week_table;
    PRESENT_WE PAY_STATUS                                                          
    X                   1                                                          
    X                   2                                                          
    SQL> select * from panel;
    PNAME                     VALUE                                                
    PRESENT_WEEK                  1                                                
    SQL> UPDATE week_table
      2  set present_week = decode(pay_status,(select value
      3                                       from panel
      4                                       where pname = 'PRESENT_WEEK'),null,
      5                                      (select value+1
      6                                      from panel
      7                                      where pname = 'PRESENT_WEEK'),'Y')
      8  WHERE week_table.pay_status=(
      9                        SELECT value+1
    10                        FROM panel
    11                        WHERE pname='PRESENT_WEEK')
    12  or
    13   week_table.pay_status=(
    14                       SELECT value
    15                        FROM panel
    16                        WHERE pname='PRESENT_WEEK');
    2 rows updated.
    SQL> select * from week_table;
    PRESENT_WE PAY_STATUS                                                          
                        1                                                          
    Y                   2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • One Key FIgure in more than one column with different restrictions

    Hi,
      I am using a key figure in more than one column with different restrictions, but restriction in one column is affecting the result in other column. What shall i do to make it independent from one another??

    Hi Pravender Chauhan,
        If you want in Single column different value for different Rows based on same Key Figure, you can create Structure where you can define different logic for each row but using same key figure.
    If you want to use different Key figures then you should have to Restricted Key Figure and for any calculation you can use calculated Key figure.
    Assign points if Useful.
    Regards,
    Rajdeep.

  • Different columns having different condition in BI Answers

    i want to have an report as like in the format :
    Name of the sectors      In local currency          In foreign currency     
         "<= 12 months" ">12 months" "<= 12 months" ">12 months"
         0-250,000 >250,000 150,000- 350,000 >350,000
    Public Sector
    -Economic Public Corporations          
    -Public Business Sector Companies          
    i want to have the report in the above format ..
    where under the local currency contains there will be two colums of the range. i have got one column with <=12 months but how to get another column with less than >12 months with the condition >250000 and all in individual rows..
    Can any body please suggest..

    Hi.
    Navigation drills from one to another report using column propetries navigation only works in case that you are using the same column from the same table, and this column is IS PROMPTED in both reports.
    Example 1:
    Fact1 >- Dim1.COL1 (Report 1)
    Fact2 >- Dim2.COL1 (Report 2)
    Navigation from Report1 to Report2 is not working although Dim2.COL1 is promted and you are drilling from Dim1.COL1.
    Example 2:
    Fact1 >- Dim1.COL1 (Report 1)
    Fact2 >- Dim1.COL1 (Report 2)
    Navigation from Report1 to Report2 is working because both reports share the same table.column (Dim1.COL1) and it is prompted in the second report.
    You can use GO URL navigation for reports and dashboard pages for other cases.
    Regards,
    Goran
    http://108obiee.blogspot.com

  • Table with column group (one column) - next row is showing on new page instead of below previous row

    I am creating new table. My goal is to display some text in few lines like this:
    "AAAAAAAA"           "BBBBBBBB"           "CCCCCCCCC"     
    "DDDDDDD"           "EEEEEEEE"
    Actually the next row (with "DD" and "EE" values) is not displayed below first row, but on the next page.
    I've tried to put table into rectangle, disabled all page breaks and still the same effect. Any help?

    Hi Heidi,
    Actually, it's not solution, I only gave more details about my problem :)
    Another description:
    In my report I'm creating Tablix with Column grouping. There is only one column with image (every image has same width). If there is only three pictures, then they are displayed next to each other in one row.
    In case, there is more than three pics, another row is showing on next page. I'd like to display all rows one after another on one page.
    I've tried to create three vertical lists, and filter each column group to display only records:
    1) =(RowNumber("Tablix1")) mod 3 = 1
    2) =(RowNumber("Tablix1")) mod 3 = 2
    3) =(RowNumber("Tablix1")) mod 3 = 0
    Unfortunately, I got an error:
    "A FilterExpression for the tablix ‘Tablix1’ uses the function RowNumber.  RowNumber cannot be used in filters."
    Do You have any other propositions?
    --------EDIT--------
    ok, I manged to solve it. As I said, I've created three vertival lists and placed them next to each other.
    Then, instead of using filter, I've used Visibility trigger:
    1)
    =IIf(RunningValue(Fields![rowgroupfield].Value, COUNTDISTINCT, "Tablix1") mod 3 = 1, false, true)
    2)
    =IIf(RunningValue(Fields![rowgroupfield].Value, COUNTDISTINCT, "Tablix2") mod 3 = 2, false, true)
    3)
    =IIf(RunningValue(Fields![rowgroupfield].Value, COUNTDISTINCT, "Tablix3") mod 3 = 0, false, true)
    I had to use function RunningValue to count all occurrences, as my report is quite complex and "RowNumber" [ssrs function] and "ROW_NUMBER() OVER (ORDER BY [rowgroupfield])" [sql query] were not working properly.

  • Splitting one column into different columns.

    Hello Experts,
    How do i split datetime column into different columns while doing a Select statement.
    Ex:
    The column "REC_CRT_TS" has data like "2014-05-08 08:23:09.0000000".The datatype of this column is "DateTime". And i want it in SELECT statement like;
    SELECT
    YEAR(DATETIME) YEAR,
    MONTH(DATETIME) MONTH,
    DATENAME(DATETIME) MONTHNAME,
    DATEPART(DATETIME) WEEKNUM,
    DAY(DATETIME) DATE,
    DATEPART(DATETIME) HOUR
    FROM TABLE_NAME;
    The output should look like this;
    --YEAR| MONTH | MONTHNAME| WEEKNUM | DATE | HOUR
    --2014| 5 | May | 25 | 08 |08
    Any suggestions please.
    Thanks!
    Rahman

    I made a very quick research and I see in this blog post
    http://www.jamesserra.com/archive/2011/08/microsoft-sql-server-parallel-data-warehouse-pdw-explained/
    that  It also uses its own query engine and not all features of SQL
    Server are supported.  So, you might not be able to use all your DBA tricks.  And you wouldn’t want to build a solution against SQL Server and then just hope to upsize it to Parallel Data Warehouse Edition.
    So, it is quite possible that this function doesn't exist in PDW version of SQL
    Server. In this case you may want to implement case based month name or do it in the client application.
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • Group by same column with different conditions

    Hi All,
    I have the following SQL statement
    select Sum(Total), Region, Code from table_A group by Region, Code
    Code has distinct values of 1 to 10 for each Region.
    Is it possible to group by Region, Code < 5 and Code > 5.

    Here is a solution which I have but wanted to see if there is any other way to do it.
    select Sum(Total), Region,'code<5' as Code from table_A group by Region, Code having code < 5
    union
    select Sum(Total), Region,'code>5' as Code from table_A group by Region, Code having code > 5

  • Navigation from one column to different Reports

    Hi,
    I am using 10g.In Answers i have a doubt.
    I have a column with 30 values.These are the different Entities.
    So when i click on any entity it needs to go to particular Entity Report.Is it possible with any case conditions.
    And i have developed 30 Reports.
    Note: Here i am providng centralized report when user login into the Dashboards. Based on the that needs to navigate
    Thanks

    Hi,
        You can create one viewset. In one view set you can place any number of views.
    According to your question
    1. create viewset
    2. place the views in viewset
    3. place outbound plug in the first view amd place the inbound plug the  second view. connect those two views witg navigation link.
    4. place the outbound plug in secondview and place the inbound plug in thirdview. connect secondview and thirdview with navigation link
    5. create two actions through actions tab.
    6. create two buttons. Go to properties of the first button and bind the first actions. Similary second button.
    7. go to implementation of that actions.
    wdThis.wdFirePlugToDisplayView();
    this is the sample code in section view to display view.
    here we are passing the parameters from one view to another view.
      wdThis.wdFirePlugToDisplyView(wdContext.currentContextElement().getOptions(),wdContext.currentContextElement().getSecondLevel(),wdContext.currentContextElement().getThirdLevel());
    Regards,
    Saraswathi
    Pls reward points for useful info.

  • How to get difference the min of two columns having different conditions ?

    Hello,
    I am trying to write a query which staisfies the following condittion. I have a table emp which has the following colums empno,ename,deptcode,empstat_code,salary.
    The salary of employees depends on the empstat_code.
    For a given deptcode, I have to compare the mimimum of salaries for empstat_code 'A' with the minimum of salaries for empstat_code 'B' and then a get a difference between the two.
    How can I do this, please advise.
    Thanks
    fm

    Something like this perhaps.
    create table my_emp as
    select
    from scott.emp
    alter table my_emp add emp_stat varchar2(1);
    update my_emp set emp_stat= case when mod(rownum, 2) = 0 then 'A' else 'B' end;
    select * from my_emp;
    TUBBY_TUBBZ?select
      2        min(decode(emp_stat, 'A', sal)) as min_A_sal
      3     ,  min(decode(emp_stat, 'B', sal)) as min_B_sal
      4     ,  deptno
      5  from
      6     my_emp
      7  group by
      8     deptno;
             MIN_A_SAL          MIN_B_SAL             DEPTNO
                   950               1250                 30
                  2975                800                 20
                  1300               2450                 10
    3 rows selected.
    Elapsed: 00:00:00.71Keeping in mind that MIN will return NULL if there are no values for a given emp_stat and deptno combination. So you would have to account for that however your business rules tell you to account for it (likely using NVL to 0)

  • Different conditions for different columns

    Hi,
    I have two tables and both have 3 common columns. I have to write a query joining the two tables and get different columns with different conditions.
    For e.g., I have the tables test and test1.
    create table test (a1 varchar(10), a2 varchar(10), a3 varchar(10), a4 date, a5 number, a6 number, a7 number, a8 number);
    create table test1 (a1 varchar(10), a2 varchar(10), a3 varchar(10));
    insert into test1 values('abc', 'a', 'z');
    insert into test1 values('xyz', 'b', 'y');
    insert into test values('abc', 'a', 'x', trunc(sysdate,'MM'), 100, 200, 300, 400);
    insert into test values('abc', 'b', 'z', trunc(sysdate,'MM'), 567, 4778, 4234, 6767);
    insert into test values('xyz', 'a', 'y', trunc(sysdate,'MM'), 5467, 2134, 5678, 8332);
    insert into test values('xyz', 'b', 'z', trunc(sysdate,'MM'), 3534, 744, 678547, 46);
    insert into test values('abc', 'a', 'x', trunc(add_months(sysdate,-1),'MM'), 700, 800, 900, 600);
    insert into test values('abc', 'b', 'z', trunc(add_months(sysdate,-1),'MM'), 565477, 474578, 4456234, 226767);
    insert into test values('xyz', 'a', 'y', trunc(add_months(sysdate,-1),'MM'), 235467, 2342134, 255678, 258332);
    insert into test values('xyz', 'b', 'z', trunc(add_months(sysdate,-1),'MM'), 324534, 25744, 678547, 78846);
    select * from test1;
    A1     A2     A3
    abc     a     z
    xyz     b     y
    select * from test;
    A1     A2     A3     A4                     A5     A6     A7     A8
    abc     a     x     05/01/2010 00:00:00     100     200     300     400
    abc     b     z     05/01/2010 00:00:00     567     4,778     4,234     6,767
    xyz     a     y     05/01/2010 00:00:00     5,467     2,134     5,678     8,332
    xyz     b     z     05/01/2010 00:00:00     3,534     744     678,547     46
    abc     a     x     04/01/2010 00:00:00     700     800     900     600
    abc     b     z     04/01/2010 00:00:00     565,477     474,578     4,456,234     226,767
    xyz     a     y     04/01/2010 00:00:00     235,467     2,342,134     255,678     258,332
    xyz     b     z     04/01/2010 00:00:00     324,534     25,744     678,547     78,846I have to write a query to get values for columns a1, a4, a5, a6, a7 and a8. For each distinct month fro mthe column a4, the values for columns a1, a4 a5 and a6 should be based on the condition test1.a1=test.a1 and test1.a2=test.a2. The condition for columns a7 and a8 should be test1.a1=test.a1 and test1.a3=test.a3.
    How can I do this?
    Thanks,
    Machaan

    remove the 4th join and only duplicate test;
    SQL> ed
    Wrote file afiedt.buf
      1  select distinct
      2  case
      3          when t11a1 is null then
      4            t12a1
      5          else
      6            t11a1
      7        end as a1
      8        ,case
      9          when t11a4 is null then
    10            t12a4
    11          else
    12            t11a4
    13         end as a4
    14        ,case
    15          when t11a5 is null then
    16            t12a5
    17          else
    18            t11a5
    19         end as a5
    20  from (
    21        select t11.a1 as t11a1
    22              ,t11.a2 as t11a2
    23              ,t11.a3 as t11a3
    24              ,t11.a4 as t11a4
    25              ,t11.a5 as t11a5
    26              ,t11.a6 as t11a6
    27              ,t11.a7 as t11a7
    28              ,t11.a8 as t11a8
    29              ,t12.a1 as t12a1
    30              ,t12.a2 as t12a2
    31              ,t12.a3 as t12a3
    32              ,t12.a4 as t12a4
    33              ,t12.a5 as t12a5
    34              ,t12.a6 as t12a6
    35              ,t12.a7 as t12a7
    36              ,t12.a8 as t12a8
    37        from test1 t1
    38            ,test  t11
    39            ,test  t12
    40        where t1.a1 = t11.a1
    41        and   t1.a2 = t11.a2
    42        and   t1.a3 = t12.a3
    43* )
    SQL>
    SQL> /
    A1         A4                A5
    xyz        01-APR-10     324534
    xyz        01-MAY-10       3534
    abc        01-APR-10        700
    abc        01-MAY-10        100

  • Select List and Popup LoV for one column

    Hello,
    is there a built-in functionality to show a select list and a popup lov for one column similar to "Condition Type" in the condition region when editing a page.

    Hello,
    No, you have to code that yourself. For instance by adding HTML in the Post Element Text field (like <IMG src=... />).
    Greetings,
    Roel
    http://roelhartman.blogspot.com/
    http://www.bloggingaboutoracle.org/
    http://www.logica.com/

  • How to handle same material number but different condition?

    In our industry(aerospace aftermarket), we can have inventory for one material in different conditions, e.g new, overhauled, scrap, etc. We use batch management and store the condition at the batch level. This probably was not the best way to handle this and now we're wondering how we can run MRP for a specific material, but only for certain conditions.
    From what I understand MRP only occurs at the material level, not the material-condition level. Is my assumption correct? Obviously, we would not want to include scrap inventory in any MRP or forecasting calculations. So if we had 10 for material 1234 in inventory, we'd want to exclude the amount that's scrap or any other condition we don't want to include in a forecast/MRP. 
    Is there a best practice that someone can share to handle this type of inventory management issue? Thanks!

    Hi,
    I've never used this but please have a look at it:
    http://help.sap.com/erp2005_ehp_04/helpdata/EN/c6/126422bd9c11d1b54f0000e82de178/frameset.htm
    Planning startegies for variants:
    This section describes how to plan products that have a practical limited number of possible combinations of characteristics and characteristic values. Technically speaking this section describes the use of variants to sell configurable materials.
    Regards,
    Csaba
    Edited by: Csaba Szommer on Feb 5, 2009 10:46 PM

  • Hide column based on condition on other column in table

    hi,
    am using BIP 10.1.3.2 to generate reports.In the template i need to hide one column based on condition on other.am using SQL query as my data source type.can anybody help me ?

    Use <?if:?> condition in the RTF, but its mainly for the rows not column. You can work around this by handeling in backend. Or take two separate tables, one with the column which you want to hide and another table without that column and before calling that table use IF condition.
    Regards,
    Amit D
    Persistent Systems Ltd.

  • Report Painter - Format group for columns in more than one section

    How do have different decimals for columns in different sections.
    For. e.g I have three sections
    one for quantity (I do not need decimals)
    two for dollars (I do not need decimals)
    three for formula dollar upon quantity (I need to have two decimals)
    I made format group 0 (with no decimals) for first two sections and format group 1 (with two decimals) for the last section.
    4.6c does not consider format group 1 and makes every section look alike with format group 0 i.e, no decimals.
    How to overcome this?

    Anders,
    I replied earlier but after reading you post several times I realized that I probably misunderstood what you want. This is what I now understand. You have several resources, each of who may work on various parts of design tasks, assembly tasks, and test
    tasks. For example, let's say your resources are Joe, Bill & Tom. Joe is assigned to a design and test task, Bill is assigned to an assembly and test test task and Tom is assigned to a design task, an assembly task and a test task (Tom is very versatile).
    You would like to see a report showing just the assembly tasks and the amount of work each of the three resources is assigned on those tasks.
    Assuming the above is a correct interpretation, you will need to employ three processes, some VBA, grouping and filtering.
    1. First, designate a custom text field for group identification (e.g. use Task Text1 to enter "design", "assembly", or "test" for each task)
    2. In order to use grouping and filtering effectively,  you will need to translate the Task Text1 information to the Assignment Text1 field. To do that, go to the MVP website at: http://project.mvps.org/faqs.htm, and run the macro in FAQ 37.
    3. Now go to the Task Usage view and set up a group with Text1 as the first group by element and Name as the second group by element. Check the box to group assignments and not tasks. Then select "assignment" for field type of the second element
    (i.e. Name).
    4. Apply the group
    5. To show only the work hours for each resource in a specific group, autofilter on the desired group. Note, if you do not run the macro to populate the Assignment Text1 field with the Task Text1 field, the filter will yield nothing.
    Hope this helps
    John

  • How to retrieve different data separated by comma into one column

    Hi all,
    We have a Custom View.In that some of the customer's Bill-To address is different remaining all columns contain same data.In that case if we query with that customer_number it displays more than one row with different Bill-to addresses,it is fine.But our requirement is we need to display only one row for that customer_number and Bill-to address column shows all Bill-to addresses corresponding to that customer separated by comma.
    Could anyone give us any idea to solve this.
    Thanks in Advance,
    Dhana

    i do not a concatenated data
    i have a data in a table with columns A & B of same size
    A B
    1 2
    2
    3 1
    4 2
    5 3
    6 5
    7 1
    8 4
    9
    10 8
    if my where condition is 'where A=2'
    my output should be
    1
    2
    3
    4
    5
    6
    8
    10
    i want my query to search as loop so that it keeps on searching
    for related data as in my case it is
    2 is linked to 1
    1 is linked to 3
    3 is linked to 4
    my query should keep on seaching for linked numbers till
    it does not find any mathing linked numbers
    and the resulted output should come in one single column

Maybe you are looking for