Count of Column  based on Value

Hi All
In our database table we have 3 columns closedate,empcode,status.
I am using the following query to fetch the data required :
select closedate,count(empcode) COUNT,EMPCODE,status from dbcleaning WHERE STATUS='Fixed' and EMPCODE='E315' group by closedate,STATUS,EMPCODE.
the result is like this :
closedate count EMPCODE STATUS
2010-10-10 98 E315 Fixed
2010-10-11 15 E315 Fixed
However i want the data to be based on DISTINCT EMPCODE , fo Eample :
closedate EMPCODE(ST001)       EMPCODE(ST002) STATUS
2010-10-10 *98 125* Fixed
2010-10-11 *128 225* Fixed
I hope i had explained properly
Replies are highly appreciated.
Thank You
Edited by: user9366471 on Jun 30, 2010 12:29 AM

It's always a better idea to post DDL of your table and INSERT statement. Also don't forget to mention the output you required. It's even better if you use tag for those DDL and DMLs.
Your database version is a important thing for exact solution.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • Custom table column based on value scale

    I want to custom table column based on the vaules.
    I understood I need to to /1000000 in the column definition and custom ###,###,###M.
    But sometimes it can be Kilos and sometimes Billions.
    I don't want to display 0.02M or 200000M.
    How can I define conditional custom according to the current value?

    Try doing what I said here and see if it works for you...
    Re: Represent numbers in thousands

  • Insert value into a column based on value of another column

    Hi,
    I am trying to insert a value into a record based on a column in
    the record, using a trigger. The complication arises because
    the new value is selected from the same table. For example:
    SELECT COL1, COL2, COL3, COL4 from TABLE1
    I want to set COL2 and COL3 based on the value of COL4. And to
    get the value of COL2 and COL3, I will go back to TABLE1 and set
    the condition to TABLE1.COL1 = :NEW.COL4
    I cannot seem to execute the trigger as I get the message "ORA-
    04091: table SYSTEM.TABLE1 is mutating, trigger/function may not
    see it" everytime.
    Is this the correct way to achieve what I wanted? Or is there
    another way?
    Appreciate your feedback. Thank you in advance.

    Hi,
    I am trying to insert a value into a record based on a column in
    the record, using a trigger. The complication arises because
    the new value is selected from the same table. For example:
    SELECT COL1, COL2, COL3, COL4 from TABLE1
    I want to set COL2 and COL3 based on the value of COL4. And to
    get the value of COL2 and COL3, I will go back to TABLE1 and set
    the condition to TABLE1.COL1 = :NEW.COL4
    I cannot seem to execute the trigger as I get the message "ORA-
    04091: table SYSTEM.TABLE1 is mutating, trigger/function may not
    see it" everytime.
    Is this the correct way to achieve what I wanted? Or is there
    another way?
    Appreciate your feedback. Thank you in advance. I'm not sure what you mean when you insert a value into a
    record, but if you are setting a value in a column of the same
    record using a trigger, then it's easy.
    :new.COL2 := ....:new.COL4...
    :new.COL3 := ....:new.COL4...
    The trigger must be 'INSERT or UPDATE' and 'FOR EACH RECORD'.
    If you are setting a different record in the same table, the
    solution is much more difficult.

  • Count MySQL rows based off Value in Dynamic Table

    Greetings all. I have 2 MySQL tables; 1 that contains the names of my classes.(Class A, Class, B, etc.) and 1 table that contains the names of students in each Class (for example Class A: John Doe; Class A: Susie Smith.; Class B: Jane Doe). In the 2nd table the Class name is in its own column and the student's name is in a 2nd column.
    I currently have a dynamic repeating table that lists the names of all of the classes from the 1st table. What I'm trying to do is add a second column to this repeating dynamic table that lists the number of students in each class. For example; Row 1 of the dynamic table would say "Class A | 5; Class B | 3; Class C | 7, etc.). The dynamic table works perfectly to list the class names. For the life of me I can't figure out how to perform a count for each class to insert in the repeating table. I will be adding more Classes which as why I'm trying to set up the counting query dynamically. So far I have only been able to figure out how to count the total rows in the 2nd table, or count the rows with a specified class name. Any advice or guidance on how to count the number of rows in the 2nd MySQL table based off the class name in the repeating table is much appreciated. Thank you for any and all help. Have a great day.

    Select count(*), Class from MyTable
    Group by Class
    Time to learn about SQL:
    http://www.w3schools.com/sql/sql_intro.asp

  • Dynamic Link Column Based on Value

    I'm using Apex version 4.1.
    This is driving me nuts, I can't get it to work. I'm trying to create a dynamic link on a column (in a SQL report) based on the value. Here's my query:
    SELECT STRUCTURE_ENTITY_ID AS "Market ID",
    Structure_entity as "Market Name",
    CASE WHEN NVL2((select 'A' from PC_PAYROLL_DISTRIBUTION PD
    WHERE PROCESSING_YEAR = SUBSTR('2011-08',1,4)
    AND PROCESSING_MONTH = TO_NUMBER(SUBSTR('2011-08',6,2))
    AND PD.OPS_MARKET = SE.STRUCTURE_ENTITY_ID
    AND ROWNUM = 1),'Ready','Not Ready') = 'Ready' THEN '' ||'' ELSE 'Not Ready' END AS Status
    FROM STRUCTURE_ENTITY SE
    So when the value in that CASE statement equals 'Ready' then I need it to show the word Ready (in the Status column) as a hyperlink, otherwise it needs to show 'Not Ready' in normal text that's not clickable.
    The URL string I have in there DOES pick up the correct values for my parameters, but it stilll appears in the report as the whole string, and it's not clickable. Any help would be greatly appreciated!
    Thanks,
    Greg

    I see an a instead of <a and no </a> in this code.
    Oh, I guess your {a is <a ... B-)  Still no end tag, though.
    Edited by: InoL on Oct 7, 2011 2:27 PM                                                                                                                                                                                                                                                                                                                       

  • Filter column based on values in second column

    I have a 7 columns (A-G). I want to add a filter to return rows if the value in column D exists anywhere in column C (values in column D and C do not necessarily match).
    Is this possible? I tried creating a filter for column D based on column C using the 'Filter based on results of another request' functionality, but it did not work.
    Create/Edit Filter>Filter based on results of another request
    Column: column D
    Relationship: is equal to any
    Saved Request: same request
    Use values in Column: column C

    Okay, it looks like you are using the same query for both the main and subquery. That won't work.
    1) Create a query with one column, column D. Name it and save it.
    2) Now build your main report with all the columns you desire and on column C, apply the filter "based on results..." and have it point to column D of the subquery in step 1.

  • Color a column based on value in another column in tableview

    I am using a tableview iterator to display data in a bsp page. I want to color a cell in particular column (column 4), when a value in another column (column 2) on that same row is greater than 20. I can color the cell in column 2 but am not able to color the cell in column 4. How can I accomplish this?
    This is what I have. Looks like val1 is losing it's value.
    CASE p_column_index.
        WHEN 2.
          ASSIGN p_row_data_ref->* TO <row>.
          ASSIGN COMPONENT 'ZTGT' OF STRUCTURE <row> TO <col>.
          VAL = <col>.
          IF VAL GT '20'.
            val1 = p_row_index.
            p_style = 'celldesign:CRITICALVALUE_DARK'.
          ENDIF.
        WHEN 4.
            if p_row_index = val1.
              p_style = 'celldesign:CRITICALVALUE_DARK'.
            endif.
        WHEN OTHERS.
    do nothing
      ENDCASE.

    The reason val1 is "loosing its' value" is presumably because you have defined it in the method as a local variable. So each time you call the RENDER_CELL_START method it is is newly initialised. So if you make this an instance attribute it will retain its' contents across method calls.
    Cheers
    Graham Robbo

  • Sort column based on value

    Hi All,
    Query result gives ou put like in the following order
    CITY NAME
    CHENNI
    DELHI
    LONDON
    RIO DEGENERO
    How to get output in the following sort order
    LONDON
    CHENNAI
    DELHI
    RIO DEGENERO
    i dont want to hardcode the column values ..it will be great if i get option to genrate dynamically.
    Thanks!

    Hi,
    user601042 wrote:
    Hi All,
    Query result gives ou put like in the following order
    CITY NAME
    CHENNI
    DELHI
    LONDON
    RIO DEGENERO
    How to get output in the following sort order
    LONDON
    CHENNAI
    DELHI
    RIO DEGENERO
    i dont want to hardcode the column values ..it will be great if i get option to genrate dynamically.If the sort order isn't hard-coded, how do you get it?
    If you call a function to get the sort order, then just call the function in the ORDER BY clause:
    ORDER BY  sort_key (city_name)If the sort order is in a table, join to that table, so you can use the appropriate column
    FROM     table_x  x
    JOIN      cities   c  ON  c.city_name = x.city_name
    ORDER BY  c.sort_key
    user601042 wrote:... i want to display the following order in screen
    3 LONDON
    1 CHENNI
    2 DELHI
    4 RIO DEGENEROThe question is, how do you determine that order? I don't see anything obvious in the data itself.
    If you were sorting by the id, either ascending or descending, then 1 wouldn't come between 3 and 2.
    If you were sorting by alphabetic order, either ascending or descending, then 'CHENNI' wouldn't come between 'LONDON' and 'DELHI'.
    If you were sorting by the length of the name, either ascending or descending, then 'DELHI' (5 characters) wouldn't come between 'CHENNI' (6 CHARACTERS) and 'RIO DEGENERO' (12 characters).
    By what are you sorting? If you can explain it in English, then someone can help you code it in SQL.
    Edited by: Frank Kulash on Oct 17, 2012 2:40 PM

  • Update column based on values of same table

    I have table T1 with 4 columns 'col1','col2','col3','col4', 'col5','col6' as follows
    Col1     Col2     Col3     Col4     Col5     Col6
    1111     City1     C     AA     DDD     A1
    2222     City 1          DD     HHH     A1
    3333     City2     B     EE     OOO     
    4444     City 1     B     JJ     SSS     A1
    5555     City2     C     KK     VVV     
    6666     City2          RR     QQQ     
    7777     City2     B     XX     BBB     
    I have already updated Column 6with value ‘A1’ where Column 2 is ‘City1’.
    Now I want to update col 6 where col2 is ‘S’ with following conditions
    If Col 3 = ‘B’ then Col6 should be = col4
    else it should be = col5

    SET col6=DECODE(col3,'B',col4,col5)
    WHERE col2='S'

  • Issue in populating values in a column based on values in other columns

    I have a situation as below:
    Src        Tar             New tar
    AC001  TAC001  
    AC002  TAC001      AC002
    AC003  TAC001
    AC011  TAC011
    AC012  TAC011      AC012
    AC021  TCA021
    AC022  TCA021
    Now, wherw I have New target as AC002, I need to copy the same value to TAC001 which is the 1st and 3rd row. Similarly, I need to copy AC012 to 4th record. And my last 2 rows will be null as I do not have any values for TCA021..Any thoughts on this would be apprecated..
    Thanks in advance..

    Hi
    almost all is said so i tip you How to Fish (with Pictures) - wikiHow because it is good asset for future when you are hungry
    Read also http://docs.oracle.com/cd/E11882_01/server.112/e41084/functions004.htm#SQLRF06174
    "Analytic functions compute an aggregate value based on a group of rows. They differ from aggregate functions in that they return multiple rows for each group. The group of rows is called a window and is defined by the analytic_clause. For each row, a sliding window of rows is defined. The window determines the range of rows used to perform the calculations for the current row. Window sizes can be based on either a physical number of rows or a logical interval such as time.
    Analytic functions are the last set of operations performed in a query except for the final ORDER BY clause. All joins and all WHERE, GROUP BY, andHAVING clauses are completed before the analytic functions are processed. Therefore, analytic functions can appear only in the select list or ORDERBY clause.
    Analytic functions are commonly used to compute cumulative, moving, centered, and reporting aggregates."

  • ALV Tree - Color Specific Column based on value in that cell?

    Hi Forums,
    I have searched the forum and I am unable to find the answer to my question.
    I am using an ALV tree and I would like to color a cell RED is the value in the cell is negative.
    I have set my field catalog to many different emphasize numbers and no luck either?
      CLEAR ls_fieldcatalog.
      ls_fieldcatalog-fieldname  = 'ORG_TXT'.
      ls_fieldcatalog-coltext    = text-d02.
      ls_fieldcatalog-scrtext_m  = text-d02.
      ls_fieldcatalog-col_pos    = 2.
      ls_fieldcatalog-outputlen  = '30'.
      ls_fieldcatalog-no_out     = 'X'.
      ls_fieldcatalog-emphasize  = 5.
      APPEND ls_fieldcatalog TO et_fieldcatalog.
    I am using 
        gr_alv_tree_control  TYPE REF TO cl_gui_alv_tree
    as my class to display my tree and I have found no methods that would set the color in there either?
    What else could be checked?

    To those interested, i was able to color the TEXT of a First coloumn of the TREE. Using this code:
    That said it will not work without BOTH
           ls_layout_item-fieldname = gr_alv_tree_control->c_hierarchy_column_name.
          ls_layout_item-style   =
                               cl_gui_column_tree=>style_intensifd_critical.
        IF ls_vip_display-vip_diff_tot > 0.
           ls_layout_item-fieldname = gr_alv_tree_control->c_hierarchy_column_name.
          ls_layout_item-style   =
                               cl_gui_column_tree=>style_intensifd_critical.
        ENDIF.
        IF ls_vip_display-vip_diff > 0.
          ls_layout_item-style   =
                               cl_gui_column_tree=>style_intensifd_critical.
        ENDIF.
        ls_layout_item-t_image = '@GZ@'.
        ls_layout_item-style   =
                            cl_gui_column_tree=>style_intensifd_critical.
        APPEND ls_layout_item TO lt_layout_item.
    *   add leaf nodes
        CALL METHOD gr_alv_tree_control->add_node
          EXPORTING
            i_relat_node_key     = lv_parent_id
            i_relationship       = cl_gui_column_tree=>relat_last_child
            i_node_text          = lv_node_text
            is_outtab_line       = ls_vip_display
            it_item_layout       = lt_layout_item
            is_node_layout       = ls_node_layout
          IMPORTING
            e_new_node_key       = lv_new_key
          EXCEPTIONS
            relat_node_not_found = 1
            node_not_found       = 2
            OTHERS               = 3.
    Anybody else who can shed some light to why both are needed OR possibly how I can change the position of the colored text to a different cell?
    Edited by: Keith Warnock on Feb 9, 2011 6:48 PM

  • Form List: Display only on certain columns based on values

    Hi there,
    Let's say I have a list of condition types. And I want to make some condition types READ ONLY. Is that possible?
    Thanks,
    Josh

    Hello,
    Do you mean that the row you are working on (focus) is read-only ?
    Regards,
    fred

  • Refresh Cell Value Of Column Based On Condition

    Hi Experts,
    I m working on UI5 grid.
    This my grid:
    My requirement is:
    On change of "Actual Value ", if value is in between UL and LL then "Sub Test" column should be refreshed with image(ex.green ! mark)
    Till Now i achieved upto comarision in columns:
    But now i stucked with ,how to refresh image in "Sub Test" column based on valued entered in "Actual Value" column.
    Request your ideas.
    Regards,
    Neha

    You can also use CalcFields to bind to your data if you don't want the Icon column to be part of you model.
    Documentation/AdvancedTopics/DataBinding/CalcFields – SAPUI5 Wiki (TIP CORE User Interface)
    I've modified Dennis' example slightly to use a CalcField, notice the paths are defined to create a composite binding, the data is the automatically passed to the formatter function.
    http://jsbin.com/poren/1/edit
    Regards,
    Jason

  • Create a derived column based on a value within the file name

    I am importing a CSV file which is easy enough, but I have an issue where I need to manufacture a couple of column values based on the filename of the input.  So this same process will import different types of records to the same table in sql server.
     I need to pull out the record code from the file name.  
    For instance, say I can use the same package to input two different CSV files.  One is named Input_M02_Data.csv and one named Input_B15_Data.csv.  I need to create a derrived column and store the record code there (i.e.:  M02 or B15) based
    on which file it came out of.  
    fyi-
    I also need to create a second column for Dept based off of the file name as well.  M02 is dept 45 and B15 is dept 99  which I also need to insert into this table when I import the data from the .csv file.  
    Any help is greatly appreciated!

    Hi Jason,
    According to your description, you want to add two derived columns based on the file name to also insert into table. One stores the value between two “_” within file name, another stores the department based on that column.
    If in this scenario, we can add a variable FileName that stores the filename, then add the two variables as derived columns like below in the Derived Column Transformation:
    Name:
    SUBSTRING(@[User::FileName],FINDSTRING(@[User::FileName],"_",1)+1,FINDSTRING(@[User::FileName],"_",2)-(FINDSTRING(@[User::FileName],"_",1)+1))
    Dept:
    @[User::Name] =="M02"?"dept 45":@[User::Name] =="B15"?"dept 99":"dept 00"
    The following screenshot is for your reference:
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    If you have any feedback on our support, please click
    here.
    Katherine Xiong
    TechNet Community Support

  • Change LOV of column in view, based on values of another LOV of column in the same view

    Hi,
    I am using Jdeveloper 11.1.1.5.
    I have a scenario in which I have two columns in the view. column names are:
    1- Column A
    2- Column B
                        both the columns have LOV's
    LOV in column A contains values as: 1, 2. Now, when I select the value 1 in column A, In the column B, an LOV named ABC should be shown. and when I select value 2 from LOV in column A,  LOV named XYZ should be shown in column B.
    how can I do that?
    thanks in advance (^.^).

    Use onchange attribute of the first drop-down. On change, submit the form. On server side, fetch the values for second drop-down based on the value selected for the first drop-down.

