Guidance on use of "COUNT(*) OVER () * 5" in a select query.

Hello Friends,
I was reading one article, in which one table was created for demo. Following was the statements for there.
CREATE TABLE source_table
NOLOGGING
AS
SELECT ROWNUM AS object_id
, object_name
, object_type
FROM all_objects;
INSERT /*+ APPEND */ INTO source_table
SELECT ROWNUM (COUNT(*) OVER () * 5)+ AS object_id
, LOWER(object_name) AS object_name
, SUBSTR(object_type,1,1) AS object_type
FROM all_objects;
INSERT /*+ APPEND */ INTO source_table
SELECT ROWNUM (COUNT(*) OVER() * 10)+ AS object_id
, INITCAP(object_name) AS object_name
, SUBSTR(object_type,-1) AS object_type
FROM all_objects;
Can anyone please tell me the purpose of *"ROWNUM + (COUNT(*) OVER () * 5)"* in above 2 insert statements, or suggest me some document on that.
I don't know about its usage, and want to learn that..
Regards,
Dipali..

The insert statements that you have listed are using Oracle Analytic Functions. Some examples of these functions can be found here: [Oracle Analytic Functions|http://www.psoug.org/reference/analytic_functions.html|Oracle Analytic Functions]
Effectively what that says is the following:
1. "COUNT(*) OVER ()" = return the number of rows in the entire result set
2. Multiply that by 5 (or 10 depending on the insert)
3. Add the current ROWNUM value to it.
This can be shown with a simple example:
SQL> edit
Wrote file sqlplus_buffer.sql
  1  SELECT *
  2  FROM
  3  (
  4     SELECT ROWNUM r,
  5             (COUNT(*) OVER ()) AS ANALYTIC_COUNT,
  6             5,
  7             ROWNUM + (COUNT(*) OVER () * 5) AS RESULT
  8     FROM all_objects
  9  )
10* WHERE r <= 10
SQL> /
         R ANALYTIC_COUNT          5     RESULT
         1          14795          5      73976
         2          14795          5      73977
         3          14795          5      73978
         4          14795          5      73979
         5          14795          5      73980
         6          14795          5      73981
         7          14795          5      73982
         8          14795          5      73983
         9          14795          5      73984
        10          14795          5      73985
10 rows selected.
SQL> SELECT COUNT(*) from all_objects;
  COUNT(*)
     14795Hope this helps!
Note the the statements you provided will not actually execute because of the extra "+" signs on either side. I have removed them.

Similar Messages

  • Can we use concatenate in where clause of a select query

    I have a select query as follows....
        SELECT ebeln ebelp belnr vgabe bwart DMBTR
                                 FROM ekbe
                                 INTO TABLE i_ekbe
                                 FOR ALL ENTRIES IN i_blck
                                 WHERE ebeln =  i_blck-ebeln AND ebelp =                                                                               
    i_blck-ebelp.
    Now i want to retrieve data from BKPF ..can i write a select query something like....
    select * from BKPF into itab
                FOR ALL ENTRIES IN i_ekbe
                where awkey = ( conatenate i_ekbe-belnr i_ekbe-gjahr )
    OR ELSE...is there any other way to link table ekbe and bseg ???

    Hi Poonam,
    SELECT ebeln ebelp belnr vgabe bwart DMBTR
    FROM ekbe
    INTO TABLE i_ekbe
    FOR ALL ENTRIES IN i_blck
    WHERE ebeln = i_blck-ebeln
    AND ebelp = i_blck-ebelp.
    select *
    from BKPF
    into  table itab
    FOR ALL ENTRIES IN i_ekbe
    where belnr = i_ekbe-belnr.
    If u want to check with AWKEY concatenate into seperate field and then use to check in where condition.
    data: lw_awkey(20) type c.
    CONCATENATE  i_ekbe-belnr  i_ekbe-gjahr  INTO lw_awkey.
    select *
    from BKPF
    into  table itab
    FOR ALL ENTRIES IN i_ekbe
    where awkey = lw_awkey
    Best regards,
    raam

  • Use of FIRST_VALUE OVER in a PL/SQL query

    Hello,
    Here is my problem:
    I'm trying to execute a query using FIRST_VALUE OVER in a PL/SQL procedure, e.g.
    SELECT FIRST_VALUE (name) OVER (order by birthdate)
    FROM birthday_table
    WHERE location = 'HOME';
    I need to get the value returned. I tried to do it using an INTO clause and
    also with EXECUTE IMMEDIATE, but I get an error like "invalid column name".
    Thank you,
    Olivier.

    Assuming the query runs successfully outside of PL/SQL, the execute immediate construct would be:
    execute immediate 'select first_value ... where location = :loc' into v_some_variable using 'HOME';

  • Issue returning a count of rows in a SELECT QUERY...

    I am working in Oracle 11.2g and I have a query where I want to return the count of DAILY records as well as WEEKLY records for specific marketers.
    Here is my query:
    Select     Mka_Mktr_No, 
              Case When Rat_Freq_Cd = 'D' Then Count(*) Else 0 End DailyCount,
              case when Rat_Freq_Cd = 'W' then count(*) Else 0 End WeeklyCount
            From     Marketer_Account, Acct
            Where     Mka_Exp_Dt >= '01-NOV-2012'
            And     Mka_Eff_Dt <= '30-NOV-2012'
            and     rat_acct_no = mka_acct_no
            And     Rat_Usage_Cd = 'P'
            and rat_freq_cd != 'M'
            Group By Mka_Mktr_No, Rat_Freq_Cd
            Order By Mka_Mktr_No;I would prefer to have the results show up on the SAME row, but instead I get the following results:
    MKA_MKTR_NO            DAILYCOUNT             WEEKLYCOUNT           
    10005                  68                     0                     
    10005                  0                      2                      Note how it shows each count on a seperate row. Is there a way to tweak the query to show the counts on the same row:
    MKA_MKTR_NO            DAILYCOUNT             WEEKLYCOUNT           
    10005                  68                     2       and not have two seperate rows?
    Many thanks,
    Sean

    Don't group by rat_freq_cd
    SQL> with test_data as
      2      (
      3      select 1 mka_mktr_no, 'W' rat_freq_cd from dual union all
      4      select 1 mka_mktr_no, 'W' rat_freq_cd from dual union all
      5      select 1 mka_mktr_no, 'D' rat_freq_cd from dual union all
      6      select 2 mka_mktr_no, 'D' rat_freq_cd from dual union all
      7      select 2 mka_mktr_no, 'W' rat_freq_cd from dual union all
      8      select 2 mka_mktr_no, 'W' rat_freq_cd from dual union all
      9      select 2 mka_mktr_no, 'D' rat_freq_cd from dual union all
    10      select 2 mka_mktr_no, 'D' rat_freq_cd from dual union all
    11      select 2 mka_mktr_no, 'D' rat_freq_cd from dual union all
    12      select 3 mka_mktr_no, 'D' rat_freq_cd from dual union all
    13      select 3 mka_mktr_no, 'D' rat_freq_cd from dual union all
    14      select 3 mka_mktr_no, 'W' rat_freq_cd from dual union all
    15      select 3 mka_mktr_no, 'D' rat_freq_cd from dual union all
    16      select 3 mka_mktr_no, 'D' rat_freq_cd from dual union all
    17      select 3 mka_mktr_no, 'W' rat_freq_cd from dual
    18      )
    19  select
    20      mka_mktr_no,
    21      count(case when rat_freq_cd = 'D' then rat_freq_cd end) dailycount,
    22      count(case when rat_freq_cd = 'W' then rat_freq_cd end) weeklycount
    23  from
    24      test_data
    25  group by mka_mktr_no;
    MKA_MKTR_NO DAILYCOUNT WEEKLYCOUNT
              1          1           2
              2          4           2
              3          4           2

  • How to use string operation in where clause of select query

    Hello All,
    I just want to know how can i write a restriction in select query saying retrive data only begins with name "DE*".
    Explaination: If my table has records and names starts with character then i want to write a query to fetch all the records in which names starts with DE*.
    Thanks in advance for your quick reply...
    Dev.

    Hi
    In the where clause you need to write like
    WHERE NAME LIKE 'DE%'
    Regards
    Sudheer

  • IR Problem with COUNT (*) OVER () AS apxws_row_cnt

    Hi all,
    i have a query wich is ran under 2 seconds when ecexuted in SQL (TOAD),
    when i use this query in an interactive report then it takes minutes.
    When i reviewd the query which APEX is sending to the DB i noticed an additional select clause:
    SELECT columns,
    COUNT ( * ) OVER () AS apxws_row_cnt
    FROM (
    SELECT *
    FROM ( query
    ) r
    ) r
    WHERE ROWNUM <= TO_NUMBER (:APXWS_MAX_ROW_CNT)
    when i remove the COUNT ( * ) OVER () AS apxws_row_cnt then the query is fast again.
    How can i change the IR so that the COUNT ( * ) OVER () AS apxws_row_cnt doesn't appear annymore.
    I removed the pagination (- no pagination selected -)
    I put the query in a new IR report in a new page, the COUNT ( * ) OVER () AS apxws_row_cnt still appears.
    Any suggestions i can try ?
    Regards,
    Marco

    Marco1975 wrote:
    Hi all,
    i have a query wich is ran under 2 seconds when ecexuted in SQL (TOAD), I doubt that.
    I think your query returns many rows. Did you see all the rows in Toad in 2 secs?
    If the answer is NO then the query is not finished after 2 secs. It just showed you the first few rows.
    Almost every tool including apex does the same.
    However if you want to know how many rows are returned then there is no way around doing the whole select until the last row.
    Then the result can be shown.
    APEX or a developer might use something like the analytic function "count(*) over ()" to get this result already on the first row. The database still needs to fetch all the rows. Howeverthe result set is not transported over the network to the client, which might also save a lot of time compared to not doing it on the database level.

  • Need help using count over function

    I have the following query
    Select student_id, OM, TM, TP, count(rownum) over (order by OM desc) PS from
    (select
    er.student_id, sum(er.obtained_marks) OM, sum(ds.max_marks) TM,
    to_char(sum(er.obtained_marks)/sum(ds.max_marks)*100,'990.00') TP
    from
    tbl_exam_results er, tbl_date_sheet ds
    where
    ds.date_sheet_id = er.date_sheet_id and ds.class_id = 77 and ds.exam_id = 3 and ds.session_id = 1 group by er.student_id
    results in
    <div style="width: 889px"><div class="fielddata"><div>
    <div>STUDENT_ID OM TM TP PS
    1825 291 300 97.00 1
    3717 290 300 96.67 2
    2122 289 300 96.33 3
    3396 287 300 95.67{color:#ff6600} *5 &lt;--*{color}
    4554 287 300 95.67{color:#ff6600} *5 &lt;--*{color}
    1847 281 300 93.67 6
    1789 279 300 93.00 7
    5254 277 300 92.33 8
    1836 258 300 86.00 9
    4867 250 260 96.15 10
    1786 249 300 83.00 11
    4659 245 300 81.67 12
    1835 241 300 80.33 *{color:#ff6600}15 &lt;--{color}*
    1172 241 270 89.26*{color:#ff6600} 15 &lt;--{color}*
    3696 241 300 80.33 *{color:#ff6600}15 &lt;--{color}*
    3865 234 300 78.00 16
    5912 215 300 71.67 17
    5913 204 300 68.00 *{color:#ff6600}19 &lt;--{color}*
    3591 204 300 68.00 *{color:#ff6600}19 &lt;--{color}*
    1830 184 250 73.60 20
    </div>
    </div>
    </div>
    </div>
    <div style="width: 889px"><div class="fielddata"><div>
    But I want as following
    <div>STUDENT_ID OM TM TP PS
    1825 291 300 97.00 1
    3717 290 300 96.67 2
    2122 289 300 96.33 3
    3396 287 300 95.67 *{color:#ff6600}4 &lt;={color}*
    4554 287 300 95.67 *{color:#ff6600}4 &lt;={color}*
    1847 281 300 93.67 {color:#ff6600}5 the following entry{color}
    1789 279 300 93.00 6
    5254 277 300 92.33 7
    1836 258 300 86.00 8
    4867 250 260 96.15 9
    1786 249 300 83.00 10
    4659 245 300 81.67 11
    1835 241 300 80.33 {color:#ff6600}*12 &lt;=*{color}
    1172 241 270 89.26{color:#ff6600} *12 &lt;=*{color}
    3696 241 300 80.33 {color:#ff6600}*12 &lt;=*{color}
    3865 234 300 78.00{color:#ff6600} 13 the following entry{color}
    5912 215 300 71.67 14
    5913 204 300 68.00 *{color:#ff6600}15&lt;={color}*
    3591 204 300 68.00 *{color:#ff6600}15 &lt;={color}*
    1830 184 250 73.60 {color:#ff6600}16{color} {color:#ff6600}the following entry{color}
    </div>
    Thanks in advance for any help
    </div>
    </div>
    </div>
    <div style="width: 889px"></div>
    Edited by: sabir786 on Jan 14, 2009 4:13 AM
    Edited by: sabir786 on Jan 14, 2009 4:17 AM

    Since I do not understand at all what you are trying to do, I cannot correct your query, but I can explain the results.
    The analytic function is doing a running count of the number of records that have been outout so far. With no duplicates, this is somewhat clearer.
    SQL> WITH t AS (SELECT 1 om FROM dual UNION ALL
      2             SELECT 2 FROM dual UNION ALL
      3             SELECT 3 FROM dual UNION ALL
      4             SELECT 4 FROM dual UNION ALL
      5             SELECT 5 FROM dual)
      6  SELECT om, COUNT(rownum) OVER (ORDER BY om) ps
      7  FROM t;
            OM         PS
             1          1
             2          2
             3          3
             4          4
             5          5However, when you have duplicates, both duplicate values get the running count from the last of the duplicates (i.e. the highest running count). Here, I have duplicated 4 and see what I get:
    SQL> WITH t AS (SELECT 1 om FROM dual UNION ALL
      2             SELECT 2 FROM dual UNION ALL
      3             SELECT 3 FROM dual UNION ALL
      4             SELECT 4 FROM dual UNION ALL
      5             SELECT 4 FROM dual UNION ALL
      6             SELECT 5 FROM dual)
      7  SELECT om, COUNT(rownum) OVER (ORDER BY om) ps
      8  FROM t;
            OM         PS
             1          1
             2          2
             3          3
             4          5
             4          5
             5          6The "second" 4 record had a running count of 5 (i.e. it was the fifth record output), so both 4's get the same count. Changing the order by to descending shows the same effect, it just changes the running count:
    SQL> WITH t AS (SELECT 1 om FROM dual UNION ALL
      2             SELECT 2 FROM dual UNION ALL
      3             SELECT 3 FROM dual UNION ALL
      4             SELECT 4 FROM dual UNION ALL
      5             SELECT 4 FROM dual UNION ALL
      6             SELECT 5 FROM dual)
      7  SELECT om, COUNT(rownum) OVER (ORDER BY om DESC) ps
      8  FROM t;
            OM         PS
             5          1
             4          3
             4          3
             3          4
             2          5
             1          6John

  • Counting Over Last 3500 appearances with Where Clause

    I'm Using Sql Server Studio 2014
    I have a Table containing the following columns:
    AutoId  Assembly_No  [Rank]   
    1          Assembly1       2
    2          Assembly2       1
    3          Assembly1       2
    4          Assembly1       1
    5          Assembly1       0
    6          Assembly2       2
    7          Assembly2       1
    I'm Trying to Run a query that Will count over the last 3500 times that a specific Assembly_No has been that has a rank > 0. For simplicity's sake we can use we can look at the last 2 times that an assembly has been ran. So the results that I'm expecting
    should look like this
    Assembly_NO   Count
    Assembly2        2
    Assembly1        1
    This resulted in assembly2 being counted twice for ids 6 and 7 and only once for ids 4 and 5 because only one rank was > 0. AutoID is an identity column so the most recent values will be determined using this number.
    The query below can count over all of the Assemblies ran, however I'm having trouble only counting over the last 2 for each assembly
    Select Assembly_No, Count(*) as Count
    From TblBuild
    Where Rank > 0
    Group By Assembly_No
    Returns the following 
    Assembly_no  Count
    Assembly2      3
    Assembly1      3

    Looks like this should return what you are expecting:
    --drop table #temp
    create table #temp
    autoid int,
    assembly_no nvarchar(10),
    rank_no int
    insert into #temp (autoid, assembly_no, rank_no) values (1, 'Assembly1', 2)
    insert into #temp (autoid, assembly_no, rank_no) values (2, 'Assembly2', 1)
    insert into #temp (autoid, assembly_no, rank_no) values (3, 'Assembly1', 2)
    insert into #temp (autoid, assembly_no, rank_no) values (4, 'Assembly1', 1)
    insert into #temp (autoid, assembly_no, rank_no) values (5, 'Assembly1', 0)
    insert into #temp (autoid, assembly_no, rank_no) values (6, 'Assembly2', 2)
    insert into #temp (autoid, assembly_no, rank_no) values (7, 'Assembly2', 1)
    select t.assembly_no, count(nullif(t.rank_no, 0))
    from #temp t
    inner join 
    select autoid, rank_no, row_number() over (partition by assembly_no order by autoid desc) as ct
    from #temp
    )x
    on x.autoid = t.autoid
    and x.ct <= 2
    group by t.assembly_no

  • Using a counter to create a timing delay

    Hi all,
    I am working on an application where I need to send some digital outputs seperated by precise timing delays.
    So for example, I may want to output a 'high' to channel 1, then have a 20ms delays, then output a 'high' to channel 2, then have a 50ms delay, and so on.
    I want the timing delays to be easily adjustable and I would like them to be precise.
    The program is being set up for hundreds of tests and it will be run once per test. In between tests I will have the opportunity to modify timing delays.
    I already have a cDAQ-9174 chassis and am planning to buy a NI 9401 high speed digital I/O card. It has been suggested to me that I use a counter (which is built into the chassis) to generate the timing delays, which sounds like a good idea to me. However, I don't really understand how to access the counters and configure the 'DAQmx create channel' function because there are so many options for the reference clock which I don't understand.
    I am thinking that I need to implement something like this:
    http://zone.ni.com/reference/en-XX/help/370466V-01/mxcncpts/hwtimedcounter/
    However I'm if this is what I need and I'm not sure how I would go about testing this code. I guess I would need to connect some sort of output to the counter to see if it's working correctly.
    Any help would be much appreciated.

    After a bit of experimenting, now I'm not sure if the hardware time delay has any advantage over the software delay. I can get a constant 5ms delay using the 'wait' function, yet when I use the counter I can normally get a 5ms delay, but sometimes (perhaps one trial out of five) I get a 4 or 6ms delay. I have even seen a 1ms delay using the counter method. Perhaps my method for measuring is flawed though? I have attached some screenshots of my program. If anybody has any comments it would be appreciated.

  • Count Over Count

    Hi, i was looking for some help in regards to understanding the general rule of using the count function. I am trying to build my knowledge of the different functions in order for me to have a better understanding so that I am writing my sql queries in the right way.
    What i was looking to find out was trying to understand the count function. As i understand I can apply the following in order to give me a count of a particular set of data.
    select number, count(*) AS no_count
    from test
    group by job_id;What I am trying to understand is if for some reason I wanted to use the results of the "count(*) AS no_count" to give me another set of results i.e. sum all values over 2 for example, would i write it like the following:
    select number, count(*) AS no_count,
    select count(no_count) having etc...
    from test
    group by job_id;or is the general rule that I would have to write a select within a select?
    If somebody could please help, would really appreciate it. Btw if there is any documentation on using count, as well as using this with other functions i.e. sum than that would be very useful as well.
    Thanks in advance.

    Solomon, thanks for your help. Apologies if i have not explained my question properly. The problem is that I haven't created the tables and have wrote my sample data and i am then trying to work out solutions before attempting to create the tables etc, which is probably where I am going wrong.
    The job_ids can be repeated, first job_count should give me total job counts belonging to each job_id.
    For example in your first dataset you have a job count for all jobs i.e. manager has 3 records with 1 job_count. So I would then like a column to give me a total count of job_count for each criteria i.e. manager had 3 total jobs. I have tried to breakdown the dataset you have shown alongwith the extras I am trying to add, to hopefully explain what I am looking for.
    JOB               JOB_COUNT       TOTAL_JOB_COUNT               OVER_1
    MANAGER                    1                    3                                   0
    PRESIDENT                  1                    1                                   1
    CLERK                         1                    4                                   0
    SALESMAN                  4                    4                                   0
    ANALYST                    2                    2                                   0
    MANAGER                   1                    3                                   0
    MANAGER                   1                    3                                   0
    CLERK                        1                    4                                   0
    CLERK                        2                    4                                   0
    [/CODE]
    So this tells from all jobs which job was dealt with first time so in this case it would be the president, the rest of the jobs were repeated.
    The total_job_count would be written like:select job, count(*) as TOTAL_JOB_COUNT
    but its the over_1 (or sum maybe, not sure) that is based on the results within the total_job_count that I need to look into to find values that equal to 1. Hence I thought I would have to write a count of a count, which is what I am not clear on.
    Sorry for the inconvenience, and really appreciate your help and time.
    Thanks
    Apologies, not sure how to write the resultset as added but appears all over the place.
    Edited by: 973436 on 17-Dec-2012 04:06                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Photo scanning -- cropping using pixel count for dimensions?

    Hello,  I have both an older Photosmart 3310 and a new Officejet Pro 8610.  When scanning using the 3310, I can control cropping of the previewed scan using pixel count (width and height).  I can't seem to do that when scanning using the 8610.  Dimensions are in inches and only.  In fact, my editing options on the previewed scan on the 8610 seem quite limited relative to what I can do using the much older 3310.  Am I missing something?  I want to scan on my new 8610, but I also want some control over the scanned image like I had with the 3310.
    Thanks.

    Hello there! Welcome to the forums @JGH28 ,
    Yes, you are in fact correct. The software definitely has changed over time and is much more limited with the software for your scanning options for the Officejet 8610 compared to your Photosmart 3310. Unfortunately there is not a way to change the options you have to broaden them again.
    I would only suggest to ensure you have installed the Full Feature software for your Officejet 8610 to ensure you are seeing the full options available for your printer: HP Officejet Pro 8610 e-All-in-One Printer series Full Feature Software and Drivers
    Best wishes, and thank you for posting in the community!
    R a i n b o w 7000I work on behalf of HP
    Click the “Kudos Thumbs Up" at the bottom of this post to say
    “Thanks” for helping!
    Click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution!

  • Counter over flow reading

    What is the utilization of counter over flow reading and annual estimate in counters? Is there any report or any application where it helps us in tracking?
    Regards,
    VM
    Edited by: V M on Jun 1, 2008 9:35 AM

    hi
    counter overflow reading is used wherein your counter reading overflows
    for example your milometer will only show 9999 miles ,once this counter has reached overflow  occurs ,i.e. the counter starts to count upwards from 0000 again
    Annual estimate is used for scheduling purpose for performance based scheduling and for multiple counter plan ,
    Multiple counter plan
    The system uses the current date as the start date and automatically calculates the planned dates based on the maintenance cycles, the scheduling parameters, the estimated annual performance and the last counter readings
    Performance based
    The system automatically calculates the planned date and call date based on the maintenance packages, the scheduling parameters, the estimated annual performance and the counter reading at the start of the cycle
    regards
    thyagarajan

  • I can not send email from my iPad .  Have been using it for over a year, all of a sudden I can only receive email.  I have a wifi connection in my home and have a A T &T cellular data plan?

    I can not send email from my iPad .  Have been using it for over a year, all of a sudden I can only receive email.  I have a wifi connection in my home and have a A T &amp;T cellular data plan?

    I have a 1st gen iPhone that I just updated the software to 2.0.2
    Now whenever I press the mail icon it goes to the mail app for about 4 seconds, does nothing, no loading of folders, old messages, nothing.
    Then it reverts back to the home screen. Tried restarting, haven't tried restoring, thought I'd look here first.
    Anyone???

  • How do I use a counter for time measurement with NI-DAQmx and C++?

    Hi,
    I need my C++ program to read time (number of elapsed ticks) using the counter on PCI-6229. I had this written and working for the non-MX driver, and now I need to re-write it for NI-DAQmx.
    Here are the steps that I want to accomplish:
    1. Route the 80MHz timebase to the input of "Dev1/ctr0"
    2. Start the counter and let it count the ticks.
    3. After a while, read the number of ticks from the counter.
    Here is how I am trying to do it now (without success):
               DAQmxCreateTask ( "" , &taskHandle ) ;
               DAQmxCreateCICountEdgesChan ( taskHandle , "Dev1/ctr0" , "" , DAQmx_Val_Rising, 0 , DAQmx_Val_CountUp ) ;
               DAQmxConnectTerms ( "/Dev1/80MHzTimebase" ,  "/Dev1/Ctr0Source" , DAQmx_Val_DoNotInvertPolarity ) ;
               DAQmxStartTask ( taskHandle ) ;
               then DAQmxReadCounterScalarU32 ( taskHandle , 0.25 , &curCount , NULL ) ;
               and DAQmxClearTask ( taskHandle ) ;
    No errors are generated, but I do not see the tick count being incremented when I repeatedly read the counter.
    Advice will be greatly appreciated!!

    Hi Peter,
    Welcome to the forums!   I just want to make sure I understand what you are trying to do.  You would like to count the rising edges of the 80 MHz clock using DAQmx in C++.  In order to route the timebase to the counter, you need to use the signal name (PFI8) instead of the counter (Ctr0Source) for the counter source input.  This name is found in Measurement Automation Explorer (MAX) by right-clicking on the device and choosing “Device Pinouts.”  This will physically put the 80 MHz clock on the PFI8 line, so make sure you reset the device or disconnect the terminals after you are done. 
    That being said, may I ask what you are trying to do by reading the number of elapsed ticks?  If you are trying to monitor a hardware timed pulse, it would be better to count the frequency or period of that pulse.  This would provide better accuracy, because you are not relying on how fast DAQmx Read can poll the hardware.  If you are simply looking for a software based timer, I would recommend taking a look at this MSDN forum post. 
    Using the GetTickCount function instead will free up your counter and provide comparable accuracy to counting the edges of the timebase.
    I hope that helps you out, let me know if you have any further questions about this. Good luck with your project.
    Rod T.

  • I used to have over 2000 songs in my itunes library, now there are only a few and I cannot find the others.

    I used to have over 2000 songs in my itunes library, now there are only a few and I cannot find the others.

    See this post.
    tt2

Maybe you are looking for

  • How to pass parameters in url templates

    hi all, i've created an iview which calls yahoomail url,i need to pass user-id and password through parameters, such that i can personalize my id and password using personalize option to see my yahoo mail box in the iview.so, plzz give me a solution

  • Burning multiple emails to a disc

    I need to burn about 50 emails on a certain subject to a disc. If I highlight them and try to copy and paste them to a folder or a thumb drive, they will not go. Does anyone know how to do this? thanks

  • Re: JDBC 10.2.0.3 available for download

    kmensah Posted this on Mar 14, 2007 3:25 PM: Some of you have requested when 10.2.0.3 will be available for download; here it is: http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html But the link 10.2.0.3 link gives a 404 NOT FOUN

  • The last update has squashed my apps!

    Hi, I just updated my iPad 2 to iOS 7.0.3 and it looks like all the apps have been squashed upwards. There appears to be a gap between the bottom of the screen and the favourite apps which used to sit at the bottom. Help!

  • How do I do word processing and printing?

    What is best word processing app for I-Pad 2 and how do I print?