Count with date rollover

I was wondering how this can be achieved:
I need to do a count of applications by application_type where the "application_recieved_date" >= JAN-2010.
The only issue is that not all applications have a "application_recieved_date", soem are NULL. So i need some sort of rollover date, if this doesnt exist then use another date on the application (application_recieved_date for example), then if this doesnt exist then use another date.
Any help would be great, i have trying decodes and nvl2 functions, but nothing yet.
below is basic query just so you can see names e.t.c, but i really cannot workout the best way of solving this
select application_type, count(*)                   
            from pple_t_application
           group by application_type
           order by application_type;

Hi,
Use COALESCE:
COALESCE (dt1, dt2, dt3, dt4)COALESCE takes 2 or more arguments of the same datatype, and returns the first argument that is not NULL.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and the results you want from that data.
Explain how you get those results from that data.
Always say what version of Oracle you're using.

Similar Messages

  • How to use Count with Date Parameters

    Hello,
    I am having issues using the Count() function in conjunction with date parameters.
    This is a Siebel report and in my report I have 2 date parameters(From Date, To Date). In a nutshell I am basically trying to count Opportunities that has a start date within the given date period. However I don't see a reasonable way to put my date parameters within the Count() function. The reason being is that I need to have a huge chunk of code to convert the dates into a common format that can be compared, and it won't even fit within the code block in my rtf template. I am not even sure how to put multiple conditional statements inside a Count() function since all the examples I have seen are very simple.
    Anyone have a suggestion on how to use Count() with date parameters?
    Thanks.

    Any chance you can get the date formats in the correct format from siebel?
    I don't know Siebel - so I can't help you with that. If you get the correct format it is just
    <?count(row[(FromDate>=date) and  (date<=ToDate))?>
    Otherwise the approach would probably need to use string function to get year/monthd/day from the date
    and store it into a varialbe and compare later the same way
    <?variable@incontext:from; ....?>
    <?variable@incontext:to; ...?>
    <?count(row[($from>=date) and  (date<=$to))?>
    Potentially you can use the date functions such as xdofx:to_date to do the conversion
    [http://download.oracle.com/docs/cd/E12844_01/doc/bip.1013/e12187/T421739T481158.htm]
    But I am not sure if they are available in your siebel implementation.
    Hope that helps

  • Who worked with ICS' Model 4896 GPIB? I can not count the data from the module. Can prompt as it to make. It is desirable with examples (data read-out from the module and data transmission between channels. It is in advance grateful.

    I can not count the data from the module. Can prompt as it to make. It is desirable with examples (data read-out from the module and data transmission between channels. It is in advance grateful.

    Hello. Most of the engineers in developer exchange are more familiar
    with NI products. Contacting ICS for technical support is a better
    course of action.

  • File Count with selected date range

    Hi,
    Our requirement is to get the file count with selected date by the user from two sharepoint date time controls i.e. dtp1 and dtp2 into the data table. I am able to get the file count of specific folder from Pages library through below code. Now need to get
    the selected date range from two date time picker controls and check with the item created by is within the date range. If yes I need to get the file count.
    So please share your ideas/thoughts to do the same.
    SPList list =
    wikiweb.Lists["Pages"];
                        SPFolderCollection oFolders
    = list.RootFolder.SubFolders["foldername"].SubFolders;
                        DataTable dt
    = new DataTable();
                        dt.Columns.Add("Column1");
                        DataRow dr;
                        if (oFolders.Count
    > 0)
                            foreach (SPFolder oFolder in oFolders)
     if (!oFolder.Name.Equals("Forms"))
                                    dr
    = dt.NewRow(); 
    dr["Column1"] = oFolder.ItemCount.ToString();
    dt.Rows.Add(dr);
    Regards,
    Sudheer
    Thanks & Regards, Sudheer

    Hi,
    I have modified the code as below
    if((DateTime)(oFolder.Item.File.TimeCreated>dtFromDate.SelectedDate)&&(DateTime)(oFolder.Item.File.TimeCreated<dtToDate.SelectedDate))
    But still it is throwing the error.
    Please share your ideas on the same.
    Regards,
    Sudheer
    Thanks & Regards, Sudheer

  • Count(*) with group by max(date)

    SQL> select xdesc,xcust,xdate from coba1 order by xdesc,xcust,xdate;
    XDESC XCUST XDATE
    RUB-A 11026 01-JAN-06
    RUB-A 11026 05-JAN-06
    RUB-A 11026 08-JAN-06
    RUB-A 11027 10-JAN-06
    RUB-B 11026 02-JAN-06
    RUB-B 11026 08-JAN-06
    RUB-B 11026 09-JAN-06
    RUB-C 11027 08-JAN-06
    I want to make sql that result :
    XDESC     COUNT(*)
    RUB-A     2
    RUB-B 1
    RUB-C 1
    Criteria : GROUPING: XDESC XCUST AND MAX(DATE)
    bellow mark *** that was selected in count.
    XDESC XCUST XDATE
    RUB-A 11026 01-JAN-06
    RUB-A 11026 05-JAN-06
    RUB-A 11026 08-JAN-06 ***
    RUB-A 11027 10-JAN-06 ***
    ---------------------------------------------------------COUNT RUB-A = 2
    RUB-B 11026 02-JAN-06
    RUB-B 11026 08-JAN-06
    RUB-B 11026 09-JAN-06 ***
    ---------------------------------------------------------COUNT RUB-B = 1
    RUB-C 11027 08-JAN-06 ***
    --------------------------------------------------------COUNT RUB-C = 1
    Can Anybody help ?
    I tried :
    select xdesc,max(xdate),count(max(xdate)) from coba1 group by xdesc
    ERROR at line 1:
    ORA-00937: not a single-group group function
    Thank

    This one is duplicate. see the following link
    Count(*) with group by max(date)
    Thanks

  • What is HEAD COUNT with regards to HR Data

    Hi Experts
    Can you please define HEAD COUNT with regards to the HR Data.
    Is it a Count of Employees
    Please update me thanks

    HI
    In HR, the head count term refers to no of employees only...there are some standard reports available for analysing the head count for an org.
    Hope it helps
    Darshan

  • Performance with dates in the where clause

    Performance with dates in the where clause
    CREATE TABLE TEST_DATA
    FNUMBER NUMBER,
    FSTRING VARCHAR2(4000 BYTE),
    FDATE DATE
    create index t_indx on test_data(fdata);
    query 1: select count(*) from TEST_DATA where trunc(fdate) = trunc(sysdate);
    query 2: select count(*) from TEST_DATA where fdate between trunc(sysdate) and trunc(SYSDATE) + .99999;
    query 3: select count(*) from TEST_DATA where fdate between to_date('21-APR-10', 'dd-MON-yy') and to_date('21-APR-10 23:59:59', 'DD-MON-YY hh24:mi:ss');
    My questions:
    1) Why isn't the index t_indx used in Execution plan 1?
    2) From the execution plan, I see that query 2 & 3 is better than query 1. I do not see any difference between execution plan 2 & 3. Which one is better?
    3) I read somewhere - "Always check the Access Predicates and Filter Predicates of Explain Plan carefully to determine which columns are contributing to a Range Scan and which columns are merely filtering the returned rows. Be sceptical if the same clause is shown in both."
    Is that true for Execution plan 2 & 3?
    3) Could some one explain what the filter & access predicate mean here?
    Thanks in advance.
    Execution Plan 1:
    SQL> select count(*) from TEST_DATA where trunc(fdate) = trunc(sysdate);
    COUNT(*)
    283
    Execution Plan
    Plan hash value: 1486387033
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 9 | 517 (20)| 00:00:07 |
    | 1 | SORT AGGREGATE | | 1 | 9 | | |
    |* 2 | TABLE ACCESS FULL| TEST_DATA | 341 | 3069 | 517 (20)| 00:00:07 |
    Predicate Information (identified by operation id):
    2 - filter(TRUNC(INTERNAL_FUNCTION("FDATE"))=TRUNC(SYSDATE@!))
    Note
    - dynamic sampling used for this statement
    Statistics
    4 recursive calls
    0 db block gets
    1610 consistent gets
    0 physical reads
    0 redo size
    412 bytes sent via SQL*Net to client
    380 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    1 rows processed
    Execution Plan 2:
    SQL> select count(*) from TEST_DATA where fdate between trunc(sysdate) and trunc(SYSDATE) + .99999;
    COUNT(*)
    283
    Execution Plan
    Plan hash value: 1687886199
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 9 | 3 (0)| 00:00:01 |
    | 1 | SORT AGGREGATE | | 1 | 9 | | |
    |* 2 | FILTER | | | | | |
    |* 3 | INDEX RANGE SCAN| T_INDX | 283 | 2547 | 3 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    2 - filter(TRUNC(SYSDATE@!)<=TRUNC(SYSDATE@!)+.9999884259259259259259
    259259259259259259)
    3 - access("FDATE">=TRUNC(SYSDATE@!) AND
    "FDATE"<=TRUNC(SYSDATE@!)+.999988425925925925925925925925925925925
    9)
    Note
    - dynamic sampling used for this statement
    Statistics
    7 recursive calls
    0 db block gets
    76 consistent gets
    0 physical reads
    0 redo size
    412 bytes sent via SQL*Net to client
    380 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    1 rows
    Execution Plan 3:
    SQL> select count(*) from TEST_DATA where fdate between to_date('21-APR-10', 'dd-MON-yy') and to_dat
    e('21-APR-10 23:59:59', 'DD-MON-YY hh24:mi:ss');
    COUNT(*)
    283
    Execution Plan
    Plan hash value: 1687886199
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 9 | 3 (0)| 00:00:01 |
    | 1 | SORT AGGREGATE | | 1 | 9 | | |
    |* 2 | FILTER | | | | | |
    |* 3 | INDEX RANGE SCAN| T_INDX | 283 | 2547 | 3 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    2 - filter(TO_DATE('21-APR-10','dd-MON-yy')<=TO_DATE('21-APR-10
    23:59:59','DD-MON-YY hh24:mi:ss'))
    3 - access("FDATE">=TO_DATE('21-APR-10','dd-MON-yy') AND
    "FDATE"<=TO_DATE('21-APR-10 23:59:59','DD-MON-YY hh24:mi:ss'))
    Note
    - dynamic sampling used for this statement
    Statistics
    7 recursive calls
    0 db block gets
    76 consistent gets
    0 physical reads
    0 redo size
    412 bytes sent via SQL*Net to client
    380 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    1 rows processed

    Hi,
    user10541890 wrote:
    Performance with dates in the where clause
    CREATE TABLE TEST_DATA
    FNUMBER NUMBER,
    FSTRING VARCHAR2(4000 BYTE),
    FDATE DATE
    create index t_indx on test_data(fdata);Did you mean fdat<b>e</b> (ending in e)?
    Be careful; post the code you're actually running.
    query 1: select count(*) from TEST_DATA where trunc(fdate) = trunc(sysdate);
    query 2: select count(*) from TEST_DATA where fdate between trunc(sysdate) and trunc(SYSDATE) + .99999;
    query 3: select count(*) from TEST_DATA where fdate between to_date('21-APR-10', 'dd-MON-yy') and to_date('21-APR-10 23:59:59', 'DD-MON-YY hh24:mi:ss');
    My questions:
    1) Why isn't the index t_indx used in Execution plan 1?To use an index, the indexed column must stand alone as one of the operands. If you had a function-based index on TRUNC (fdate), then it might be used in Query 1, because the left operand of = is TRUNC (fdate).
    2) From the execution plan, I see that query 2 & 3 is better than query 1. I do not see any difference between execution plan 2 & 3. Which one is better?That depends on what you mean by "better".
    If "better" means faster, you've already shown that one is about as good as the other.
    Queries 2 and 3 are doing different things. Assuming the table stays the same, Query 2 may give different results every day, but the results of Query 3 will never change.
    For clarity, I prefer:
    WHERE     fdate >= TRUNC (SYSDATE)
    AND     fdate <  TRUNC (SYSDATE) + 1(or replace SYSDATE with a TO_DATE expression, depending on the requirements).
    3) I read somewhere - "Always check the Access Predicates and Filter Predicates of Explain Plan carefully to determine which columns are contributing to a Range Scan and which columns are merely filtering the returned rows. Be sceptical if the same clause is shown in both."
    Is that true for Execution plan 2 & 3?
    3) Could some one explain what the filter & access predicate mean here?Sorry, I can't.

  • Got a new Mac, my iTunes is whack, (No Play Count or Date Added)

    Hello, everybody. It's been a rough night.
    I currently own a G4 iMac and I just got a brand new Macbook. The Macbook is very nice, it's extremely speedy and I am sure I will grow to love it. We've got just one hurdle to get through together: the organization of my music in iTunes. Now, I've had the iMac for five years, and not long after I got it adding music to it became something of an importance, it was my music player. Over the past five years I've not only added thousands of songs, but meticulously and very specifically organized them into playlists based on the number of spins they have and when they were added. To a lot of people I know this sort of thing isn't a huge deal, but for me this organization became, and I kid you not, a huge, huge part of my life.
    So I get the new Macbook, fire it up and use Migration Assistant, (with the iMac in Target Disk Mode), to move my data over. When it's done I open the iTunes and am greeted with... nothing. Well, okay, all of my music is there, that's nice, (it's what iTunes is for, etc etc), but NONE of my play count or date added information remains. I weep inside.
    Being that this is my first new computer in five years, (a long time!), you might be able to tell that I was hesitant about upgrading. Before getting my Macbook I asked experts at the Apple Store if this method would work, and even received assurance from several people online that everything would be preserved. So, I did my homework, but my Macs and I both apparently failed the test. Here's where we are now:
    1. The iMac, (running Tiger), still has iTunes on it, with all the information, nothing seems to have changed on that end.
    2. The Macbook has a hard drive full of music with no playlist, play count or date added data.
    3. I do own an iPod where I backed up the music before the move. I know that the data information on playlists, play count and date added is on the iPod. I do not dare plug it in to the new machine for fear of the unknown.
    Which brings me here, is there some way, any way of rectifying this? Here is what I would like:
    1. For the Macbook iTunes to look EXACTLY like the iMac's does.
    2. For it to work with both my old iPods without question.
    This has been long, and I fear that some may pass it over as something too much of an banality to be needed help with. But like some collect shoes or hats, I collect music. It's a lovely collection and it's a large part of who I am. I could start all over, but that's sort of like saying the world could start over if it by chance happened to forget how to turn. It would take a lot of effort, and there would be some (more) tears, but I could move on. But I really, really don't want to. I just want things to be the way they were. I'd very much like to have this information present, and I thank you all for your time.

    ADDED:
    Now that I look at it, appears that nothing except for my applications transferred over. My old computer is listed in the Hard Drive, but I can't access any of the folders because I don't have that "level of privileges" or whatever, (odd, considering they're both my computers, do they need to be hooked up for this?). I don't really need for my old applications to be there, (Hello, iWork '06 Demo!), so can I just go and erase them, or am I better just starting all over again?

  • Access Counter with ANSI C

    Hi Folks,
    I am trying to access counter  using ANSI C (python wrapper actually). Now I am able to read number of counts with sets of commands:
    DAQmxCreateTask("", &task);
    DAQmxCreateCICountEdges(task, "Dev1/ctr0", "", DAQmx_Val_Rising, 0, DAQmx_Val_CountUp);
    DAQmxSetCICountEdgesTerm(task, "Dev/ctr0", "Dev1/PFI11");
    DAQmxStartTask(task);
    DAQmxReadCounterScalarU32(task, 10, &data, NULL) 
    This example cumulates all counts since task was started, so I can get all counts from begining of task or from previous call (using internal software buffer).
    But what I want to do is count non-periodical series of 'events'  represented with TTL/NIM pulses. So I want to set up measurement (integration) time for one single shot (let say 1000 ms) and then in loop read number of counts (=events) in this window (i.e. frequency in Hz). I probably need to trigger the 'counting function' in some way, probably something like DAQmxCfgSampClkTiming...
    Can you please show me short, simple piece of code, how to do this?
    Thanks a lot.
    Radek 

    Hi Stefo,
    Thanks for trying to help me.
    I tried to use DAQmxCreateCIPeriodChan and it works fine, but it just not what I was looking for. In our application, we have to read counts from multiple counters (usually 3) in the same time window and the signal is NOT periodic (if it matters). Also it blocks one more counter for each one in the task, so if I need 3 Inputs, the 6601 cards with just 4 counters is not enough. Maybe if it is be possible to share that "gate" counter, I will need just 4 and also it will be maybe possible to count corresponding events in the same time window.
    But I found a solution. This "code" (seems to) do exactly what I need:
    (this is just important part of Python code, but I guess it is very easy to read, so...)
    def cOut0(self, chan, up = 1, down = 0.1, samps = 1e3, num = -1):
        err1 = self.device.DAQmxCreateCOPulseChanTime(self.task, char(chan), char(""), int32(DAQmx_Val_Seconds), int32(DAQmx_Val_Low), float64(0), float64(down), float64(up))
        if num > 0:
            err2 = self.device.DAQmxCfgImplicitTiming(self.task, int32(DAQmx_Val_FiniteSamps), uInt64(num))
        else:
            err2 = self.device.DAQmxCfgImplicitTiming(self.task, int32(DAQmx_Val_ContSamps), uInt64(samps))
    def cOut1(self, chan, freq = 1e3, duty = 0.1, samps = 1e3, num = -1):
        err1 = self.device.DAQmxCreateCOPulseChanFreq(self.task, char(chan), char(""), int32(DAQmx_Val_Hz), int32(DAQmx_Val_Low), float64(0), float64(freq), float64(duty))
        if num > 0:
            err2 = self.device.DAQmxCfgImplicitTiming(self.task, int32(DAQmx_Val_FiniteSamps), uInt64(num))
        else:
            err2 = self.device.DAQmxCfgImplicitTiming(self.task, int32(DAQmx_Val_ContSamps), uInt64(samps))
    def cIn5(self, chan, trig, rate = 1e9, samps = 1e3):
        err1 = self.device.DAQmxCreateCICountEdgesChan(self.task, char(chan), char(""), int32(DAQmx_Val_Rising), uInt32(0), int32(DAQmx_Val_CountUp))
        err2 = self.device.DAQmxSetPauseTrigType(self.task, int32(DAQmx_Val_DigLvl))
        err3 = self.device.DAQmxSetDigLvlPauseTrigSrc(self.task, char(trig))
        err4 = self.device.DAQmxSetDigLvlPauseTrigWhen(self.task, int32(DAQmx_Val_Low))
    def wait(self, tOut = -1):
        tOut = float(tOut)
        err = self.device.DAQmxWaitUntilTaskDone(self.task, float64(tOut))
    def gCts(self, tout = 1.0, buff = False):
        tout = float(tout)
        ret = numpy.zeros(1, dtype=numpy.uint32)
        err = self.device.DAQmxReadCounterScalarU32(self.task, float64(tout), ret.ctypes.data, bool32(0))
        return ret[0]
    And here is terminal output (important part):
    >>> devOS.createTask(taskName = "OS")
    >>> devOS.cOut1(chan = "/Dev1/ctr0", freq = 1e5)
    >>> devOS.startTask()
    >>>
    >>> devOG = pydaq.nidaq()
    >>> devOG.createTask(taskName = "OG")
    >>> devOG.cOut0(chan = "/Dev1/ctr1", up = 1, down = 0.1, num = 1)
    >>>
    >>> devIA = pydaq.nidaq()
    >>> devIA.createTask(taskName = "IA")
    >>> devIA.cIn5(chan = "/Dev1/ctr2", trig = "/Dev1/PFI32")
    >>>
    >>> devIB = pydaq.nidaq()
    >>> devIB.createTask(taskName = "IB")
    >>> devIB.cIn5(chan = "/Dev1/ctr3", trig = "/Dev1/PFI32")
    >>>
    >>> devIC = pydaq.nidaq()
    >>> devIC.createTask(taskName = "IC")
    >>> devIC.cIn5(chan = "/Dev1/ctr4", trig = "/Dev1/PFI32")
    >>>
    >>> import time
    >>> def fce(n):
        T1 = time.time()
        r = []
        for i in xrange(n):
            t1 = time.time()
            devIA.startTask(); devIB.startTask(); devIC.startTask();
            devOG.startTask()
            devOG.wait()
            devOG.stopTask()
            c = [devIA.gCts(), devIB.gCts(), devIC.gCts()]
            devIA.stopTask(); devIB.stopTask(); devIC.stopTask();
            t = time.time() - t1
            r.append(c)
            print "%d: %d %d %d (%d s)" % (i + 1, c[0], c[1], c[2], t)
        T = (time.time() - T1) / float(n)
        print "Total Average Time: %d s" % (T)
        return r
    >>> a = fce(10)
    1: 100000 100000 100000 (1 s)
    2: 100000 100000 100000 (1 s)
    3: 100000 100000 100000 (1 s)
    4: 100000 100000 100000 (1 s)
    5: 100000 100000 100000 (1 s)
    6: 100000 100000 100000 (1 s)
    7: 100000 100000 100000 (1 s)
    8: 100000 100000 100000 (1 s)
    9: 100000 100000 100000 (1 s)
    10: 100000 100000 100000 (1 s)
    Total Average Time: 1 s
    So conclusion:
    1) I know I can put all Input Tasks together to only one task, but when I try to read the counts with DAQmxReadCounterU32 function, I get error -200523. So what Read function is for task with multiple counters?
    2) All those Trigger functions I used I found somewhere on the internet. Where is documentation? I can not find it in NI-DAQmx C Reference Help. Also in the header file, there are a lot of functions prototypes of which are not mentioned in the documentation.
    3) When I change the lowTime parameter in function DAQmxCreateCOPulseChanTime, the time of measurement does not change, so it seems that this part of pulse is not part of 'task' and/or the DAQmxWaitUntilTaskDone function waits just when the trigger pulse is high. This decreases our death time, because it seems not be possible to set duty cycle to 100 %, but still it is little confusing for me.
    Diky moc
    Radek
    P.S.: Ten "editor" na vlkadani dotazu je udesnej... :-)

  • Adding fields with data type "TIMS" to the BP transaction

    hi all,
      This  is Anil regarding the addition of fields to the BP transaction.
    here my problem is for BP transaction I could not find any BADI or screen exit  to add the fields. Even EEWB tool does not allow us to cretate the fields with data type "TIMS". so could you please suggest any other way to add these fields to BP?
    when I enter the values to the time fields in BP transaction, they must reflect in
    BUT000 table also?
    Regards,
    Anil .

    In the physical layer, Column Properties change the data type to int.
    If still problem exists, In the Business Model, write a case statement like
    case when column1=1 then 1 end
    and apply count aggregation on the new calculated column,add the column to presentation table, use that new calculated column for report.
    - Madan

  • Getting Counts with single query

    HI,
    I need help in writing a query that gets account counts in a single query,
    CREATE TABLE ACCOUNTINFO(     
    ACCOUNTID VARCHAR2(20 BYTE) NOT NULL,
    ACCOUNTNO VARCHAR2(10 BYTE) NOT NULL,
    LAST_DEPOSIT_DATE DATE,
    BALANCE NUMBER(10,0));
    I have a table like above and I am trying to write a query that gets
    Count of accounts with deposits made in last 1 month,
    Count of accounts with deposits made in last 2 months
    Account Count with balance > 0,
    Also, I need to join this ACCOUNTINFO with ACCOUNTMAIN to get name etc details
    CREATE TABLE ACCOUNTINFO(     
    EMPID VARCHAR2(20 BYTE) NOT NULL,
    FNAME VARCHAR2(30 BYTE) NOT NULL,
    MNAME VARCHAR2(30 BYTE),
    LNAME VARCHAR2(30 BYTE) NOT NULL,
    DOB DATE,
    ACCOUNTID VARCHAR2(20 BYTE));
    Question, how to write a query since I getting too-many counts (I have only 3 in sample above, actual goes on like 3-6, 6-9 etc).

    SELECT SUM  (CASE WHEN LAST_DEPOSIT>=ADD_MONTHS(SYSDATE,-1) THEN
                   1
                 ELSE
                   0
                 END
                ) COUNT_LAST_MONTH,
           SUM  (CASE WHEN LAST_DEPOSIT>=ADD_MONTHS(SYSDATE,-2) THEN
                   1
                 ELSE
                   0
                 END
                ) COUNT_LAST_TWO_MONTHS,
           SUM  (CASE WHEN BALANCE>0 THEN
                   1
                 ELSE
                   0
                 END
                ) COUNT_BALANCE_GREATER_ZERO
      FROM ACCOUNTINFO

  • FM to count pricing data for document for todays date

    Hi
    I would like to find function module that will count pricing data for offer in CRM 5.0 and will store it in some internal table.
    it cannot change pricing data on document.
    I am writing module for comparing pricing data on document with these that pricing will give for todays date.
    Regards
    Radek

    not solved

  • Filling dynamic internal table with data from other internal table

    Hi Friends,
    My problem is that i have already built a dynamic internal table
    (class int_table->create) but now i want to fill it with data from other internal table.
    The dynamic table column name and the field value of the data filled internal table are same, but how to access that column name, since i cant hard code it anyway.
    Like if my werks field value is '8001'. I want to place it under the column 8001 of dynamic table, Can anybody help me in this regard?
    Awarding points is not a problem for even giving a slight hint.
    Best Regards

    Hi
    See this
    Dynamic internal table is internal table that we create on the fly with flexible column numbers.
    For sample code, please look at this code tutorial. Hopefully it can help you
    Check this link:
    http://www.****************/Tutorials/ABAP/DynamicInternaltable/DynamicInternalTable.htm
    Sample code:
    DATA: l_cnt(2) TYPE n,
    l_cnt1(3) TYPE n,
    l_nam(12),
    l_con(18) TYPE c,
    l_con1(18) TYPE c,
    lf_mat TYPE matnr.
    SORT it_bom_expl BY bom_comp bom_mat level.
    CLEAR: l_cnt1, <fs_dyn_wa>.
    Looping the component internal table
    LOOP AT it_bom_expl INTO gf_it_bom_expl.
    CLEAR: l_cnt1.
    AT NEW bom_comp.
    CLEAR: l_cnt, <fs_dyn_wa>, lf_mat.
    For every new bom component the material data is moved to
    temp material table which will be used for assigning the levels
    checking the count
    it_mat_temp[] = it_mat[].
    Component data is been assigned to the field symbol which is checked
    against the field of dynamic internal table and the value of the
    component number is been passed to the dynamic internal table field
    value.
    ASSIGN COMPONENT c_comp_list OF STRUCTURE <fs_dyn_wa> TO
    <fs_check>.
    <fs_check> = gf_it_bom_expl-bom_comp.
    ENDAT.
    AT NEW bom_mat.
    CLEAR l_con.
    ENDAT.
    lf_mat = gf_it_bom_expl-bom_mat.
    Looping the temp internal table and looping the dynamic internal table
    *by reading line by line into workarea, the materialxxn is been assigned
    to field symbol which will be checked and used.
    LOOP AT it_mat_temp.
    l_nam = c_mat.
    l_cnt1 = l_cnt1 + 1.
    CONCATENATE l_nam l_cnt1 INTO l_nam.
    LOOP AT <fs_dyn_table2> ASSIGNING <fs_dyn_wa2>.
    ASSIGN COMPONENT l_nam OF STRUCTURE <fs_dyn_wa2> TO <fs_xy>.
    ENDLOOP.
    IF <fs_xy> = lf_mat.
    CLEAR lf_mat.
    l_con1 = l_con.
    ENDIF.
    Checking whether the material exists for a component and if so it is
    been assigned to the field symbol which is checked against the field
    of dynamic internal table and the level of the component number
    against material is been passed to the dynamic internal table field
    value.
    IF <fs_xy> = gf_it_bom_expl-bom_mat.
    ASSIGN COMPONENT l_nam OF STRUCTURE <fs_dyn_wa> TO <fs_check>.
    CLEAR l_con.
    MOVE gf_it_bom_expl-level TO l_con.
    CONCATENATE c_val_l l_con INTO l_con.
    CONDENSE l_con NO-GAPS.
    IF l_con1 NE space.
    CONCATENATE l_con1 l_con INTO l_con SEPARATED BY c_comma.
    CLEAR l_con1.
    l_cnt = l_cnt - 1.
    ENDIF.
    <fs_check> = l_con.
    l_cnt = l_cnt + 1.
    ENDIF.
    ENDLOOP.
    AT END OF bom_comp.
    At end of every new bom component the count is moved to the field
    symbol which is checked against the field of dynamic internal table
    and the count is been passed to the dynamic internal table field
    value.
    ASSIGN COMPONENT c_count OF STRUCTURE <fs_dyn_wa> TO <fs_check>.
    <fs_check> = l_cnt.
    INSERT <fs_dyn_wa> INTO TABLE <fs_dyn_table>.
    ENDAT.
    ENDLOOP.
    Reward if useful
    Anji

  • Creating a time channel in the data portal and filling it with data - Is there a more efficient way than this?

    I currently have a requirement to create a time channel in the data portal and subsequently fill it with data. I've shown below how I am currently doing it:
    Time_Ch = ChnAlloc("Time channel", 271214           , 1      ,           , "Time"         ,1                  ,1)              'Allocate time channel
    For intLoop = 1 to 271214
      ChD(intLoop,Time_Ch(0)) = CurrDateTimeReal          'Create time value
    Next
    I understand that the function to create and allocate memory for the time channel is extremely quick. However the time to store data in the channel afterwards is going to be highly dependent on the length I have assigned to the Time_Ch. In my application the length of Time_Ch is variable but could easily be in the order of 271214 or higher. Under such circumstances the time taken to fill Time_Ch is quite considerable. I am wondering whether this is the most appropriate way of doing things or whether there is a more efficient way of creating a time channel and filling it.
    Thanks very much for any help.
    Regards
    Matthew

    Hi Matthew,
    You are correct that there is a more efficient way to do this.  I'm a little confused about your "CurrDateTimeReal" assignment-- is this a constant?  Most people want a Time channel that counts up linearly in seconds or fractions of a second over the duration of the measurement.  But that looks like you would assign the same time value to all the rows of the new Time channel.
    If you want to create a "normal" Time channel that increases at a constant rate, you can use the ChnGenTime() function:
    ReturnValue = ChnGenTime(TimeChannel, GenTimeUnit, GenTimeXBeg, GenTimeXEnd, GenTimeStep, GenTimeMode, GenTimeNo)
    If you really do want a Time channel filled with all the same values, you can use the ChnLinGen() function and simply set the GenXBegin and GenXEnd parameters to be the same value:
    ReturnValue = ChnLinGen(TimeChannel, GenXBegin, GenXEnd, XNo, [GenXUnitPreset])
     In both cases you can use the Time channel you've already created (which as you say executes quickly) and point the output of these functions to that Time channel by using the Group/Channel syntax of the Time channel you created for the first TimeChannel parameter in either of the above functions.
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments

  • Improving the LabVIEW Help: Working with Data Types

    Have you ever had trouble figuring out how to work with the waveform data type, the dynamic data type, or some of the other more complex data types in LabVIEW? As a tech writer on the LabVIEW team, I'd like to improve our documentation about working with data. What would you like to see? What would be helpful? Have you ever given up on a particular data type because it didn't work? Have you ever created a replacement data type because you preferred not to use a LabVIEW data type?
    Lacy Klosterman Rohre | Marketing Editor | National Instruments | 512.683.6376 | ni.com/newsletter

    I've been programming LabVIEW since around 3.1 / 4.0.  Over the years and versions, I've found it necessary to approach a lot of the new datatypes and algorithms with some healthy skepticism because I don't think we're usually given a "fair and balanced" overview.  Some of the things that are highly promoted that bring "ease of use" for beginners (and I *do* understand the importance of that when you're growing your LabVIEW user base) can carry significant performance penalties that are mentioned in more of a whisper, if at all.  I'd just like a more full disclosure of the tradeoffs -- the good, the bad, and the ugly.
    Waveforms -- very rarely use them, unless required for analysis functions.  I have a vague notion (between a belief and a memory) that they used to carry a significant performance penalty compared to arrays, but that the gap is now much smaller.  Still, I'm most comfortable with my old habit of using data arrays.  Some of this came about because a lot of my work uses counters where I may have a variable "dt" value or where my AI is clocked by a counter and the "dt" isn't internally generated.
    Dynamic signals -- have never used them.  Have no clear idea what good they're supposed to be, and they seem to be tied in primarily with Express VI's, which I have also studiously avoided.
    Variants -- Use them only slightly.  Performance issues are a question mark.  Exception: have learned that the implementation of Variant properties allows their use as an efficient way to create associates for string lookup tables. 
    Digital Waveform -- have typically avoided it except when graphing digital data during debug.  Haven't found any compelling reasons to use it.  I do like the notion of a compress/expand capability for sparse digital data, but haven't exercised it enough to trust the implementation. 
    Recap:  I don't need more simple "how-to's" in the help.  I need a LOT more "why bother's" that include both pros and cons. 
    -Kevin P.

Maybe you are looking for