How to get the count of customers

Hi all,
We have a fact table, AR_F to which the dimensions Party_D and Fin_D are connected. Party-org_d is inturn connected to Party_d.
party_org_D contains details of customers like Customer name and customer ID (Number)
Fin_D contains ratings (Both -ve and +ve) of each customer.
the rating range is as follows,
good rating : >0
OK Rating: Between 0 and -1.5
Bad Rating: <-1.5
Now i need to get the count of all customers falling in each range as separate measures.
Kindly help me get a solution for this.
Thank you.

Hi,
Try this....
col 1
case when Fin_D.ratings > 0 then 'Good'
when Fin_D.ratings >= -1.5 and Fin_D.ratings <= 0 then 'Ok'
when Fin_D.ratings < -1.5 then 'Bad' end
col 2
case when (case when Fin_D.ratings > 0 then 'Good'
when Fin_D.ratings >= -1.5 and Fin_D.ratings <= 0 then 'Ok'
when Fin_D.ratings < -1.5 then 'Bad' end)='Good' then count(customer_id)
when (case when Fin_D.ratings > 0 then 'Good'
when Fin_D.ratings >= -1.5 and Fin_D.ratings <= 0 then 'Ok'
when Fin_D.ratings < -1.5 then 'Bad' end)='Ok' then count(customer_id)
when (case when Fin_D.ratings > 0 then 'Good'
when Fin_D.ratings >= -1.5 and Fin_D.ratings <= 0 then 'Ok'
when Fin_D.ratings < -1.5 then 'Bad' end)='Bad' then count(customer_id)
end
hope helps........

