Move row based on one duplicated value

is it possbile to move entire rows base on just the value in the first column?
1    a
1    b
2    c
2   d
the result should be
1   a
2   c

Yes - double the header row, then use a formula like the one that I posted but start in row 1, with the formula
=COUNTIF($A$1:$A1,$A1)
Then copy down, copy that column, paste as values, and finally, sort the entire table
based on that value. Then List1 will all have 1s in that column, List2 will have 2s, etc.

Similar Messages

  • Formating the Row Based on one column value

    Hi Friends
    I am trying to format the Entire row based on the value of the first column in my Answers.
    Example if first column value in 'F' now i want the Entire row to be colored
    I can do conditional formating on one column but i want to do it on the entire row
    F     8.1 %     12.0 %
    E     5.2 %     3.5 %
    M     2.3 %     3.3 %
    If any one has done this or any suggestions please respond
    Thanks
    Sang

    Its a Pivot View
    F 8.1 % 12.0 %
    E 5.2 % 3.5 %
    M 2.3 % 3.3 %
    the column 1 --> F,E,M are the Product
    the column 2 --> 8.1% , 5.2% , 2.3% are the sales in year 2008
    the column 3 --> 12.0 % , 3.5 %, 3.3 % are the sales in year 2009
    So will i be able to apply the formating in pivot view based on one column to other column If yes please let me know how or
    suggest if this can be done using the BI Office , or BI publisher
    sing the BI Office i can do the formating in Excel but once i refresh the data all the formating is gone ... :(
    I am donno BI Publisher if we have to use BIP please suggest any solution its very very very urgent and important report formating they need here ....
    Thanks in advance David
    sango

  • Join all rows bases on one column value

    Hi All,
    I have requrement like Join all rows bases on one column value, i am not getting how to accomplish that. Here is my requrement. i have table test(id,id_desc) with no key
    table:Test
    id id_desc
    1 desc_a
    1 desc_b
    1 desc_c
    Now the requremnet i have one more table as test1(id,id_desc) here id is primary key. where record i need to insert as
    id id_desc
    1 desc_a
    desc_b
    desc_c

    orza wrote:
    Hi All,
    I have requrement like Join all rows bases on one column value, i am not getting how to accomplish that. Here is my requrement. i have table test(id,id_desc) with no key
    table:Test
    id id_desc
    1 desc_a
    1 desc_b
    1 desc_c
    Now the requremnet i have one more table as test1(id,id_desc) here id is primary key. where record i need to insert as
    id id_desc
    1 desc_a
    desc_b
    desc_cI'm guessing you want to pivot the results in TEST and use that to insert into TEST1?
    If so this may be useful
    http://www.oracle-base.com/articles/misc/StringAggregationTechniques.php

  • Need to  color a Table row based on a Column value

    Dear Alll
    I have a requirement to color the rows of a table based on a column value in it. I have tried and surfed many useful materials over the net. but none of them solves my purpose. Please help me, I know that i can used OADataBoundValueViewObject and create a custom css file and apply color to a particular column of a table using a decode in the select statement of that VO.
    But all i need is to color a particular row with a particular color. Need your help with this ........
    Please do reply
    Best Regards
    Edited by: Antony Jayaraj on Mar 27, 2012 8:54 PM

    These posts might help you.
    How to change the row color based on Condition
    Can we colour the rows in the column of a table
    Regards,
    Peddi.

  • How not show duplicate rows based on one field

    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0
    Hello
    I have a query that looks for certain scripts that did not run on a particular day compared to what ran the same day a week ago. We want to include the start_datetime and end_datetime but when I add it to the select statement it brings up all instances of the jobs that run multiple times during the day. Is there a way to exclude the extra rows based on the script_name field?
    SELECT instances.script_name,
                             instances.instance_name,
                             REGEXP_REPLACE(master.description,
                                            chr(49814),  -- em-dash
                                            '-') description
                                            --instances.start_datetime
                      FROM   xxcar.xxcar_abat_instances Instances,
                             xxcar.xxcar_abatch_master  Master
                      WHERE  1 = 1
                      AND    TRUNC(start_datetime) = TRUNC(TO_DATE(:p_StartDate, 'YYYY/MM/DD HH24:MI:SS')) - (:p_NumOfWeeks * 7)
                      AND    Instances.SCRIPT_NAME = Master.SCRIPT_NAME (+)
                      MINUS
                      SELECT script_name,
                             instance_name,
                             NULL
                             --NULL
                      FROM   xxcar.xxcar_abat_instances
                      WHERE  1 = 1
                      AND    TRUNC(start_datetime) = TRUNC(TO_DATE(:p_StartDate, 'YYYY/MM/DD HH24:MI:SS'))

    MINUS does a set operation - removing rows from the first set that exactly match the second set.
    When you add columns to the first set, you want a more restricted filtering - try a multi-column NOT IN:
    To remove multiple runs, group and get min/max
    SELECT instances.script_name,
                             instances.instance_name,
                             REGEXP_REPLACE(master.description,
                                            chr(49814),  -- em-dash
                                            '-') description,
                             min(instances.start_datetime) start_datetime,
                             min(instances.end_datetime) end_datetime
                      FROM   xxcar.xxcar_abat_instances Instances,
                             xxcar.xxcar_abatch_master  Master
                      WHERE  1 = 1
                      AND    TRUNC(start_datetime) = TRUNC(TO_DATE(:p_StartDate, 'YYYY/MM/DD HH24:MI:SS')) - (:p_NumOfWeeks * 7)
                      AND    Instances.SCRIPT_NAME = Master.SCRIPT_NAME (+)
                      AND (script_name, instance_name) NOT IN
                    ( SELECT script_name,
                             instance_name
                      FROM   xxcar.xxcar_abat_instances
                      WHERE  1 = 1
                      AND    TRUNC(start_datetime) = TRUNC(TO_DATE(:p_StartDate, 'YYYY/MM/DD HH24:MI:SS'))
    group by instances.script_name, instances.instance_name, master.descriptionYou didn't give table definitions, and the query has schemas in it, so I didn't test it.
    regards,
    David

  • Adding a row based on a total value

    I have the following table
    tablea
    AnID
    Aname
    aTotal
    57
    Agatha
    28
    58
    Bertie
    13
    59
    Guilford
    17
    60
    Francois
    12
    I want to be able to create a query that displays the id aname atotal and also another column called noofrows.  I would like the query to list multiple records for each AnId based on the atotal / 14 e.g. if the aTotal equals 28 then there will be two
    rows for Anid 57 and the Noofrows column will display a1 and a2.  If there result is less than 14 and greater or equal to 1, the total rows must be 1.  If the total is 0 then the rows will be 0. See below the results of this example
    AnID
    Aname
    Total
    Noofrows
    57
    Agatha
    28
    a1
    57
    Agatha
    28
    a2
    58
    Bertie
    13
    a1
    59
    Guilford
    56
    a1
    59
    Guilford
    56
    a2
    59
    Guilford
    56
    a3
    59
    Guilford
    56
    a4
    60
    Francois
    80
    a1
    60
    Francois
    80
    a2
    60
    Francois
    80
    a3
    60
    Francois
    80
    a4
    60
    Francois
    80
    a5
    60
    Francois
    80
    a6
    Can anyone help?

    This was a fun one. This should work for you.
    --drop table #temp
    create table #temp
    AnID int,
    Aname varchar(10),
    total int
    insert into #temp(AnID, Aname, total) values ('57','Agatha','28')
    insert into #temp(AnID, Aname, total) values ('58','Bertie','13')
    insert into #temp(AnID, Aname, total) values ('59','Guilford','56')
    insert into #temp(AnID, Aname, total) values ('60','Francois','12')
    ; WITH CTE (CT,AnID, Aname, Total, Rw)
    as
    select
    1 as CT,
    t.AnID,
    t.Aname, 
    t.total,
    SUM(t.total/14) over (partition by t.AnID, t.Aname order by t.total) as rw
    from #temp t
    UNION ALL
    select
    CT + 1,
    t.AnID,
    t.Aname, 
    t.total,
    SUM(t.total/14) over (partition by t.AnID, t.Aname order by t.total) as rw
    from #temp t
    inner join cte c
    on c.AnID = t.AnID
    where ct <= (rw-1)
    select 
    AnID,
    Aname, 
    total,
    'a' + cast((row_number() over (partition by AnID, Aname, Total order by total)) as varchar(10)) as Noofrows
    from cte 

  • Hide or delete row based on it's value?

    If I have a column called "Name" and I want to delete or hide all the rows which include the name "smith" or alternatively all the rows with "Miss" how do I do this?
    I know I can manually search to find the name "smith" but I have 60,000+ rows in my spreadsheet.
    Format:
    Column 1
    Row 1: Miss J Jones
    Row 2: Mr P Smith
    Row 3: Mr C Widget
    etc...
    Thanks.

    Here is an AppleScript whic is able to delete the rows matching your criteria.
    --[SCRIPT removematchingrows]
    Enregistrer le script en tant que Script : removematchingrows.scpt
    déplacer le fichier ainsi créé dans le dossier
    <VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:Applications:Numbers:
    Il vous faudra peut-être créer le dossier Numbers et peut-être même le dossier Applications.
    Sélectionner une cellule de la colonne dans laquelle le script cherchera le mot clé.
    menu Scripts > Numbers > removematchingrows
    Tapez le mot à chercher puis cliquez OK.
    Le script supprimera les lignes dont la cellule de la colonne sélectionnée contenait le mot saisi.
    --=====
    L'aide du Finder explique:
    L'Utilitaire AppleScript permet d'activer le Menu des scripts :
    Ouvrez l'Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
    Cochez la case "Afficher le menu des scripts dans la barre de menus".
    --=====
    Save the script as a Script: removematchingrows.scpt
    Move the newly created file into the folder:
    <startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
    Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
    Select a cell in the column in which we will search a key word.
    menu Scripts > Numbers > removematchingrows
    You will be asked to type the word to search.
    Type it then click OK.
    The script will remove the rows whose the cell of the selected column contained the choosed word.
    --=====
    The Finder's Help explains:
    To make the Script menu appear:
    Open the AppleScript utility located in Applications/AppleScript.
    Select the "Show Script Menu in menu bar" checkbox.
    --=====
    Yvan KOENIG (VALLAURIS, France)
    2010/03/24
    --=====
    on run
    if my parleAnglais() then
    set theKey to text returned of (display dialog "Enter the word to search …" default answer "At least one cell of the column in which we will search must be selected.")
    else
    set theKey to text returned of (display dialog "Saisir le mot à chercher …" default answer "Une cellule de la colonne dans laquelle il faut chercher doit être sélectionnée.")
    end if
    set {dName, sName, tName, rname, rowNum1, colNum1, rowNum2, colNum2} to my getSelParams()
    tell application "Numbers" to tell document dName to tell sheet sName to tell table tName
    set nbRows to row count
    repeat with r from nbRows to 1 by -1
    set maybe to (value of cell r of column colNum1) as text
    if words of maybe contains theKey then
    remove row r
    end if
    end repeat
    end tell -- Numbers
    end run
    --=====
    on getSelParams()
    local r_Name, t_Name, s_Name, d_Name, col_Num1, row_Num1, col_Num2, row_Num2
    set {d_Name, s_Name, t_Name, r_Name} to my getSelection()
    if r_Name is missing value then
    if my parleAnglais() then
    error "No selected cells"
    else
    error "Il n'y a pas de cellule sélectionnée !"
    end if
    end if
    set two_Names to my decoupe(r_Name, ":")
    set {row_Num1, col_Num1} to my decipher(item 1 of two_Names, d_Name, s_Name, t_Name)
    if item 2 of two_Names = item 1 of two_Names then
    set {row_Num2, col_Num2} to {row_Num1, col_Num1}
    else
    set {row_Num2, col_Num2} to my decipher(item 2 of two_Names, d_Name, s_Name, t_Name)
    end if
    return {d_Name, s_Name, t_Name, r_Name, row_Num1, col_Num1, row_Num2, col_Num2}
    end getSelParams
    --=====
    set {rowNumber, columnNumber} to my decipher(cellRef,docName,sheetName,tableName)
    apply to named row or named column !
    on decipher(n, d, s, t)
    tell application "Numbers" to tell document d to tell sheet s to tell table t to return {address of row of cell n, address of column of cell n}
    end decipher
    --=====
    set { d_Name, s_Name, t_Name, r_Name} to my getSelection()
    on getSelection()
    local _, theRange, theTable, theSheet, theDoc, errMsg, errNum
    tell application "Numbers" to tell document 1
    set nbCols to column count
    repeat with i from 1 to the count of sheets
    tell sheet i
    set x to the count of tables
    if x > 0 then
    repeat with y from 1 to x
    try
    (selection range of table y) as text
    on error errMsg number errNum
    set {_, theRange, _, theTable, _, theSheet, _, theDoc} to my decoupe(errMsg, quote)
    return {theDoc, theSheet, theTable, theRange}
    end try
    end repeat -- y
    end if -- x>0
    end tell -- sheet
    end repeat -- i
    end tell -- document
    return {missing value, missing value, missing value, missing value}
    end getSelection
    --=====
    on decoupe(t, d)
    local l
    set AppleScript's text item delimiters to d
    set l to text items of t
    set AppleScript's text item delimiters to ""
    return l
    end decoupe
    --=====
    on parleAnglais()
    local z
    try
    tell application "Numbers" to set z to localized string "Cancel"
    on error
    set z to "Cancel"
    end try
    return (z is not "Annuler")
    end parleAnglais
    --=====
    --[/SCRIPT]
    At this time, I don't know how to Hide a row thru AppleScript.
    Yvan KOENIG (VALLAURIS, France) mercredi 24 mars 2010 17:02:20

  • How to retrieving latest row based on a column value

    Hi,
    Lets consider a scenario. I have a table which has a order number, count column which is our fact, a type column which contains types e.g. (A,B) with A has more priority then B. Now in our graph we are getting all rows i.e. if we have two rows in db for order #1 one for type A and one for type B, then it shows us data from both rows in graph.
    But I need only to show one row of type A in this case as A has higher priority than B. The row with type B should not contribute in construction of my graph if type A for same row also exists.
    I tried a solution, for which i created a new column at logical level which contain 1 for A and 0 for B. Now i put Max aggregation rule in it to get maximum value which will be row with Type A in our case. But it did not work.
    How we will can achieve it in OBIEE?
    Thanks.
    Aasim Khan.

    Hi Steve,
    I have a similar requirement... one of the columns in my table is a calculated value based on several xml fields,
    <?xdofx:(MATH01+MATH02+MATH03+MATH04+MATH05+AA+AA1)+((FNDCD01+FNDCD02+FNDCD03+FNDCD04+FNDCD05+MCHCD01+MCHCD02) div '8')?>
    if the resultant value above is less than 62, i do no want to display this entire row in the output. could you help me wout with this?
    thanks
    Domnic

  • Update a row based on the minimum value

    I need to update a row value in a table (table1) which is having one-to-may relationship with another table (table2) based on priority. Below is the table structure and sample data. I have a merge statement which can just do this, but it's taking too much to execute if the data in table2 is huge.
    I want to reduce the execution time, can anyone suggest me another way to do this.
    --Table Definition
    CREATE TABLE TABLE_1 (ENAME VARCHAR2(20), ID NUMBER(20), DISPLAY_NAME VARCHAR2(20), PRIMARY KEY (ENAME));
    CREATE TABLE TABLE_2 (ENAME VARCHAR2(20), DISPLAY_NAME VARCHAR2(20), PRIORITY NUMBER(1));
    --Sample data
    INSERT INTO TABLE_1 (ENAME,ID) VALUES ('EMP1','1000');
    INSERT INTO TABLE_1 (ENAME,ID) VALUES ('EMP2','2000');
    INSERT INTO TABLE_2 (ENAME,DISPLAY_NAME,PRIORITY) VALUES ('EMP1','APPLE',1);
    INSERT INTO TABLE_2 (ENAME,DISPLAY_NAME,PRIORITY) VALUES ('EMP1','DELL',2);
    INSERT INTO TABLE_2 (ENAME,DISPLAY_NAME,PRIORITY) VALUES ('EMP1','MS',NULL);
    --Merge to perfor the update
    MERGE INTO TABLE_1 T USING
    (select ename, display_name from TABLE_2 where (ename,priority) in (
    select distinct ename, min(priority) over (partition by ename) from TABLE_2 min_prior)) Q
    ON (T.ENAME = Q.ENAME)
    WHEN MATCHED THEN UPDATE SET DISPLAY_NAME = Q.DISPLAY_NAME;

    Hi,
    You can use the aggregate FIRST function, like this:
    MERGE INTO     table_1          t
    USING   (
             SELECT    ename
             ,            MIN (display_name) KEEP (DENSE_RANK FIRST ORDER BY priority)     
                              AS first_display_name
             FROM      table_2
             GROUP BY  ename
         )               q
    ON      (t.ename = q.ename)
    WHEN MATCHED THEN UPDATE
    SET      t.display_name      = q.first_display_name
    ;If the combination (ename, priority) is not unique in table_2, then this uses the first display_name (in normal sort order) among those with the lowest priority. This probably can't happen, becuase your original statement would raise an error if it did.
    For performance problems, see the forum FAQ {message:id=9360003}

  • How to group rows based on a formula value

    Hi experts,
    I have a query that returns a a char row (country) and a couple of columns, "Duration of Process in days" and "Counter of nº process done", each a calculated formula KF .
    What I would like is to group the results based on formula KF1 results ""Duration of Process in days".
    For example: from this query result
    Country  -   Duration of Process in Days  -   Counter of nº process done
    ES                      1                                         3
    PT                      3                                         2
    UK                      4                                         3
    IT                       1                                          5
    US                      6                                         2
    FR                      1                                         3
    DE                      4                                         5
    get the following: aggregated by all possible formula values "Duration of Process in Days"
    Duration of Process in Days  -   Counter of nª process
                    1                                       11   (353)
                    3                                         2
                    4                                         8    (3+5)
                    6                                         2
    Is this possible??
    Thanks in advance for your help,
    Best regards,
    Enric

    Hi Vikram,
    my problem is that the "Duration in days" cannot be a characteristic derived in the loading process, as its value depends (is calculated) based on several user's selections done in the variable pop-up screen when executing the report.
    Thanks again for your reply.
    Enric

  • Counting rows based on a column value

    Tricky Query.No offence if this is a repeat please.
    This is a PROD issue in SYBASE.
    TableA has id_flag_listing column
    TableA
    id_flag_listing
    N
    N
    N
    N
    N
    1) If all rows are set to 'N',then my count should be 0.
       PrimaryListing
       0
    2) If there is one row which is 'Y' then this shoud be:
       id_flag_listing
       N
       N
       Y
       N
       N
       PrimaryListing
       1
    How can I count in this manner?
    Do i use decode? I am using
    Select sum(decode(flg_active),'Y',1,0))
    from TABLEA
    Will the above work.??
    I am using SQL for Sybase.
    Please guide?

    Did you even tried the SQL query I've given?
    Your table A
    SQL> SELECT flg_listing
      2  FROM
      3  (
      4     SELECT 'N' flg_listing FROM DUAL
      5     UNION ALL
      6     SELECT 'N' FROM DUAL
      7     UNION ALL
      8     SELECT 'N' FROM DUAL
      9     UNION ALL
    10     SELECT 'N' FROM DUAL
    11     UNION ALL
    12     SELECT 'N' FROM DUAL
    13  ) TABLEA;
    FLG_LISTING
    N
    N
    N
    N
    N
    Your table A, from which I count where are of 'Y' value. In these queries, I change TableA contents.
    SQL> SELECT count(*)
      2  FROM
      3  (
      4     SELECT 'N' flg_listing FROM DUAL
      5     UNION ALL
      6     SELECT 'N' FROM DUAL
      7     UNION ALL
      8     SELECT 'N' FROM DUAL
      9     UNION ALL
    10     SELECT 'N' FROM DUAL
    11     UNION ALL
    12     SELECT 'N' FROM DUAL
    13  ) TABLEA
    14  WHERE flg_listing = 'Y';
      COUNT(*)
             0
    SQL> SELECT count(*)
      2  FROM
      3  (
      4     SELECT 'N' flg_listing FROM DUAL
      5     UNION ALL
      6     SELECT 'N' FROM DUAL
      7     UNION ALL
      8     SELECT 'Y' FROM DUAL
      9     UNION ALL
    10     SELECT 'N' FROM DUAL
    11     UNION ALL
    12     SELECT 'N' FROM DUAL
    13  ) TABLEA
    14  WHERE flg_listing = 'Y';
      COUNT(*)
             1
    SQL> SELECT count(*)
      2  FROM
      3  (
      4     SELECT 'N' flg_listing FROM DUAL
      5     UNION ALL
      6     SELECT 'N' FROM DUAL
      7     UNION ALL
      8     SELECT 'Y' FROM DUAL
      9     UNION ALL
    10     SELECT 'Y' FROM DUAL
    11     UNION ALL
    12     SELECT 'Y' FROM DUAL
    13  ) TABLEA
    14  WHERE flg_listing = 'Y';
      COUNT(*)
             3Yoann.

  • Selecting rows based on one column change

    Hi All -
    I need to select the rows from a table (this table has 4 columns and has a primary key and have many records for that primary key).
    I need to select all the rows for this primary key for which only one column (in this case "flag" column) has been changing from its past value.
    How can I do this?
    for example, table data is:
    ID, flag, Profile,date
    pk, Y, Profile4,01/10/10
    pk, N, Profile4, 01/08/10
    pk,N, Profile3, 01/07/10
    pk,Y, Profile3, 01/05/10
    pk,Y, Profile2, 01/03/10
    pk,N, Profile1, 01/02/10
    The output of the query I am looking for should return the following i.e. only retrieve rows whose previous flag value has been changed:
    ID, flag, Profile,date
    pk, Y, Profile4,01/10/10
    pk,N, Profile3, 01/07/10
    pk,Y, Profile2, 01/03/10
    pk,N, Profile1, 01/02/10
    Please share your expertise.
    Thanks,
    Seenu

    Hi, Seenu,
    Centinul wrote:
    It is always helpful to provide the following:
    1. Oracle version (SELECT * FROM V$VERSION)
    2. Sample data in the form of CREATE / INSERT statements.
    3. Expected output
    4. Explanation of expected output (A.K.A. "business logic")
    5. Use \ tags for #2 and #3. See FAQ (Link on top right side) for details.
    Seenu001 wrote:(1) Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
    PL/SQL Release 10.2.0.3.0 - Production
    CORE 10.2.0.3.0 Production
    TNS for Solaris: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production Good!
    (2) select 'pk' id,'Y' flag,'Profile4' profile,to_date('01/10/10','mm/dd/yy') dt from dual union all
    select 'pk','N','Profile4',to_date('01/08/10','mm/dd/yy') from dual union all
    select 'pk','N','Profile3',to_date('01/07/10','mm/dd/yy') from dual union all
    select 'pk','Y','Profile3',to_date('01/05/10','mm/dd/yy') from dual union all
    select 'pk','Y','Profile2',to_date('01/03/10','mm/dd/yy') from dual union all
    select 'pk','N','Profile1',to_date('01/02/10','mm/dd/yy') from dualNot bad. It can be made into a CREATE TABLE AS statement without a lot of work, but if you're not willing to do that little bit or work, why should anyone else?     
    (3) Expected output: I want all the rows from this table where the flags have been changed from its previous value.That's a vague description. Post the exat output, like Solomon did:
    ID F PROFILE  DT
    pk N Profile1 01/02/2010
    pk Y Profile2 01/03/2010
    pk N Profile3 01/07/2010
    pk Y Profile4 01/10/2010
    (4) I want all the rows from this table where the flags have been changed from its previous value.That's a repeat of the vague description. Explain how you get the crorrect results, with specific examples, like this:
    "The row dated January 2 should be included, because it is the oldest row in the table, regardless of what its flag is.
    The row dated January 3 should be included because ...
    The row dated January 5 should *not* be included, because ..."
    You don't have to explain every row, just every reason.
    Solomon - I tried your query but the prev_flag is not being populated, it shows null value '-'NULL is not the same as '-'. Did you issue a command like
    SET NULL "-"that would display a '-' instead of NULL?
    Solomon's query works fine for me, as it did for him. Post your code, even if you just copied it from this site. (There may have been an editing problem.)
    Frank - I tried your query, prev_flag is populated in this case but when I am using with the WITH clause, I am getting an error saying "unsupported column aliasing" , I guess WITH command doesnt allow use of column alias. The problem is that I forgot the keyword AS after the sub-query name.
    WITH     got_prev_flag     AS
         SELECT     id, flag, profile, dt     -- DATE is not a good column name
         ,     LAG (flag, 1, '??') OVER (ORDER BY dt)  AS prev_flag
         FROM     t
    --     WHERE     ...     -- any filtering goes here
    SELECT     id, flag, profile, dt
    FROM     got_prev_flag
    WHERE     flag     != prev_flag
    ;If you don't post data in an executable form, then people can't test their ideas. If people can't test their ideas, trivial mistakes like this are very likely.
    This flag column will have either
    Y or N columns. Could you tell me what is the use of "??" value.By default, LAG returns NULL for the first row. If you want to include the first row in the results, then "WHERE     flag     != prev_flag" won't work when prev_flag is NULL. We could explicitly check for "prev_flag IS NULL", but I find it cleared to override the default, and have LAG return '??' on the first row. I guessed that '??' would make the condition "WHERE     flag     != prev_flag" work, no matter what value flag had. There's nothing magical about '??'; you can use any string that will never actually match flag.

  • Changing the font color for the complete row based on the Keyfigure Values

    Hi Experts,
    Can any one help me to find a solution for this?.
    I have a requirement, in which the Font color for the complete Row needs to be set to RED in Bex Report, when the corresponding Row Keyfigure is more than a particular value.
    Ex: Notification-Material-Customer-Def Qty-delivered Qty
          1000000 - XXXXX- AAAAAA-10-1000
    in the above example, when the Defect qty increses more than 10, then the complete Row Including the characterstics, Notification, Material, and customer Should be Highlighted in Red. This has to happen automatically once the Query is refreshed.
    Please let me know if you have any suggestion here?.
    Regard,
    Muruganand.K

    Hi,
    Step 1: Click the Format Menu in Excel(BEX Analyzer)
    Step 2: Click the Style submenu
    Step 3: there will be number of SAPBEX formats available. Each of these relates to another cell of BEx (Header, Cell Data,
                Result  Row, Hierarchies, etc.). Also, they depend on data types.
    Step 4: Select SAPBEXchatext
    Step 5: Click Modify. This displays all the standard formatting option as shown below.
    Step 6: Select Font, Color (Background/ Font).
    Step 7: Click OK on both the screens. The entire BEx output result row Font and color is modified.
    Hope it helps........
    Regards,
    Suman

  • [8i] Way to add a specific nbr of rows based on a column value? (Follow-up)

    I'm dealing with an old database that's being phased out, and here's the version info (yes, it's really old):
    Oracle8i Enterprise Edition Release 8.1.7.2.0 - Production
    PL/SQL Release 8.1.7.2.0 - Production
    CORE 8.1.7.0.0 Production
    TNS for HPUX: Version 8.1.7.2.0 - Production
    NLSRTL Version 3.4.1.0.0 - Production
    I believe Frank Kulash gave me the solution to my original question, which was:
    Sample data:
    CREATE TABLE     testabc
    (     item     CHAR(25)
    ,     qty     NUMBER(13,4)
    INSERT INTO     testabc
    VALUES ('Item1',1);
    INSERT INTO     testabc
    VALUES ('Item2',3);
    INSERT INTO     testabc
    VALUES ('Item3',1);
    INSERT INTO     testabc
    VALUES ('Item4',2); Desired results:
    ITEM                                  QTY
    Item1                               1.000
    Item2                               3.000
    --blank row
    --blank row
    Item3                               1.000
    Item4                               2.000
    --blank rowAnd the solution:
    SELECT       CASE
              WHEN c.n = 1  THEN  t.item
           END          AS item_col
    ,       CASE
               WHEN c.n = 1  THEN  t.qty
           END          AS qty
    FROM       testabc  t
              SELECT     ROWNUM     AS n
              FROM     all_objects
              WHERE     ROWNUM     <= 10     -- If you know an upper bound
           )          c
    WHERE       c.n     <= t.qty
    ORDER BY  t.item
    ,            c.n
    ;Now, it turns out there are only some items which need these extra rows, but I'm not sure if it's possible to only include extra rows for certain items or not...
    Here's my new sample data:
    CREATE TABLE     testabc1
    (     s     CHAR(1)
    ,     item     CHAR(25)
    ,     qty     NUMBER(13,4)
    INSERT INTO     testabc1
    VALUES ('*','Item1',1);
    INSERT INTO     testabc1
    VALUES ('','Item2',3);
    INSERT INTO     testabc1
    VALUES ('*','Item3',3);
    INSERT INTO     testabc1
    VALUES ('*','Item4',2);And my new desired results: (any row with an asterisk gets extra rows, if the qty is greater than 1)
    S ITEM                                  QTY
    * Item1                               1.000
      Item2                               3.000
    * Item3                               3.000
    --blank row
    --blank row
    * Item4                               2.000
    --blank rowEdited by: user11033437 on Jan 3, 2012 9:27 AM (fixed missing asterisk in desired results)

    Hi,
    Here's a slightly simpler way:
    SELECT       CASE
              WHEN c.n = 1  THEN  t.item
           END          AS item_col
    ,       CASE
               WHEN c.n = 1  THEN  t.qty
           END          AS qty
    FROM       testabc1  t
              SELECT     ROWNUM     AS n
              FROM     all_objects
              WHERE     ROWNUM     <= 10     -- If you know an upper bound
           )          c
    WHERE       c.n     <= CASE
                       WHEN  t.s  = '*'
                       THEN  t.qty
                     ELSE  1
                 END
    ORDER BY  t.item
    ,            c.n
    ;This is just like the previous solution, except that the WHERE clause, which was originally
    WHERE       c.n     <= t.qtyis now
    WHERE       c.n     <= CASE ... END
    user11033437 wrote:... And my new desired results: (any row with an asterisk gets extra rows, if the qty is greater than 1)
    S ITEM                                  QTY
    * Item1                               1.000
    Item2                               3.000
    Item3                               3.000
    --blank row
    --blank row
    * Item4                               2.000
    --blank row
    S should be '*' on the output row where item='Item3', right?
    I'm sure you know how to get the s column in the output, but, since I've already tried it:
    SELECT       CASE
              WHEN c.n = 1  THEN  '*'
           END                AS s
    ,       CASE
              WHEN c.n = 1  THEN  t.item
           END          AS item_col
    ,       CASE
               WHEN c.n = 1  THEN  t.qty
           END          AS qty
    FROM       testabc1  t
              SELECT     ROWNUM     AS n
              FROM     all_objects
              WHERE     ROWNUM     <= 10     -- If you know an upper bound
           )          c
    WHERE       c.n     <= CASE
                       WHEN  t.s  = '*'
                       THEN  t.qty
                     ELSE  1
                 END
    ORDER BY  t.item
    ,            c.n
    ;Edited by: Frank Kulash on Jan 3, 2012 11:11 AM

  • Count Rows based on an optionaet value in CRM Online Fetchxml Report

    Hi,
        I am new to FetchXml Reports, I have a Report in which i want to Sum the records which have different Optionset values
    Like Profit,NonProfit,Other.
    I want to calculate the number of rows which have options (Profit,NonProfit,NotApplicable) and show in other column.
    Thanks

    in a last row insert an expression:
    =sum(iif(Fields!IsOrganization.Value = "Profit",1,0) + iif(Fields!IsOrganization.Value = "NonProfit",1,0) + iif(Fields!IsOrganization.Value = "NotApplicable",1,0))
    It will count all rows with "Profit", "NonProfit" and "NotApplicable" text in IsOrganization field.

Maybe you are looking for

  • U530 Touch - Audio DRIVER ERROR - This device cannot start (Code 10) - Windows 7

    U530 - High definition audio device - ERROR - This device cannot start (Code 10) Windows 7, please see the picture Picture link (hosted on photobucket.com) I got all drivers up to date including the BIOS, everything is working fine (the sound works,

  • Linking between tabs

    Hi, Sorry if I'm repeating a prior post. I have searched but can't find the answer I'm looking for. It's pretty simple. How do I link between tabs on the same Index page? My entire site is basically just the index page with many tabs on it. How do I

  • Can't Remove HD

    I hope someone can help with this. I have a Powermac G5 with 2 HD's in the top and bottom bays. I can't remove the bottom drive because it's really wedged in there. I can't remove the top drive first because of the bottom drive. I've tried to wiggle

  • Add a Watermark

    Hi, I would like to create a watermark component in Flex, like those that we can see in commercial products (i.e. transparent letters with grey surroundings). How can I do this? I've already tried to add a scalable image over my application, but doin

  • How to show an empty JLabel?

    Hi, I tried to create a JLabel containing nothing, gave it a size and a background color...but when i add it to a JFRame, it just won't show! I tried setVisible(true), and it's not either! Anyone knows what i should do?