Comparing values of a column in a group

Hi All,
i have key, dt, col1
1, dt1, a
1, dt2, b
2, dt1, a
2, dt2, a
2, dt3, a
i need to check whether all values of col1, for column key is same or different.
in the example key 1 has difft values for col1,
key 2 has same values for col1.
how can i achieve this in a single sql query?
thanks in advance

SQL> with virtual_tab as
  2  (select 1 key, 'dt1' dt, 'a' col1 from dual
  3   union all
  4   select 1 key, 'dt2' dt, 'b' col1 from dual
  5   union all
  6   select 2 key, 'dt1' dt, 'a' col1 from dual
  7   union all
  8   select 2 key, 'dt2' dt, 'a' col1 from dual
  9   union all
10   select 2 key, 'dt3' dt, 'a' col1 from dual)
11  select * from virtual_tab;
       KEY DT  C
         1 dt1 a
         1 dt2 b
         2 dt1 a
         2 dt2 a
         2 dt3 a
SQL> with virtual_tab as
  2  (select 1 key, 'dt1' dt, 'a' col1 from dual
  3   union all
  4   select 1 key, 'dt2' dt, 'b' col1 from dual
  5   union all
  6   select 2 key, 'dt1' dt, 'a' col1 from dual
  7   union all
  8   select 2 key, 'dt2' dt, 'a' col1 from dual
  9   union all
10   select 2 key, 'dt3' dt, 'a' col1 from dual)
11  select vt2.key,
12         case when vt2.cnt = 1 then
13                'different'
14              else
15                'the same'
16         end as remarks
17    from (select vt1.key,
18                 vt1.dt,
19                 vt1.col1,
20                 count(*) over (partition by key, col1 order by key, col1) cnt
21            from virtual_tab vt1) vt2
22  group by vt2.key, vt2.cnt;
       KEY REMARKS
         1 different
         2 the same
SQL>