Similar Messages

  • How to get the count of repeating elements in a xml doc.

    In many xml documents, in is common to have repeating child elements and what I would like to know is how do I determine exactly how many of these child elements exist in a particular document. There is probably a correct XPath string to determine this, but I cannot figure out what it is. Here is an example
    <a>
    <b>
    <c>1</c>
    <c>5</c>
    <c>22</c>
    </b>
    </a>
    The above 'c' element is what varies in number from document to document and I need to know how to get the number of 'c' elements for the document, which would be 3 in the above case.

    create table test_xml(data xmltype)
    insert into test_xml values(
    xmltype('<a>
    <b>
    <c>1</c>
    <c>5</c>
    <c>22</c>
    </b>
    </a>')
    select extract(data, '/a/b/c').getclobval() from test_xml
    select count(*) from test_xml
    where existsnode(data, '/a/b/c')=1
    good luck.

  • Select Count(*) from Sample_table - how to get the count using JDBC?

    Hi All,
    It would be glad if anyone could help me with this. The problem is that I have to get the 'count' of records selected from a arbitrary table say, 'sample_table'. Is that possible to form the SQL in JDBC as
    Select Count(*) from Sample_table
    and get the value of the count? If yes, how?
    Thanks in advance
    Prabz

    stmt = con.createStatement();
    ResultSet recordcnt_rs = stmt.executeQuery("Select Count (*) as record_ctr From Sample_table");
    recordcnt_rs.next();     
    record_ctr = recordcnt_rs.getInt("record_ctr");
    hope this helps.

  • How to get the count of each minutes

    Oracle 10 DB
    Hi All
    I using this query to get the count of records fetched by the concurrent program per min,
    select count (distinct b.attribute2)
    from oe_order_headers_all a,oe_order_lines_all b
    where a.header_id=b.header_id
    and b.flow_status_code ='AWAIT_QUINTIQ_BOOK'
    and to_Char(b.last_update_date,'DD-MON-YYYY HH24:MI:SS') between '19-JAN-2011 02:00:01' AND
    '19-JAN-2011 02:00:02'
    This is used to get the count of records fetched at one mins
    How to find the count of last 10 mins ie 1 mins count 2.00 to 2.10
    Thanks & Regards
    Srikkanth.M

    Try this:
    SELECT TRUNC(b.last_update_date, 'mi') time_mins, COUNT(DISTINCT b.attribute2)
    FROM   oe_order_headers_all a,
           oe_order_lines_all b
    WHERE  a.header_id = b.header_id
    AND    b.flow_status_code = 'AWAIT_QUINTIQ_BOOK'
    AND    b.last_update_date >= to_date('19/01/2011 02:00:00', 'dd/mm/yyyy hh24:mi:ss')
    AND    b.last_update_date < to_date('19/01/2011 02:10:00', 'dd/mm/yyyy hh24:mi:ss')
    GROUP BY TRUNC(b.last_update_date, 'mi');I'm not sure why you're bothering with the join to the oe_order_headers_all table, since you're not referencing that in the where clause or the selected columns list. I think you could probably do away with it.
    I've changed your code to take the last_update_date and truncate it to the minute level, and added that as a column, so you can see which count goes with which minute. Obviously, this has to be in the group by.
    I've also changed your date comparisons so that you're actually comparing dates to dates, rather than strings to strings - why would you deliberately take information away from the optimizer? Oracle does not treat strings the same as dates, and forcing it to use strings rather than dates could lead you to have a vastly differing execution path, which will most likely be less performant.
    Not to mention, coding like that leads you to assume that you can compare dates in strings without any problems, and that is just not the case. '19-FEB-2011' is counted as being earlier than '19-JAN-2008', as strings sort alphabetically.

  • How to get the count of PO'S raised by a user

    Hi,
    I have a new requirement whr i am asked to get the count of number of PO'S raised by a particular user in report. Suppose the user raised 10 purchase orders .
    The requirement is when a user name is given it has to give count of 10.
    Where shud i include this,in rows or columns. Please suggest.
    Thanks&Regards,
    Praveen

    Hi Praveen,
    take a look in www.service.sap.com/bi, under old release, for release 2.x you will find an How to that detail how to count occurencies of a Char. Maybe you will find here the solution.
    Ciao.
    Riccardo.

  • How to get the Count of a logic?

    Hi,
    Very new to CRM. I am trying to get the count of "activity start time" that are greater than current time stamp. Count(activity start time) work. I don't know how to add the time stamp condition to this. I can't add this condition as filter.
    Appreciate any responses.
    Thanks

    Raghu,
    Thanks for the help. It works to get the count.
    The problem is, i have some other filters set and can't combine this filter. Here is my scenario:
    get all activities on a contact that have greater than x $ amount as assets. I need to find the number of future appointments for that contact and start time of first pending future appointment. All has to be in one report.
    My columns are for example : contact name, activity start time, end time, subject, next pending appointment start time, total future appointments, some other related fields from contact
    So when I add the filter that you had given, it will not give me all activities. I am able to achieve all this in seperate reports and unnable to get it in single one.
    Thanks,
    GiGi

  • How to get the count of distinct customer in matrix?

    Hi,
    I want to get the count of distinct customer in matrix at the time of validation event.
    Thanks Regards,

    Hi,
    Please close the thread.by marking the correct answer
    regards,
    Prasad

  • How to get the count of all the entries in the DB?

    I want to know the way getting the count of the entries in a DB. Not using cursor to visit all entries and record the count.
    Message was edited by:
    user633842

    Hello,
    Yes, depending on the type of database you are using, the
    following statistics from DB->stat, look like what you want.
    For Hash databases:
    hash_ndata;
    The number of key/data pairs in the database. I
    For Btree databases:
    bt_ndata;
    For the Btree Access Method, the number of key/data pairs
    in the database.
    For the Recno Access Method, the number of records in
    the database.
    For Queue databases:
    qs_ndata;
    The number of records in the database.
    Additional details are at:
    http://www.oracle.com/technology/documentation/berkeley-db/db/api_c/db_stat.html
    Thanks,
    Sandra

  • How to get the count monthly wise

    Hi All
    I have lot of order dispatched in a year 2010, how to get the moth wise total.
    For example jan 1000 orders ,feb 2500 orders.
    Thanks & Regards
    Srikkanth.M

    Pleiadian wrote:
    Maybe even
    b.schedule_ship_date between to_date('2010','YYYY') and to_date('2011','YYYY');)But this could return schedule ship dates that are 01-Jan-2011 00:00:00. I don't think this is wanted since it was not specified in the original requirement. I'm not even sure if to_date('2010','YYYY') returns 01. Feb.2010 in a few days (when we will have february).
    Just checking the docs....
    found it: http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/sql_elements003.htm#SQLRF51062
    from the docs:
    If you specify a date value without a time component, then the default time is midnight (00:00:00 or 12:00:00 for 24-hour and 12-hour clock time, respectively). If you specify a date value without a date, then the default date is the first day of the current month.Just to be on the safe side always give the complete format mask!
    b.schedule_ship_date >= to_date('01012010','DDMMYYYY')
    and b.schedule_ship_date < to_date('01012011','DDMMYYYY')Edited by: Sven W. on Jan 17, 2011 5:14 PM

  • How to get the count of the records

    Hi all,
    how can we get the record count after the read statement.Means if we write a read statement based on a condition,then how can we know that how many records get effected for this read statement

    You can use loop statement to read the records and write in some internal table and after the end of the loop, you can use describe command to find the number of records.
    For eg. DESCRIBE TABLE tablename LINES lines.
    Here the "Lines" field will give the total number of records present in the table "tablename"

  • How to get the count property from the oData response

    Hi,
    I have a fullscreen view in my Fiori app where we call a oData service through table.bindItems() inside the controller.
    The binding of items works fine but we have a situation when we need to display the total number of items (for e.g. 515) on the UI. We do not get this information from the VDM, so we plan to use the length property of the getList() method to determine the total number of items. But because of growing feature of the table it only reads 100 items at a time and the length property returns only 100. I have attached the listener attachRequestCompleted() for the model so that once the bindItems() request is complete i can get the length property. But my problem is that i want the total count.
    I saw in the debug that when this table.bindItems() gets called it makes a oData service call and in the response i can see that there is a count property available which has the total number of items (515 for my e.g.) but how do i read this count property from the response inside my controller (probably inside my attachRequestCompleted)?? I would really appreciate any help in this regard. Thanks.
    Kind Regards,
    Ashish
    Tags edited by: Michael Appleby

    HI Chandra,
    Thanks for your suggestions.
    But i think in my case we do not want to get the complete list. We still want to get only 100 items initially and then if the user would scroll down he/she would see more items. But we already need to know the total number of items for the purpose of showing a message to the user. For e.g. Total issues (515),  but the table would initially show only 100 and then another 100 after scroll. So setting the size litmit to max would not help.
    And to be able to use the $count you mentioned, we have to still make another oData service call which we do not want.
    But as i mentioned there is already a property named "__count" in the response of the bindItems() method call and i see that it has correct count but not sure how to retrieve it inside the controller. Thanks.
    Regards,
    Ashish

  • How to get the count of items(folders or documents) in a SharePoint document library and for a folder in any SharePoint document library?

    I need to get a count of documents and folders in a selected document library(the item for EventRecievers for event deleting) and the count of documents in a selected folder(the item for EventRecievers for event deleting) to determine whether the item(document
    library or folder) is empty or not, as I need to use this condition for one of my custom EventReceivers.
    Can you please suggest me the code to do the same?

    Hi.
    Try this:
    class Program
    static void Main(string[] args)
    using (SPSite site = new SPSite("http://z2012net"))
    using (SPWeb web = site.OpenWeb())
    SPList l = web.Lists["List001"];
    List<FolderInfo> res = new List<FolderInfo>();
    getListCount(l.RootFolder, ref res);
    private static void getListCount(SPFolder sPFolder, ref List<FolderInfo> res)
    SPQuery query = new SPQuery();
    query.Folder = sPFolder;
    res.Add(new FolderInfo() { ItemCount = sPFolder.ItemCount, Name = sPFolder.Name, Url = sPFolder.Url });
    SPListItemCollection items = sPFolder.ParentWeb.Lists[sPFolder.ParentListId].GetItems(query);
    foreach (SPListItem item in items)
    if (item.FileSystemObjectType == SPFileSystemObjectType.Folder)
    SPFolder f = sPFolder.ParentWeb.GetFolder(item.UniqueId);
    getListCount(f, ref res);
    class FolderInfo
    public string Url { get; set; }
    public string Name { get; set; }
    public int ItemCount { get; set; }
    Regards,
    Bubu
    http://zsvipullo.blogspot.it
    Please mark my answer if it helped you, I would greatly appreciate it.

  • How to get the Count for no.of.errors

    HI
    BELOW IS MY CODE
    LOOP AT I_RETURN INTO WA_RETURN.
      IF WA_RETURN-TYPE ='E'.
        CONCATENATE SOURCE-AUFNR '|' SOURCE-VORNR '|'WA_RETURN-MESSAGE
                                                         INTO TEXT.
        WRITE:/ TEXT.
        COUNTER = COUNTER + 1.
      ENDIF.
    IM GETTING BELOW O/P
    000090001366 0020 Enter another operation number
    000090001366 0020 Error  during processing of BAPI methods
    000090001366 0050 Item categories in agreement and requisition incompatible
    000090001366 0050 Error  during processing of BAPI methods
    NO.Of records In Error          4
    My Requirement is if AUFNR and VORNR value is same then the count should be 1 , Like the o/p should be
    NO.Of records In Error          2
    because AUFNR and VORNR is same for 2 records , can any one tel me the logic to do this,
    AUFNR and VORNR value is there in Internal Table

    Hi All,
    Thanks for the replies.
    AUFNR and VORNR are in different tables so im putting them in one internal table
    loop at itab into wtab.
        wtab-aufnr = wa_methods-objectkey.
        wtab-vornr = wa_operation-activity.
    endloop.
    now
    IF WA_RETURN-TYPE ='E'.
    now if aufnr and VORNR is same then i should get error message as said above
    can any one tel me the logic

  • How to get the count of the entries in the table view

    Hello experts,
             I have got a requirement where i need to display the total number of entries present in the table view, since the result comprises of several pages. This requirement is even applicable for the filter options in the table view i.e., if i use a filter it should count the total number of entries that satisfy the filter criteria.
    Thanks in advance,
    Vijayalakshmi

    hi,
    its simple,just place an input field in the layout and display the cpunt in that field.
    for that do as below,
    first in the layout of the page where you are giving tableview tab,in the next line give
    <b><htmlb:inputField id="Count"
                      value="<%=ln%>"
                      disabled = 'X'/></b>
    to display the count in that input field which is disabled.
    and if i am mot wrong in the Initialization event, you are writing select query right to populate internal table.
    after that write,
    <b>describe table it_mara lines ln.</b>
    and define this ln in page attributes as type i.
    do award points f it helps u,
    regards,
    Message was edited by:
            sowjanya s

  • How to get the count for every 30 mins

    Hi,
    Following is the table format:
    Time ******************** logged in users
    9/5/2006 8:38:22 PM**** 2
    9/5/2006 8:38:44 PM**** 4
    9/5/2006 8:40:22 PM**** 1
    9/5/2006 8:41:22 PM**** 3
    9/5/2006 8:52:22 PM**** 6
    9/5/2006 9:02:22 PM**** 5
    9/5/2006 9:04:24 PM**** 3
    9/5/2006 9:08:26 PM**** 4
    9/5/2006 9:10:28 PM**** 6
    What I need is number of users logged in for every 30 min
    like 9/5/2006 9:00:00(8:30 to 9:00) is 16
    9/5/2006 9:30:00(9:00 to 9:30) is 18
    Can any one help me in this regard?
    -Raj

    The trick is to group your times to every 30 min.
    Unfortunatly there is no way to TRUNC(30 min).
    But you can build this function yourself using some mathematical logic and trunc to build the groups.
    Look at this code piece:
    select trunc(sysdate) + trunc((sysdate - trunc(sysdate))*24*2)/24/2
    from dualInstead of sysdate use your date column and group by the expression.
    Added example using Dave's test data
    WITH t AS
            SELECT TO_DATE ('9/5/2006 8:38:22 PM', 'fmdd/mm/yyyy hh:mi:ss pm') tm,
                   2 num
              FROM DUAL
            UNION
            SELECT TO_DATE ('9/5/2006 8:38:44 PM', 'fmdd/mm/yyyy hh:mi:ss pm') tm,
                   4 num
              FROM DUAL
            UNION
            SELECT TO_DATE ('9/5/2006 8:40:22 PM', 'fmdd/mm/yyyy hh:mi:ss pm') tm,
                   1 num
              FROM DUAL
            UNION
            SELECT TO_DATE ('9/5/2006 8:41:22 PM', 'fmdd/mm/yyyy hh:mi:ss pm') tm,
                   3 num
              FROM DUAL
            UNION
            SELECT TO_DATE ('9/5/2006 8:52:22 PM', 'fmdd/mm/yyyy hh:mi:ss pm') tm,
                   6 num
              FROM DUAL
            UNION
            SELECT TO_DATE ('9/5/2006 9:02:22 PM', 'fmdd/mm/yyyy hh:mi:ss pm') tm,
                   5 num
              FROM DUAL
            UNION
            SELECT TO_DATE ('9/5/2006 9:04:24 PM', 'fmdd/mm/yyyy hh:mi:ss pm') tm,
                   3 num
              FROM DUAL
            UNION
            SELECT TO_DATE ('9/5/2006 9:08:26 PM', 'fmdd/mm/yyyy hh:mi:ss pm') tm,
                   4 num
              FROM DUAL
            UNION
            SELECT TO_DATE ('9/5/2006 9:10:28 PM', 'fmdd/mm/yyyy hh:mi:ss pm') tm,
                   6 num
              FROM DUAL)
    SELECT   SUM (num), trunc(tm) + trunc((tm - trunc(tm))*24*2)/24/2 halfhours
        FROM t
    GROUP BY trunc(tm) + trunc((tm - trunc(tm))*24*2)/24/2;
    Row#     SUM(NUM)     HALFHOURS
    1     16     09.05.2006 20:30:00
    2     18     09.05.2006 21:00:00Message was edited by:
    Sven Weller

Maybe you are looking for