Maybe you are looking for

  • Short dump while extracting data

    Hi, When i extract the data from the datasource 2lis_05_item in rsa3 i m getting the following short dump. Can anyone tell what to do in this case? Runtime Errors         CONNE_IMPORT_WRONG_STRUCTURE Exceptn                CX_SY_IMPORT_MISMATCH_ERROR

  • Setting character encoding in a Writer

    Hi, Is this possible? I'm reading from an InputStream (stream from a text file) using an InputStreamReader wrapped in a BufferedReader. I set the character encoding in the InputStreamReader. Then I read line by line - making some modifications in the

  • Need EJB Help

    Hi, can any one tell me the flow of control from client to bean and then response from bean to client while using 1:1,1:M nad M:M relationship mapping. my second question is if i have a create method with local interface variable as parameter then ho

  • UML Modeling - Reverse Engineering Java Applications

    Hi , I'm trying to download UML tutorial sample.zip from the below link: http://developers.sun.com/prodtech/javatools/jsenterprise/downloads/ea/jse8/learning/tutorials/Sample.zip getting page not found error. http://developers.sun.com/prodtech/javato

  • Interactive command line

    I want to build a program with an interactive command line. The screen should be split in two areas: on top of the screen will be displayed the program itself and in a line on the bottom of screen, should be displayed an interactive command line. Thi