Similar Messages

  • Need to compare values in two columns of one table against values in two columns in another table

    Hi, as the title reads, I'm looking for an approach that will allow me to compare values in two columns of one table against values in two columns in another table.
    Say, for instance, here are my tables:
    Table1:
    Server,Login
    ABCDEF,JOHN
    ABCDEF,JANE
    FEDCBA,SEAN
    FEDCBA,SHAWN
    Table2:
    Server,Login
    ABCDEF,JOHN
    ABCDEF,JANE
    FEDCBA,SHAWN
    In comparing the two tables, I'd like my query to report the rows in table1 NOT found in table2. In this case, it'll be the 3rd row of table one:
    Server,Login
    FEDCBA,SEAN
    Thanks.

    create table Table1([Server] varchar(50), Login varchar(50))
    Insert into Table1 values ('ABCDEF','JOHN'),('ABCDEF','JANE'),('FEDCBA','SEAN'),('FEDCBA','SHAWN')
    create table Table2([Server] varchar(50), Login varchar(50))
    Insert into Table2 values ('ABCDEF','JOHN'),('ABCDEF','JANE'), ('FEDCBA','SHAWN')
    select [Server] ,Login from Table1
    Except
    select [Server] ,Login from Table2
    select [Server] ,Login from Table1 t1
    where not exists(Select 1 from Table2 where t1.[Server] = t1.[Server] AND Login=t1.Login)
    drop table Table1,Table2

  • Compare values in a Column.

    Hi,
    I have an requirement like below and would like to have SQL for that.
    Source Table:+
    EMP_NO     EMP_CODE
    1          'A'
    1          'D'
    1          'E'
    1          'F'
    2          'S'
    2          'A'
    2          'W'
    2          'Q'
    3          'A'
    3          'T'
    3          'D'
    3          'E'
    4          'D'
    4          'A'
    I want to load only data which has EMP_CODE as A and doesnt have subsequent 'E' or 'F' in it.
    In the above source you can see EMP_NO 2 and 4 satisfy the condition and rest wont. So i want the output data like below.
    Desired output:+
    EMP_NO     EMP_CODE
    2          'A'
    4          'A'
    Please help. Any helping pointers would be appreciated.
    Thanks,
    K

    I Hope this is the ans you were looking for.
    SELECT E.EMP_ID,E.EMP_CODE
    FROM EMP E
    WHERE E.EMP_CODE = 'A'
    AND E.EMP_ID NOT IN ( SELECT M.EMP_ID
    FROM EMP M
    WHERE M.EMP_CODE IN('E','F')
    AND M.EMP_ID = E.EMP_ID)

  • How to add only highest values in the column

    Hello All,
    We have report where I need to add only highest values in 'Price' column.
    Ex:
    Group  Mat      Price
    Grp1    Mat1    50
               Mat2    75
               Mat3    100
    Grp2    Mat1    50
               Mat2    100
    I need my result as 200...
    Any input is appreciated!
    Thanks in advance !!
    Venu.

    Sriman/Surendra,
    Unfortunately, this approach does not work because the Calculate Result As --> Maximum applies not only to the subtotals but also to the grand total. Therefore, the result in Venu's example will be:
    MAX(Grp1) = 100
    MAX(Grp2) = 100
    MAX(All Grps) = 100
    We have the same requirement as Venu, but have not found a satisfactory solution yet. The only way we have solved such problems in the past is to use VBA in workbooks, but the report we are using now is a Web report.
    Hope this helps to clarify the issue...
    Bob

  • SSRS Compare a string value in an column

    I need to show a text box that shows a message if the string values of a column on SSRS report have mixed values.
    I need to compare the first three letters of a string to see if its different. If different then unhid Textbox and show a message. How can I do this in SSRS or SQL (if sql how do I feed it to SSRS)?
    For example
    Substring(alloy,1,3) <> Substring(alloy,1,3)
    ALLOY
    KZA1
    KZD1    << is different
    KZA2

    If your scope is the whole dataset then you can add a total row to the tablix outside any groups or
    simply add a textbox below the tablix and apply the same principle:
    =IIf(Min(Fields!Alloy.Value,"DatasetName") <> Max(Fields!Alloy.Value,"DatasetName"), "Mixed Alloy", "")
    =IIf(Min(Left(Fields!Alloy.Value,3),"DatasetName") <> Max(Left(Fields!Alloy.Value,3),"DatasetName"), "Mixed Alloy", "")
    This should do what you are asking. The only way that the minimum value for alloy will equal the maximum value for allow is if all values for alloy in the dataset are the same. When that happens, empty string is displayed in your text box rendering it invisible
    if you set borders appropriately. Otherwise you will see "Mixed Alloy" in the text box.
    "You will find a fortune, though it will not be the one you seek." -
    Blind Seer, O Brother Where Art Thou
    Please Mark posts as answers or helpful so that others may find the fortune they seek.

  • Create a new column in a table that compares the value of one column with its previous value

    The DDL:
    DECLARE
    @T TABLE
    IDNO
    int,
    name
    varchar(40),
    [Date]
    datetime2,
    Price1
    float,
    Price2
    float
    DECLARE
    @K TABLE
    IDNO
    int,
    name
    varchar(40),
    [Date]
    datetime2,
    Price1
    float,
    Price2
    float
    INSERT
    INTO @T
    VALUES(22,'C_V_Harris','2014-01-02 10:23:49.0000000',
    23.335,      
    23.347)
    INSERT
    INTO @T
    VALUES(21,'C_V_Harris','2014-01-02 10:05:13.0000000',
    23.357,      
    23.369)
    INSERT
    INTO @T
    VALUES(20,'C_V_Harris','2014-01-02 09:56:15.0000000',
    23.364,      
    23.377)
    INSERT
    INTO @T
    VALUES(19,'C_V_Harris','2014-01-02 09:45:26.0000000',
    23.351,      
    23.367)
    INSERT
    INTO @T
    VALUES(18,'C_V_Harris','2014-01-02 09:43:20.0000000',
    23.380,      
    23.396)
    INSERT
    INTO @T
    VALUES(17,'C_V_Harris','2014-01-02 09:34:28.0000000',
    23.455,      
    23.468)
    INSERT
    INTO @T
    VALUES(16,'C_V_Harris','2014-01-02 09:30:37.0000000',
    23.474,      
    23.486)
    INSERT
    INTO @T
    VALUES(15,'C_V_Harris','2014-01-02 09:18:12.0000000',
    23.419,      
    23.431)
    INSERT
    INTO @T
    VALUES(14,'C_V_Harris','2014-01-02 09:16:06.0000000',
    23.360,      
    23.374)
    INSERT
    INTO @K
    SELECT
    ROW_NUMBER()
    OVER (ORDER
    by IDNO)
    AS RN,*
    FROM
    @T
    SELECT
    * FROM
    @K
    --not working:
    SELECT
    a.RN,a.Price2
    FROM
    @K a
    INNER
    JOIN @K
    b
    ON
    a.RN=b.RN-1
    WHERE
    a.Price2>b.Price2
    I need to create  a view with a column (say 'Comp' below) that compares the value of each row in Price2 with the previous Price2 row, and it is greater then +1, the
    same 0, and less -1.
    The processed table should be:
    IDNO
    name
    Date
    Price1
    Price2
    Comp
    22
    C_V_Harris
    1/2/2014 10:23:49
    23.335
    23.347
    0
    21
    C_V_Harris
    1/2/2014 10:05:13
    23.357
    23.369
    1
    20
    C_V_Harris
    1/2/2014 9:56:15
    23.364
    23.377
    1
    19
    C_V_Harris
    1/2/2014 9:45:26
    23.351
    23.367
    -1
    18
    C_V_Harris
    1/2/2014 9:43:20
    23.38
    23.396
    1
    17
    C_V_Harris
    1/2/2014 9:34:28
    23.455
    23.468
    1
    16
    C_V_Harris
    1/2/2014 9:30:37
    23.474
    23.486
    1
    15
    C_V_Harris
    1/2/2014 9:18:12
    23.419
    23.431
    -1
    14
    C_V_Harris
    1/2/2014 9:16:06
    23.36
    23.374
    -1
     How can I structure the statement to get (the most recent - order by date ) result for Comp?

    Satheesh Variath, I just had to make some corrections from your script to get the correct answer:
    CREATE
    VIEW vw_Comp
    AS
    SELECT
    TOP 1 t.IDNO,t.name,t.[Date],t.Price1,t.Price2,
    CASE
    WHEN t.Price2
    > LAG(Price2,1)
    OVER (PARTITION
    BY name
    ORDER BY IDNO) 
    THEN 1
    WHEN t.Price2
    < LAG(Price2,1)
    OVER (PARTITION
    BY name
    ORDER BY IDNo) 
    THEN -1
    ELSE 0
    END
    AS Comp
    FROM 
    @T t
    ORDER
    BY DATE
    DESC
    The adjustments: the selection of the most recent comparison (Top 1) and the use of the function LAG (instead of LEAD) to get the previous value of the column.

  • How to compare the value node of a for-each-group with other for-each-group

    Hello!
    I have a report in Oracle BI Publisher (10.1.3.2) with several data set. My XML schema is something like
    <DATA>
    <PARAMETERS>
    <MY_PARAMETERS>
    <A_ID>12345</A_ID>
    <DESCRIPTION>ABC</DESCRIPTION>
    <VALUE>111111</VALUE>
    </MY_PARAMETERS>
    <MY_PARAMETERS>
    <A_ID>12345</A_ID>
    <DESCRIPTION>DEF</DESCRIPTION>
    <VALUE>222222</VALUE>
    </MY_PARAMETERS>
    <MY_PARAMETERS>
    <A_ID>67890</A_ID>
    <DESCRIPTION>ABC</DESCRIPTION>
    <VALUE>333333</VALUE>
    </MY_PARAMETERS>
    </PARAMETERS>
    <NAMES>
    <MY_NAMES>
    <A_ID>12345</A_ID>
    <NAME>ASDF</NAME>
    </MY_NAMES>
    <MY_NAMES>
    <A_ID>67890</A_ID>
    <NAME>EFGH</NAME>
    </MY_NAMES>
    </NAMES>
    <VALUES>
    <MY_VALUES>
    <A_ID>12345<A_ID>
    <VALUE>10987</VALUE>
    <DESCRIPTION>ASDFG</DESCRIPTION>
    </MY_VALUES>
    <MY_VALUES>
    <A_ID>12345<A_ID>
    <VALUE>26385</VALUE>
    <DESCRIPTION>EFGHI</DESCRIPTION>
    </MY_VALUES>
    <MY_VALUES>
    <A_ID>67890<A_ID>
    <VALUE>24355</VALUE>
    <DESCRIPTION>ASDFG</DESCRIPTION>
    </MY_VALUES>
    </VALUES>
    </DATA>
    I'm trying to build a rtf template in Word using this XML schema. The "A_ID" nodes in each group in my data have the same value. I want for each "A_ID" take the respective values in /DATA/VALUES/MY_VALUES.
    <?for-each-group:MY_PARAMETERS;./A_ID?>
    <?for-each:current-group()?>
    <?choose:?><?when: DESCRIPTION='ABC'?>
    <?VALUE?>
    <?end when?><?end choose?>
    <?end for-each?>
    <?for-each:current-group()?>
    <?choose:?><?when: DESCRIPTION='DEF'?>
    <?VALUE?>
    <?end when?><?end choose?>
    <?end for-each?>
    <?/DATA/NAMES/MY_NAMES/VALUE?>
    <?for-each-group:/DATA/VALUES/MY_VALUES;./A_ID?>
    <?for-each:current-group()?>
    <?choose:?><?when: DESCRIPTION='ASDFG'?>
    <?VALUE?> <---------------- I obtain for this node the '24355' and '10987' values
    <?end when?><?end choose?>
    I want to know how to obtain only '24355' value, this is, the value for A_ID (/DATA/VALUES/MY_VALUES) = A_ID (/DATA/PARAMETERS/MY_PARAMETERS).
    Can someone help me?

    CREATE OR REPLACE TRIGGER "TEST_TRG"
       BEFORE UPDATE OF "STATUS"
       ON "TABLE1"
       FOR EACH ROW
    BEGIN
       IF (:NEW.status = 'HOLD')
       THEN
          INSERT INTO table2
                      (status
               VALUES (:NEW.status
       END IF;
    END;You should learn how to write PL/SQL code.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.apress.com/9781430235125
    http://apex.oracle.com/pls/apex/f?p=31517:1
    http://www.amazon.de/Oracle-APEX-XE-Praxis/dp/3826655494
    -------------------------------------------------------------------

  • How to represent multiple values in one column

    Hi,
    I need some help in designing a schema for this problem.
    I have :
    - 4 domains
    - In each domain there will be many groups
    - users belong to multiple groups in multiple domains
    Eg.
    user1 might be in groups g1, g2 and g3 in domains d1, d2
    In a text file I represent it like this:
    user1 | d1 | g1,g2,g3
    user2 | d2 | g1, g2
    etc.,
    How do design a schema for this. I don't like the idea of having comma
    separated values in columns.
    Thanks.

    Good instincts. You don't want to have comma-separated values in a column, that violates basic normalization rules.
    You would probably want something like this
    CREATE TABLE usr (
      user_pk
      user_id
    CREATE TABLE grp (
      group_pk
      group_id
    CREATE TABLE domain (
      domain_pk,
      domain_name
    CREATE TABLE domain_group (
      domain_pk,
      group_pk
    CREATE TABLE user_group (
      user_pk,
      group_pk
    )where you create separate tables that map different things to each other. domain_group shows which groups are associated with a particular domain, user_group shows which users are associated with a particular group.
    Justin

  • How do you lookup multiple values in different columns based on variable criteria?

    Essentially, I'd like to be able to do a Vlookup but instead of searching for one value only, search for multiple values in separate columns. A smaller version of my current spreadsheet as an example...
    Attack Type ->
    Fire
    Water
    Grass
    Fire
    1/2x
    2x
    1/2x
    Water
    1/2x
    1/2x
    2x
    Grass
    2x
    1/2x
    1/2x
    Fire/Water
    1/4x
    1x
    1x
    Fire/Grass
    1x
    1x
    1/4x
    Grass/Water
    1x
    1/4x
    1x
    The headers are the attack types and the list of types to the left are the receiving Pokemon. Fire does half damage (1/2x) to fire types, Water does double damage (2x) to fire types, etc. I'd like to be able to search for specific damages for each type. For example, I'd like to find a Typing that recieves half (1/2x) damage from Fire-type attacks but also recieves double (2x) from Grass-type attacks. I do want more than just two search criteria though seeing as the actual table is much, much larger.
    I've tried assigning number values to each damage multiplier and then merging all of them together for a specific typing and doing a VLOOKUP based on checkboxes determining what damage multiplier I want in a few specific types, the rest being filled in to the standard of 1x but the result isn't correct most of the time.

    Hi Mitchell,
    VLOOKUP can be set for accept either an 'exact match' or a 'close match'.  Your 17 digit 'number' is actually a 17 character text string (Numbers can handle numbers to a precision of only 15 places). Provided all 17 digits are present, sorting should be the same as for numerical values—the leftmost character is the most significant.
    As a text string, your 'number' is sorted/evaluated alphabetically. A 'close match' accepts the 'largest value that is less than or equal to the search value'.
    If your search term is 000200000 (a 9 character string), several 'wrong' answers will fit the 'close match' criteria, including all of those listed below:
    000200000 (the 'correct' match)
    0000xxxxx (x may be any of the three acceptable values)
    0001xxxxx (x may be any of the three acceptable values)
    The main problem here is that digits in a number (or characters in a text string) have decreasing significance related to their distance from the beginning of the string/number. You want a search in which each character has the same significance as each of the others when compared to the search key. To do that, you need to compare each character in the search string with the character in the same position in the similar string for each type of Pokemon, then take a count of the matches or a sum of the differences.
    Here's one approach:
    Column A contains labels.
    Column B, the 17 digit search term, created in whatever manner you wish, and the similar 17 digit string for each of the characters.
    Columns C through S contains a formula that detines, using subtraction, the difference between each digit of the search term and the corresponding digit of each character's profile.
    Column C uses SUM() to calculate the total of columns C to S for each row.
    T1 uses =MIN(T) to calculate "least different" profile.
    Column A is a Header column; Row 1 is a Header row.
    Formulas:
    C2, and filled right to S2, then down to the last row of data:
    =ABS(MID($B$1,COLUMN()-2,1)-MID($B2,COLUMN()-2,1))
    T1: =MIN(T)
    T2, and filled down column T: =SUM(C2:S2)
    The conditional formatting rule set for all body cells in column T is shown below the table.
    This may be enough to get you started. Formulas can be tweaked to produce results more closely matching what you're looking for, if necessary.
    Regards,
    Barry

  • How to set default values for boolean columns

    I'm trying to deploy some content types and columns into a site with a feature. All it's ok, except that I'm trying to set a default value for boolean columns with no success.
    I've tried to set default value at column level:
    <Field ID="{EFE23A1D-494E-45cf-832E-45E41B17F0CF}" Name="ScopeSpanish" DisplayName="Se publican noticias en español"
    Type="Boolean" Hidden="FALSE" Group="Columnas ShaCon" >
    <Default>TRUE</Default>
    </Field>
    and at content type level:
    <FieldRef ID="{EFE23A1D-494E-45cf-832E-45E41B17F0CF}" Name="ScopeSpanish" DefaultValue="TRUE" Required="TRUE" />
    But in any case, when i create a new item with this content type, default value is applied.
    Can anyone tell how to set default values for boolean columns?
    Thanks in advance,
    Regards,
    Sergio

    In the field definition you can set
    <Default>1</Default>
    or
    <Default>0</Default>
    How to set the default value Null?

  • Count of schema based on the value in a column

    I have to write a query to count the number of schema that have the value in a column as '1' in a table For ex
    I have a table called Vendor in all the schemas(schema1 through 50) I have to look for the value in a column(Benefits) if it 1 or 0 . I need to do the count of the number of schema who have the Benefits turned ON (value '1')
    suppose the value in benefits(col) in Vendor (tbl) for schema1 is 0 than donot count that schema
    and if the value in benefits(col) in Vendor (tbl) for schema2 is 1 than count
    do i connect as a system manager? Do I need a Pl/sql table to put the count in it
    anybody please help.
    TX
    KK

    As I understand from 325537 description, the table VENDOR contains only one row and column BENEFITS_TRACKING is either 0 or 1
    In this case the total can be calculated by simply summing the values of all BENEFITS_TRACKING
    In case VENDOR has more than one row you need some grouping function like SUM or COUNT
    I don't unterstand why you loop through dba_users.
    Im quite sure that you won't find a VENDORS table in the SYSTEM schema. The 'execute immediate' will fail with a table not found exception.
    Another problem in your code is, you will get no_data_found exception when benefits_tracking=0 because of your where condition
    (remove the where-condition or use a grouping function as explained above)
    declare
      v_count      pls_integer := 0;
      v_curr_count pls_integer := 0;
    begin
      for rec in (select owner from all_tables where owner like 'SCHEMA%' and table_name='VENDORS') loop
          execute immediate 'select SUM(BENEFITS_TRACKING) from '||rec.owner||'.VENDORS' into v_curr_count;
    --      execute immediate 'select COUNT(BENEFITS_TRACKING) from '||rec.owner||'.VENDORS where BENEFITS_TRACKING=1' into v_curr_count;
    --      execute immediate 'select BENEFITS_TRACKING from '||rec.owner||'.VENDORS' into v_curr_count;
          v_count := v_count + v_curr_count;
      end loop;
      dbms_output.put_line(v_count);
    end;

  • How to set 0 for "Nan" Value in the Column

    Hi All,
      I have 3 imp columns with name Build %,Deploy%,Validation % and I would like to set the value as "0" or "1" using formula and below is the formula . But I am getting the values as "Nan" due to that it's reflecting the
    Pivot Table & Report  which show in below 2nd image.
    And I had written formula  as "=SWITCH(EDSCIMonthlyReport[Build %] , "Nan", 0)"  to copy all the values of the Build % Field to another calculated Column and set the value "0" if found "Nan" ,But I am getting
    error as"Function 'SWITCH' attempted to compare values of incompatible types. Ensure that both values are Numeric, String, or Boolean(True/False). Consider using the VALUE or FORMAT function to convert one of the values".Can any one help me how can
    I solve this issue
    Thanks,
    Sid

    Hello Sid,
    Again TFS? The data type of the column is "text" and now you want to convert it to a numeric to use it as a measure, right?
    - First you have to change "NaN" to "0" (<= 0 as type "Text"!, see your error msg); you can do it with an IF expression
    - Then you have to remove the % sign; it's a text as well. For this you can use the SUBSTITUE function
    - Then you can convert it to a numeric using the VALUE function
    As one complete expression it will look like this:
    = VALUE(SUBSTITUTE(If(Tabelle3[Build] = "NaN"; "0"; Tabelle3[Build]); "%"; ""))
    As you can see in below screenshot PowerPivot automatically detects the data type as "Decimal"; now you can use it as a measure value.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Select the newest value of a row in a group by

    On the following query I would like to select the value of the column new_cost which belongs to the row with the newest date in the column m.creation_date, instead of using max(new_cost)
    select s.segment1, segment2, m.organization_id, sum(primary_quantity), max(new_cost)
    from inv.mtl_material_transactions m, inv.mtl_system_items_b s
    where s.segment2 = 1000435
    and m.organization_id = 83
    and s.organization_id = 136
    and m.inventory_item_id = s.inventory_item_id
    group by s.segment1, s.segment2, m.organization_id
    order by s.segment1, s.segment2, m.organization_id for example, on the following table I would like to choose the new_cost of the row with the creation date 20/08/2010 14:37 (row 4)
    SEGMENT1     SEGMENT2     ORGANIZATION_ID     PRIMARY_QUANTITY     NEW_COST     CREATION_DATE
    1     1000435     83     0,66668     175.500     04/06/2010 16:41
    1     1000435     83     1     189.106     22/06/2010 11:54
    1     1000435 83     -0,58333     189.106     19/07/2010 11:55
    1     1000435     83     1     198.459     20/08/2010 14:37
    1     1000435     83     -0,5     189.106     11/08/2010 18:12

    You should be able to use an analytic function... something similar to:
    with data
    as
         select 1 segment1, 1000435 segment2, 83 organization_id, 0.66668 primary_quantity, 175.500 new_cost, to_date('04/06/2010 16:41', 'DD/MM/YYYY HH24:MI:SS') creation_date
         from dual
         union all
         select 1 segment1, 1000435 segment2, 83 organization_id, 1 primary_quantity, 189.106 new_cost, to_date('22/06/2010 11:54', 'DD/MM/YYYY HH24:MI:SS') creation_date
         from dual
         union all
         select 1 segment1, 1000435 segment2, 83 organization_id, -0.58333 primary_quantity, 189.106 new_cost, to_date('19/07/2010 11:55', 'DD/MM/YYYY HH24:MI:SS') creation_date
         from dual
         union all
         select 1 segment1, 1000435 segment2, 83 organization_id, 1 primary_quantity, 198.459 new_cost, to_date('20/08/2010 14:37', 'DD/MM/YYYY HH24:MI:SS') creation_date
         from dual
         union all
         select 2 segment1, 1000435 segment2, 83 organization_id, -0.5 primary_quantity, 189.106 new_cost, to_date('11/08/2010 18:12', 'DD/MM/YYYY HH24:MI:SS') creation_date
         from dual
    select segment1, segment2, organization_id, primary_quantity_sum, new_cost
    from (
        select
              segment1,
              segment2,
              organization_id,
              sum(primary_quantity) over (
                   partition by
                        segment1,
                        segment2,
                        organization_id
              ) primary_quantity_sum,
              new_cost,
              row_number() over (
                   partition by
                        segment1,
                        segment2,
                        organization_id
                   order by
                        creation_date desc
              ) rn
        from data
        where segment2 = 1000435
    where rn = 1

  • Sorting the values in a column in a Web Template Report

    Hi All,
    I have a report build on WAD in which a table is displayed with certain rows and columns and have certain text values in one column and few numeral values in the other few columns. When i right click on the 1st column(having text values) and click on Sort Ascending by Name, the values are sorted in groups.There are other 3 columns next to that column which have text values as well but when i right click on them and try to sort it in some order(ascending by name/descending by name), there are no reorganization of the values in the column. Again, once i go to the other remaining columns having numeral values in it, the values get sorted in ascending/descending order as per the sort selection. Please advise on how i can make the sort possible in the columns in which the rearrangement is not happening. Do i need to change the Query to some settings? Please advise.
    Thanks!
    Subhra Ghosh.

    Subhra,
    In BW reports, the sorting of characteristic values always happens left-to-right. When you choose to sort by columns 2 - 4, you are actually just specifying whether to sort ascending|descending and/or by key or text. This sort happens for each value of the first column, however. Therefore, the sort in column 2 is only noticeable when you have more than one row with the same value in column 1, etc.
    This sorting behavior is different than the Excel type of sorting, which may be your confusion here.
    If you want to sort first by a column other than column 1, you must swap the columns so that the desired characteristic is in column 1.
    Hope this helps...
    Bob

  • Zero values in stacked column

    Hello all, I'm doing some reports in apex 4 and I'd like to hide the zero values. Could it be possible?
    I've read most of anychart doc and xml reference but I can't seem to find what I'm looking for.
    The data format section in anychart doc: http://www.anychart.com/products/anychart/docs/users-guide/number-formatting.html
    here is my problem:
    http://imgur.com/wot2u.jpg
    like always thanks in advance....

    Hello Hillary, thanks for the input...
    about your comments first of all I've already considered the turning off of the labels and I'm keeping that workaround as an eventual option.
    about the data set, I couldn't imagine a data set with restiricted zero (or null) values. i'll try to expliain why with a sample data set (maybe you can paste it in excel for a better view):
    group_label;value1;value2;value3;value4
    group1; 2 3 0 2
    group2; 1 0 0 3
    group3; 0 2 1 1
    so you see here how each group will form a bar. group1 will have stacked values of 2,3,0,2. the where clause wont work given there is a value of that column needed to form the group3 bar.
    anyway, maybe if I wait a while some will come up with the same problem.
    thanks again!

Maybe you are looking for

  • Need help abt Purchase order and material document number

    1)Is there any releation ship between Purchse order number and material document number? 2) I found aBAPI to get the goods receipt details. That is BAPI_GOODSMVT_GETDETAIL. But it is excepting Material document number and material document year as in

  • My Macbook Pro (2010, 10.9.5) turns off by itself randomly

    Hi all My Macbook Pro (mid 2010, 2.53 GHz, ram 4GB, Intel Core i5, Mac OS 10.9.5) turns off randomly while I am working. The screen turns black and I get a message that my "mac was turned off due to a problem". It turns on again and all seems normal.

  • UPDATE_DOCINFO service from hcsp

    I am having the following code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <M

  • Final Items Would like to Modify...

    Hi, Here are a few items I'd like to iron out for this site design... 1) CURIOUSITY: The sign up box, I chose the 'center' alignment within the CSS panel so that the text would be centered within that box...however, when I uploaded, I found that the

  • Mail to Submit form.

    I have made an editable PDF with textfields and a submit form button. Problem, the mailto - submit form - button isn't working. Any ideas how to make it work? Also how do I remove permissions so people can edit and save the PDF with any PDF program.