Count of size range
Hi
could some one assist.
Our requirement is Number of tickets by Size per each month, the data in Trade table like this
Trade_id-->Size-->trade_Date-->Market
1-------->110----->01/02/11-->AA
2-------->80------>25/01/11-->AB
3-------->210----->17/01/11-->BB
4-------->150----->15/02/11-->AA
5-------->260------>20/12/10-->AB
6-------->320------>15/12/10-->BB
7------->60------->12/12/11-->AA
8-------->60------->20/01/11->AB
Final result would be
Month-->0-100-->101-200-->201-300-->301-400
Dec-10---->1 ---------->0 ------------>1 ------>1
Jan-11------>2 --------->0 ------------>1 -------->0
Feb-11----->0----------->2-------------->0-------->0
And assist would be appreciated.
Thanks in Advance
Megna
I guess you want something like this. Btw. Your sample data didn't match the wanted outcome. I guess one of the values was mistyped but I keept the values as you provided them.
For future posts try to give an example using a small insert script or a with clause. THis helps us to help you. Also there is a {<b></b>code} tag that you should put before and after your code to improve readablility and to keep indentions.
with testdata as (select 1 trade_id, 110 sizecol, to_date('01/02/11','dd/mm/rr') trade_date, 'AA' market from dual union all
select 2 trade_id, 80 sizecol, to_date('25/01/11','dd/mm/rr') trade_date, 'AB' market from dual union all
select 3 trade_id, 210 sizecol, to_date('17/01/11','dd/mm/rr') trade_date, 'BB' market from dual union all
select 4 trade_id, 150 sizecol, to_date('15/02/11','dd/mm/rr') trade_date, 'AA' market from dual union all
select 5 trade_id, 260 sizecol, to_date('20/12/10','dd/mm/rr') trade_date, 'AB' market from dual union all
select 6 trade_id, 320 sizecol, to_date('15/12/10','dd/mm/rr') trade_date, 'BB' market from dual union all
select 7 trade_id, 60 sizecol, to_date('12/12/11','dd/mm/rr') trade_date, 'AA' market from dual union all
select 8 trade_id, 60 sizecol, to_date('20/01/11','dd/mm/rr') trade_date, 'AB' market from dual
/* end of test data creation */
select to_char(trunc(trade_date,'MONTH'),'Mon-YY') as "month",
count(*) as "total",
count(case when sizecol between 0 and 100 then 1 end) as "bucket 0-100",
count(case when sizecol between 101 and 200 then 1 end) as "bucket 101-200",
count(case when sizecol between 201 and 300 then 1 end) as "bucket 201-300",
count(case when sizecol between 301 and 400 then 1 end) as "bucket 301-400",
count(case when sizecol >= 401 then 1 end) "bucket 401+"
from testdata
group by trunc(trade_date,'MONTH')
order by trunc(trade_date,'MONTH');
month total bucket 0-100 bucket 101-200 bucket 201-300 bucket 301-400 bucket 401+
Dec-10 2 0 0 1 1 0
Jan-11 3 2 0 1 0 0
Feb-11 2 0 2 0 0 0
Dec-11 1 1 0 0 0 0This takes advantage of the fact that the count function will not count NULL values. The case expression will deliver NULL if the sizecol doesn't fit into the appropriate bucket.
There are other solutions that would deliver a similar result, but are more flexible. For example the NTILE or WIDTH_BUCKET function could be used. However they would return/consider the output as rows and not columns. It still might be worth exploring those solutions.
Edited by: Sven W. on Feb 17, 2011 10:56 AM
Similar Messages
-
Counting the size of tablespaces and database
hi,
can any one help me with this..
to write a shell script that counts the size of the tablespaces (excluding the oracle tablespaces like system,sysaux) and come up with the individual database size of evrey databse and mail to team on every month of 2nd for each database.
thanks in advance..to write a shell script that counts the size of the tablespaces (excluding the oracle tablespaces like system,sysaux)To do so requires one to know which shell you use.
Since you declined to share that with us, You're On Your Own YOYO)!
How does script know/decide which DBs exist on any system?
Handle: user8884944
Status Level: Newbie
Registered: Dec 13, 2009
Total Posts: 23
Total Questions: 15 (15 unresolved)
Why are you so challenged to get answers to your posts?
Edited by: sb92075 on Jan 6, 2010 4:52 PM -
SQL DISTINCT COUNT IN DATE RANGE
Dear All
Thanks for your attention.
A table is storing the task summary of each order
e.g.
Date | Order Number | Task Number
2015-01-01 00:00:01 | ABC123456 | JOB001
2015-01-01 00:01:02 | ABC123456 | JOB002
2015-01-01 00:10:02 | ABC123444 | JOB001
2015-01-01 10:12:59 | ABC123456 | JOB002 (Since the job002 is not done correctly, need to work again)
2015-01-01 18:20:05 | ABC888888 | JOB001
2015-01-01 20:22:42 | ABC789456 | JOB001
2015-01-01 21:02:11 | BBB121212 | JOB002
I would like to write a single query that get the distinct count of order number in sepcific date range
result as expected in three columns:
2015-01-01
task_number | AM | PM
JOB001 | 2 | 2
JOB002 | 1 | 1
explain the figures here:
JOB001 AM = 2 (ABC123456, ABC123444)
JOB002 AM = 1 (two records of ABC123456 count as 1 since we would like to know the number of orders)
JOB001 PM = 2 (ABC888888, ABC789456)
JOB002 PM = 1 (BBB121212)
I wrote a query get similar result but the count of order is not distinct
SELECT task_number,
AM=SUM(CASE WHEN date >= ('2015-01-01 00:00:00') AND date < ('2015-01-01 12:00:00') THEN 1 ELSE 0 END),
PM=SUM(CASE WHEN date >= ('2015-01-01 12:00:00') AND date < ('2015-01-02 00:00:00') THEN 1 ELSE 0 END)
FROM MyTable
WHERE task_number = 'JOB001'
Could anyone advise how to enhance this query to let the result become disintct of order number?
Many Thanks,
swivanTry
select task_number,
count(distinct case when datepart(hour, [date]) >=0 and datepart(hour, [date]) < 12 then [OrderNumbers] END) as AM,
count(distinct case when datepart(hour, [date]) >=12 and datepart(hour, [date]) < 24 then [OrderNumbers] END) as PM FROM myTable
GROUP BY Task_Number
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles
Thank you very much, short and good answer -
Getting Record Count From Date Range - IDE: PLSQL Developer
I would like to count the number of member records that fall within a specified date range based on the members effective and expiration dates and their 'elg_code'. I have posted the SQL for some sample data. What I would like to see returned is three columns of counts where the members eff_date exp_date fall within the date range specified by the SQL and have an Elg_code of ' ' (one blank space).
So, what I would like is all members with elg_code ' ' where there eff_dt and exp_dt range falls within APR 2012, MAY 2012 & JUN 2012. So, based on the sample data I posted, Mark, where his elg_code record is ' ', his eff_dt is 1/1/2011 and his exp_dt is within APR 2012 (4/30/2012). Mark's range falls within APR 2012, but not MAY or JUNE of 2012. Marty would tally for both APR and MAY since his eff_dt is before MAY 2012 and his exp is within MAY 2012. etc..
Based on the data below, the results should look like:
APR MAY JUN
4 3 2
APR should have FRANK, MARK, MARTY, MARY,
MAY should have FRANK, MARTY, MARY
JUN should have FRANK and MARY
NOAM and JEAN should not show up as their records with elg_code ' ' do not have eff_dt and exp_dt records that fall within APR-JUN 2012.
So what I tried without success as it appears I have some kind of Cartesian issue (?), is:
select count(m1.mbr_name) APR,
count(m2.mbr_name) MAY,
count(m3.mbr_name) JUN
from mbr2 m1,
mbr2 m2,
mbr2 m3
where m1.eff_dt < '01-may-2012'
and m1.exp_dt > '01-apr-2012'
and m1.elg_code = ' '
and m2.eff_dt < '01-jun-2012'
and m2.exp_dt > '01-may-2012'
and m2.elg_code = ' '
and m3.eff_dt < '01-jul-2012'
and m3.exp_dt > '01-jun-2012'
and m3.elg_code = ' '
Below is the DML
Thanks for any assistance!
create table mbr2 (mbr_name varchar(10), grpid varchar(1), eff_dt date, exp_dt date, elg_code varchar(1))
commit
insert into mbr2 values ('MARK', 'A', to_date('01-01-2011', 'MM-DD-YYYY'), to_date('04-30-2012', 'MM-DD-YYYY'), ' ')
insert into mbr2 values ('MARK', 'A', to_date('05-01-2012', 'MM-DD-YYYY'), to_date('12-31-2013', 'MM-DD-YYYY'), 'C')
insert into mbr2 values ('MARTY', 'A', to_date('01-01-2011', 'MM-DD-YYYY'), to_date('05-31-2012', 'MM-DD-YYYY'), ' ')
insert into mbr2 values ('MARTY', 'A', to_date('06-01-2012', 'MM-DD-YYYY'), to_date('12-31-2013', 'MM-DD-YYYY'), 'C')
insert into mbr2 values ('FRANK', 'B', to_date('01-01-2011', 'MM-DD-YYYY'), to_date('06-30-2012', 'MM-DD-YYYY'), ' ')
insert into mbr2 values ('FRANK', 'B', to_date('07-01-2012', 'MM-DD-YYYY'), to_date('12-31-2013', 'MM-DD-YYYY'), 'C')
insert into mbr2 values ('MARY', 'B', to_date('01-01-2011', 'MM-DD-YYYY'), to_date('06-30-2012', 'MM-DD-YYYY'), ' ')
insert into mbr2 values ('MARY', 'B', to_date('07-01-2012', 'MM-DD-YYYY'), to_date('12-31-2013', 'MM-DD-YYYY'), 'C')
insert into mbr2 values ('JEAN', 'C', to_date('01-01-2011', 'MM-DD-YYYY'), to_date('07-01-2011', 'MM-DD-YYYY'), ' ')
insert into mbr2 values ('JEAN', 'C', to_date('07-01-2011', 'MM-DD-YYYY'), to_date('01-01-2012', 'MM-DD-YYYY'), 'C')
insert into mbr2 values ('NOAM', 'D', to_date('07-01-2012', 'MM-DD-YYYY'), to_date('12-31-2013', 'MM-DD-YYYY'), ' ')
commitHi,
Here's one way:
WITH all_months AS
SELECT LEVEL AS month_num
, ADD_MONTHS (first_month, LEVEL - 1) AS month_begin
, ADD_MONTHS (first_month, LEVEL) AS next_month_begin
FROM (
SELECT TO_DATE ('04-01-2012', 'MM-DD-YYYY') AS first_month
, TO_DATE ('06-01-2012', 'MM-DD-YYYY') AS last_month
FROM dual
CONNECT BY level <= 1 + MONTHS_BETWEEN (last_month, first_month)
SELECT COUNT (CASE WHEN month_num = 1 THEN 1 END) AS month_1
, COUNT (CASE WHEN month_num = 2 THEN 1 END) AS month_2
, COUNT (CASE WHEN month_num = 3 THEN 1 END) AS month_3
FROM all_months a
JOIN mbr2 m ON a.month_begin <= m.exp_dt
AND a.next_month_begin > m.eff_dt
WHERE m.elg_code = ' '
;This assumes you know how many months will be in the output. If you want to derive that from the data, or to give the columns meaningful aliases (such as APR-2011 instead of MONTH_1), then you'll need dynamic SQL (to get separate columns for each month) or string aggregation (if you don't mind one big VARCHAR2 column, formatted to look like several columns). See {message:id=3527823}
If you don't mind modifying the query a little every time you run it, you can hard-code the number of columns and the month names. In the main query, put exactly as many lines as you need, with the alias you want at the end. That is, instead of
, COUNT (CASE WHEN month_num = 2 THEN 1 END) AS month_2say
, COUNT (CASE WHEN month_num = 2 THEN 1 END) AS may_2012I'm not sure exactly what the problem was with the query you posted. It looks like this site cut off parts of the query.
One thing that is definitely a mistake is that you're comparing DATE columns to VARCHAR2 literals. Never compare a DATE to a VARCHAR2; compare DATEs to DATEs (or compare VARCHAR2s to VARCHAR2s). So instead of
and m1.exp_dt > '01-apr-2012'you should say
and m1.exp_dt > TO_DATE ('01-apr-2012', 'dd-mon-yyyy')Thanks for posting the CREATE TABLE and INSERT statements; that's very helpful.
Edited by: Frank Kulash on Jun 26, 2012 3:32 PM -
Hi, I have data containing a task name and it's start and end date.
Now, I want new data based on above that will tell how many tasks were running at any given date.
Assuming that time stamp for each date is 00:00:00, and tasks start at Start_Dt but end just before End_dt (lower bound included, upper bound not)
Input:
Task Start_Dt End_D
A 2013-12-01 2013-12-05
B 2013-12-03 2013-12-04
C 2013-12-03 2013-12-04
D 2013-12-03 2013-12-06
E 2013-12-04 2013-12-05
F 2013-12-06 2013-12-07
Output:
Start
End
Count
(Jobs)
2013-12-01
2013-12-03
1
(A)
2013-12-03
2013-12-04
4
(A,B,C,D)
2013-12-04
2013-12-05
3
(A,D,E)
2013-12-05
2013-12-06
1
(D)
2013-12-06
2013-12-07
1
(F)
In the above, Task B should not be in 3rd row since it ended on 12/04 and hence not to be included in the 12/04 - 12/05 range (and B was not running in this period)
alter session set nls_date_format = 'YYYY-MM-DD';
select tmp.* from
select 'A' TASK, to_date('2013-12-01','YYYY-MM-DD') START_DT, to_date('2013-12-05','YYYY-MM-DD') END_DT from dual
union
select 'B' TASK, to_date('2013-12-03','YYYY-MM-DD') START_DT, to_date('2013-12-04','YYYY-MM-DD') END_DT from dual
union
select 'C' TASK, to_date('2013-12-03','YYYY-MM-DD') START_DT, to_date('2013-12-04','YYYY-MM-DD') END_DT from dual
union
select 'D' TASK, to_date('2013-12-03','YYYY-MM-DD') START_DT, to_date('2013-12-06','YYYY-MM-DD') END_DT from dual
union
select 'E' TASK, to_date('2013-12-04','YYYY-MM-DD') START_DT, to_date('2013-12-05','YYYY-MM-DD') END_DT from dual
union
select 'F' TASK, to_date('2013-12-06','YYYY-MM-DD') START_DT, to_date('2013-12-07','YYYY-MM-DD') END_DT from dual
)tmp
order by 2,3
How to write the sql on the input ('tmp' table)?
Thanks,
-srinivas y.
Message was edited by: ysri
Message was edited by: ysri. Updated tasks and dates.with
data_table as
(select 'A' task,date '2013-12-01' started,date '2013-12-05' ended from dual union all
select 'B',date '2013-12-03',date '2013-12-04' from dual union all
select 'C',date '2013-12-04',date '2013-12-05' from dual union all
select 'D',date '2013-12-06',date '2013-12-07' from dual
date_periods as
(select date '2013-12-01' started,date '2013-12-03' ended from dual union all
select date '2013-12-03',date '2013-12-04' from dual union all
select date '2013-12-04',date '2013-12-05' from dual union all
select date '2013-12-06',date '2013-12-07' from dual
select to_char(p.started,'yyyy-mm-dd') "Start",
to_char(p.ended,'yyyy-mm-dd') "End",
count(*) "Count",
'('||listagg(t.task,',') within group (order by t.task)||')' "(Jobs)"
from date_periods p
left outer join
data_table t
on greatest(t.started,p.started) < least(t.ended,p.ended)
group by p.started,p.ended
order by p.started
Start
End
Count
(Jobs)
2013-12-01
2013-12-03
1
(A)
2013-12-03
2013-12-04
2
(A,B)
2013-12-04
2013-12-05
2
(A,C)
2013-12-06
2013-12-07
1
(D)
Regards
Etbin -
How get Mailbox Folder Item Count for date range?
How to make query to Exchange 2013 like this:
query ItemCount (specified Mailbox, specified Folder (with subfolders), specified Date Range)?
I find this script for Exchange 2010: http://gsexdev.blogspot.ru/2012/10/item-age-sample-one-reporting-on-item.html
This script dont work for Exchange 2013 ((I believe you are making the change on both the places in code, as this path version would be different in 2013
C:\Program Files\Microsoft\Exchange\Web Services\1.2\Microsoft.Exchange.WebServices.dll"
Cheers,
Gulab Prasad
Technology Consultant
Blog:
http://www.exchangeranger.com Twitter:
LinkedIn:
Check out CodeTwo’s tools for Exchange admins
Note: Posts are provided “AS IS” without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. -
Count and size of photos in iTunes does not match what is on my iPhone
I have 2 different iPhone 6 phones. For each of them, the number of photos on the phone does not match the number of photos shown in iTunes. For example, one of my iPhones has fewer than 400 photos; however, when I connect the phone to iTunes on my computer, the usage bar at the bottom shows that there are more than 2500 photos accounting for 2.5GB. I suspect that iTunes is including photos that I have deleted from my phone. Are the additional 2100 "phantom photos" actually taking up space on my phone, and what can I do to make iTunes match what is actually on my phone?
Read here https://discussions.apple.com/docs/DOC-8281
-
Restrictions in Oracle Server (table size, record count ...)
Hello,
can somebody tell me if there are any restrictions of table size, record count, file size (apart from operation system restrictions) in Oracle 8.1.7 and 7.3.4?
Or where can i find information? I couldn4t find anything in the generic documentation.
Thank you in advance,
Hubert Gilch
SEP Logistik AG
Ziegelstra_e 2, D-83629 Weyarn
Tel. +49 8020 905-214, Fax +49 8020 905-100
EMail: [email protected]Hello,
if you are executing a DBMS_AQ.DEQUEUE and then perform a rollback in your code the counter RETRY_COUNT will not go up by 1.
You are only reversing your own AQ action. This counter will be used only internally to log unsuccessful dequeue actions.
Kind regards,
WoG -
Array size limitations... and prime number programs.
What are they? I am an ameteur programmer who wrote an extremely efficient prime finding program, if i do say so myself. The program doesnt find high primes, just prime numbers from 1-1,000,000,000 so far. Thats one version, the next version i use is faster, but because it uses an ArrayList, it can only do the primes 1-10,000,000. I am trying to work the programs up to primes with 50 or more digits, but ArrayList runs out of space, Integer is too small, I dont quite know how to switch all my code to be compatable with BigIntegers, and I cannot find a limit to arrays. I guess that I could find big primes if a) Integer was bigger, b)I tried, but what i wanted to do, because the second program is way more effecient, is to use an array to store primes instead of an ArrayList. The only problem? Arrays cannot be appended, so I need to know the limit in size for an array... So far, from my tests, I have found the limit to be somewhere around, 15,380,277. The only problem with this is that every time i compile, i can use a different number. So I would like it if a) somone could tell me the limit to an array's size, b) ideas for programs that can find primes with 50 or more digits, c) Down below is the code, could someone tell me how to convert it to BigIntegers?
private void primeFinder1root(int beg, int end){
int tmp = 0;
int counter = 0;
int counter2 = 2;
boolean flag;
for(int n = 3; n < end; n+=2){
if(n%5!=0){
flag = true;
for(int d = 3; d <= Math.sqrt(n) && flag; d+=2){
counter++;
if(n%d == 0)
flag = false;
if(flag){
System.out.println(n);
counter2++;
tmp = n;
if(counter2%100000 == 0)
System.out.println(n);
System.out.println();
System.out.println("The program looped " + counter + " times. There were " + counter2 + " primes found. "
+ tmp + " was the last prime found.");
}That is the first progam that does not use an ArrayList, but is still extremely effecient, it only looped 1,744,118,556 times to find the primes 1-100,000,000 which seems like a lot, but it truely isn't. I realize that by using counters and printing, I am slowing the program down immensly, but i am fine with that.
public void primeFinder(){
boolean flag;
int tmp = 0;
int tmp2 = 0;
int counter = 0;
primes.add(2);
for(int n = 3; n < end; n+=2){
if(n%5!=0){
flag = true;
for(int i = 0; i < primes.size()/2 && ((Integer)primes.get(i)).intValue() <= Math.sqrt(n) && flag; i++){
tmp = ((Integer)primes.get(i)).intValue();
if(n%tmp == 0)
flag = false;
counter ++;
if(flag && n!=1){
System.out.println(n);
primes.add(n);
tmp2 = n;
if(primes.size() % 100000 == 0)
System.out.println(n);
primes.add(0, 1);
System.out.println(counter + " " + primes.size() + " " + tmp2);
}This is the code that stores all the primes it finds in an ArrayList, and then compares all numbers to the ArrayList of primes. This is extremely more effecient than the first, looping only 278,097, 308 times to find the primes 1-10,000,000 (the other looped 868,772,491 times). I used 10,000,000 as my example because this program cannot go to 100,000,000 because there are 5,761,455 primes and the ArrayList can only hold ~4,000,000 objects. Because of this ~4,000,000 object limitation on the ArrayList I have set my sites on the Array. This is the reason why I want to know the limitations of an Array if you could please tell me. If you could also, I would like help making my code compatable with BigIntegers as well.
Well, sorry for the very long post, but thank you if you answer it and took the time to read it.
Dumber_ChildI too was in the quest to develop the most efficient prime number code few years ago when I was a student.
Here is a more fine tuned version for your code
public static long findPrimes(int max, ArrayList out){
long count=0;
FastList primes = new FastList((int)Math.sqrt(max));
primes.add(2);
for (int i=3; i<=max; i+=2)
int al_size = primes.size();
double sqrt = Math.sqrt(i);
boolean prime_flag =true;
boolean loop_flag = prime_flag;
for (int j=0; j<al_size && loop_flag; j++)
int val = primes.get(j);
if (i%val == 0)
loop_flag = prime_flag = false;
else if (val > sqrt)
loop_flag = false;
count++;
if (prime_flag)
primes.add(i);
primes.addToArrayList(out);
return count;
Following a data structure to store the prime numbers while processing
Since this holds first number of primes in an array instead of in an ArrayList
the get will work much faster and for those elements the casting is not required
static class FastList
ArrayList list = new ArrayList();
int cache[];
int pointer = 0;
int fastAreaSize;
public FastList(int fastAreaSize){
cache = new int[fastAreaSize];
this.fastAreaSize = fastAreaSize;
public void add(int i){
if (pointer < fastAreaSize)
cache[pointer] = i;
list.add(new Integer(i));
pointer++;
public int size(){
return pointer;
public int get(int i){
if (i<fastAreaSize)
return cache;
else
return((Integer)list.get(i)).intValue();
public void addToArrayList(ArrayList al){
for (int i=0; i<pointer; i++)
if (i<fastAreaSize)
al.add(new Integer(cache[i]));
else
al.add(list.get(i));
When running in my pc
above code detected primes within range 0-10000000 in 281809517 iterations within 6.718secs
while your original code did the same in 278097308 iterations within 13.687 secs.
By the way i removed the check for '5' thats why my code does more iterations.
Notice that I have relocated code like Math.sqrt and ((Integer).....).intValue() to reduce the re calculating the same thing. That saved a lot of time. -
Setting the counter output mastertimebase divider?
Hello
I want to output single short pulses with varying pauses. My MuFu DAQ card has 20 MHz master clock rate and 24 bit counter (Good ol'6052E). When I try to output 1 µs with a pause duration of more than 839 ms, I get an error due to mismatch of clockrate and counter bit size with short and long duration. This is explained in great detail in the corresponding help:
2/ counter clock rate <= X <= 2^24 / counter clock rate. with counter clock rate = master clock rate / divider
0.1 µs <= X <= 16777215 / 20Mhz = 839 ms
I could strech my limits by manually setting the CO.CounterTimebaseMasterTimebaseDivider to 10. But I've searched all property nodes I could find but I have not found this property.
Does anyone know where it is hidden, and to which values it can be set?
Thank you
MichaelHi Michael,
Unfortunately that property doesn't exist. There are a few "Divisor" properties available for other subsystems (e.g. see Analog Input timing block diagram below).
However, you'll notice in the above diagram that the valid divisors of the master timebase are only 1 or 200 (which then gives the AI Sample Clock Timebase). You can get similar behavior on the counter by specifying to use the 20 MHz timebase or 100 kHz timebase for your source. However, using the 100 kHz (1/10 us) timebase is going to prevent you from properly generating the narrow 1 us pulses that you require.
So, you can use 20 MHz or 100 kHz without any additional resources, but 100 kHz wouldn't allow you to have a 1 us pulse, and 20 MHz won't let you have a high or low time of greater than ~839 ms. You could generate frequencies in between these to use as the counter timebase (either use the frequency output or use the second counter to generate the desired frequency, or perhaps configure a dummy analog task) but of course there would always be a tradeoff between the resolution of the pulse and the maximum time between pulses.
If you do have the 2nd counter available, here is my suggestion to get the best of both worlds:
1. Configure a counter output to generate a pulse every N seconds (I suggest configuring the output to generate at 1/N frequency at 50% duty cycle). When you configure this counter, DAQmx will choose an appropriate timebase for you. When N is less than ~1.67 seconds, DAQmx will use the 20 MHz timebase (since both the high and low time would be under the 839 ms). When N is > 1.67 seconds but below ~335 seconds, DAQmx will use the 100 kHz timebase. If you intend on modifying the rate of the output (to something above 1.67 seconds) after the task has started you would need to make sure to specify to use the 100 kHz timebase rather than relying on the DAQmx default. You can't use a built-in timebase if you want to generate a delay greater than 335 seconds, but if you wanted to you could handle this case by checking for it and configuring the frequency output to generate an even lower timebase.
2. To generate the actual output signal, configure a retriggerable single pulse generation to be triggered off of the signal generated above. This signal will be based off of the 20 MHz timebase (assuming you configure a pulse width less than ~839 ms) and so will give you a good resolution on the available pulse widths that you can generate.
In summary, doing this would let you decouple the resolution of your generated pulse width from the resolution of the delay between the pulses. The downside is that it uses two counters.
The other option which I previously mentioned (and what you were asking about) would be to find a timebase that meets the two requirements: 1) fast enough to generate a narrow pulse and 2) slow enough to not roll-over between pulses. You have 100 kHz and 20 MHz available to you, but you can generate intermediate frequencies using the frequency output. If you plan on using a counter to generate the timebase instead, you should consider the other option which decouples the two counters.
Of course, using a device with a higher counter resolution (most newer DAQ devices use 32-bit counters) would probably also resolve your issue depending on the full range of delays that you need. The downside here is the cost of new hardware.
Best Regards,
John Passiak -
How do I calculate the size of files that I have UNC paths for
I am on SQL Server 2008 R2. I have a table that contains a field called [Location]. In that field is a UNC path to the physical file on the repository. Is there a way in SQL Server that I can say give me the select sum([Location] UNC file) where criteria?
I saw some posts about xp_filesize or xp_GetFileDetails, but I do not see them in master. I am unable to add anything and wondering if there is any native functionality that would allow me to accomplish this!? Thanks.Maybe you can use an Excel Macro for this kind of thing.
Dim iRow
Sub ListFiles()
iRow = 11
Call ListMyFiles(Range("C7"), Range("C8"))
End Sub
Sub ListMyFiles(mySourcePath, IncludeSubfolders)
Set MyObject = New Scripting.FileSystemObject
Set mySource = MyObject.GetFolder(mySourcePath)
On Error Resume Next
For Each myFile In mySource.Files
iCol = 2
Cells(iRow, iCol).Value = myFile.Path
iCol = iCol + 1
Cells(iRow, iCol).Value = myFile.Name
iCol = iCol + 1
Cells(iRow, iCol).Value = myFile.Size
iCol = iCol + 1
Cells(iRow, iCol).Value = myFile.DateLastModified
iRow = iRow + 1
Next
If IncludeSubfolders Then
For Each mySubFolder In mySource.SubFolders
Call ListMyFiles(mySubFolder.Path, True)
Next
End If
End Sub
Try this too.
Sub TestListFilesInFolder()
' Open folder selection
' Open folder selection
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "Select a Folder"
.AllowMultiSelect = False
If .Show <> -1 Then GoTo NextCode
pPath = .SelectedItems(1)
If Right(pPath, 1) <> "\" Then
pPath = pPath & "\"
End If
End With
NextCode: 'MsgBox "No files Selected!!"
'Application.WindowState = xlMinimized
'Application.ScreenUpdating = False
Workbooks.Add ' create a new workbook for the file list
' add headers
ActiveSheet.Name = "ListOfFiles"
With Range("A2")
.Formula = "Folder contents:"
.Font.Bold = True
.Font.Size = 12
End With
Range("A3").Formula = "File Name:"
Range("B3").Formula = "File Size:"
Range("C3").Formula = "File Type:"
Range("D3").Formula = "Date Created:"
Range("E3").Formula = "Date Last Accessed:"
Range("F3").Formula = "Date Last Modified:"
Range("A3:F3").Font.Bold = True
Worksheets("ListOfFiles").Range("A1").Value = pPath
Range("A1").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Selection.Font
.Color = -16776961
.TintAndShade = 0
End With
Selection.Font.Bold = True
ListFilesInFolder Worksheets("ListOfFiles").Range("A1").Value, True
' list all files included subfolders
Range("A3").Select
Lastrow = Range("A1048576").End(xlUp).Row
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Worksheets("ListOfFiles").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("ListOfFiles").Sort.SortFields.Add Key:=Range( _
"B4:B" & Lastrow), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("ListOfFiles").Sort
.SetRange Range("A3:F" & Lastrow)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A1").Select
Cells.Select
Cells.EntireColumn.AutoFit
Columns("A:A").Select
Selection.ColumnWidth = 100
Range("A1").Select
End Sub
Sub ListFilesInFolder(SourceFolderName As String, IncludeSubfolders As Boolean)
' lists information about the files in SourceFolder
Dim FSO As Scripting.FileSystemObject
Dim SourceFolder As Scripting.Folder, SubFolder As Scripting.Folder
Dim FileItem As Scripting.File
Dim r As Long
Set FSO = New Scripting.FileSystemObject
Set SourceFolder = FSO.GetFolder(SourceFolderName)
r = Range("A1048576").End(xlUp).Row + 1
For Each FileItem In SourceFolder.Files
' display file properties
Cells(r, 1).Formula = FileItem.Path & FileItem.Name
Cells(r, 2).Formula = (FileItem.Size / 1048576)
Cells(r, 2).Value = Format(Cells(r, 2).Value, "##.##") & " MB"
Cells(r, 3).Formula = FileItem.Type
Cells(r, 4).Formula = FileItem.DateCreated
Cells(r, 5).Formula = FileItem.DateLastAccessed
Cells(r, 6).Formula = FileItem.DateLastModified
' use file methods (not proper in this example)
r = r + 1 ' next row number
Next FileItem
If IncludeSubfolders Then
For Each SubFolder In SourceFolder.SubFolders
ListFilesInFolder SubFolder.Path, True
Next SubFolder
End If
Columns("A:F").AutoFit
Set FileItem = Nothing
Set SourceFolder = Nothing
Set FSO = Nothing
ActiveWorkbook.Saved = True
End Sub
Sub CreateList()
Application.ScreenUpdating = False
Workbooks.Add ' create a new workbook for the folder list
' add headers
ActiveSheet.Name = "ListOfFiles"
With Cells(3, 1)
.Value = "Folder contents:"
.Font.Bold = True
.Font.Size = 12
End With
Cells(4, 1).Value = "Folder Path:"
Cells(4, 2).Value = "Folder Name:"
Cells(4, 3).Value = "Folder Size:"
Cells(4, 4).Value = "# Subfolders:"
Cells(4, 5).Value = "# Files:"
Range("A3:E3").Font.Bold = True
ListFolders BrowseFolder, True
Application.ScreenUpdating = True
Cells.Select
Cells.EntireColumn.AutoFit
Columns("A:A").Select
Selection.ColumnWidth = 100
Columns("B:B").Select
Selection.ColumnWidth = 25
Range("A1").Select
End Sub
Sub ListFolders(SourceFolderName As String, IncludeSubfolders As Boolean)
' lists information about the folders in SourceFolder
Dim FSO As Scripting.FileSystemObject
Dim SourceFolder As Scripting.Folder, SubFolder As Scripting.Folder
Dim r As Long
Set FSO = New Scripting.FileSystemObject
Set SourceFolder = FSO.GetFolder(SourceFolderName)
' display folder properties
Worksheets("ListOfFiles").Range("A1").Value = SourceFolderName
Range("A1").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Selection.Font
.Color = -16776961
.TintAndShade = 0
End With
Selection.Font.Bold = True
r = Cells(Rows.Count, 1).End(xlUp).Row + 1
Cells(r, 1).Value = SourceFolder.Path
Cells(r, 2).Value = SourceFolder.Name
Cells(r, 3).Value = SourceFolder.Size
Cells(r, 3).Value = (SourceFolder.Size / 1048576)
Cells(r, 3).Value = Format(Cells(r, 3).Value, "##.##") & " MB"
Cells(r, 4).Value = SourceFolder.SubFolders.Count
Cells(r, 5).Value = SourceFolder.Files.Count
If IncludeSubfolders Then
For Each SubFolder In SourceFolder.SubFolders
ListFolders SubFolder.Path, True
Next SubFolder
Set SubFolder = Nothing
End If
Columns("A:E").AutoFit
Set SourceFolder = Nothing
Set FSO = Nothing
ActiveWorkbook.Saved = True
End Sub
And, finally.
Const BIF_RETURNONLYFSDIRS As Long = &H1 ''' For finding a folder to start document searching
Const BIF_DONTGOBELOWDOMAIN As Long = &H2 ''' Does not include network folders below the domain level in the tree view control
Const BIF_RETURNFSANCESTORS As Long = &H8 ''' Returns only file system ancestors.
Const BIF_BROWSEFORCOMPUTER As Long = &H1000 ''' Returns only computers.
Const BIF_BROWSEFORPRINTER As Long = &H2000 ''' Returns only printers.
Const BIF_BROWSEINCLUDEFILES As Long = &H4000 ''' Returns everything.
Const MAX_PATH As Long = 260
Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszINSTRUCTIONS As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
Declare Function SHGetPathFromIDListA Lib "shell32.dll" (ByVal pidl As Long, ByVal pszBuffer As String) As Long
Declare Function SHBrowseForFolderA Lib "shell32.dll" (lpBrowseInfo As BROWSEINFO) As Long
Function BrowseFolder() As String
Const szINSTRUCTIONS As String = "Choose the folder to use for this operation." & vbNullChar
Dim uBrowseInfo As BROWSEINFO
Dim szBuffer As String
Dim lID As Long
Dim lRet As Long
With uBrowseInfo
.hOwner = 0
.pidlRoot = 0
.pszDisplayName = String$(MAX_PATH, vbNullChar)
.lpszINSTRUCTIONS = szINSTRUCTIONS
.ulFlags = BIF_RETURNONLYFSDIRS
.lpfn = 0
End With
szBuffer = String$(MAX_PATH, vbNullChar)
''' Show the browse dialog.
lID = SHBrowseForFolderA(uBrowseInfo)
If lID Then
''' Retrieve the path string.
lRet = SHGetPathFromIDListA(lID, szBuffer)
If lRet Then BrowseFolder = Left$(szBuffer, InStr(szBuffer, vbNullChar) - 1)
End If
BrowseFolder = BrowseFolder & "\"
End Function
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it. -
RANGE is deleting table from table
Hello,
I used a ranges object in a 4.7system. If the range was empty, nothing would be deleted from my table. In a ECC6.0 system, if the range is empty, everything is deleted from the table. Could this be a bug that was fixed in ECC6.0?
Edited by: Julius Bussche on Feb 4, 2009 6:19 PM
Post split from hijacked ancient threadI think you are right.( I am in netweaver 7 PI version )
report zars no standard page heading
line-size 170
line-count 65(4).
ranges : r_matnr for mara-matnr.
data : begin of i_mara occurs 0.
data : matnr like mara-matnr.
data : end of i_mara.
move '001' to i_mara-matnr.
append i_mara.
move '002' to i_mara-matnr.
append i_mara.
delete i_mara where matnr in r_matnr.
break-point.
Its deleting entire i_mara internal table if r_matnr is blank.
I don't think this will be a bug.
We need to check if range is not initial , like below mentioned
if not r_matnr[] is initial.
delete i_mara where matnr in r_matnr.
endif.
a® -
SQL azure database size not dropping down after deleting all table
Dear all,
I have a simple database on Azure for which I have deleted all table data. The size of the database is still showing 5Mb of data and I am charge for that. I have heard that this may happen from cluster index getting fragmented.
I have run a querry I found on internet on all my table index to show percentage of fragmentation and all report 0%.
DBA is not so my job but what could it be or how can I reduce that size ?
ON premise I would use COMPACT DB but not available in azure like some others DB action
Thnaks for tips
regardsuser created objects/data are not the only ones stored in your database. you got system objects and metadata as Mike mentions above.
are you trying to skip being charged if you're not storing data? looking at the pricing table, you'll still get charged the $4.995 for the 0-100MB database size range. -
How to count number of documents in a page with Tabs
We have a page with Tabs and sub tabs for each Tab. There is no limit for the Tabs and Sub Tabs. I mean a Tab can have several child tabs and each child tab can have n number of Sub Tabs. We have documents laoded on Tab level and sub Tab level also.
I want to display the count and size of the documents loaded on a page. That is If Page1 has 2 tabs and each tab has 2 sub tabs and on each sub tab there are 2 documents of 10 MB then I should be able to display like this.
Page1 - number of documents: 8 , documents total size 80 MB.
By linking documents table and apges table I am able to get the results by tab not by page.
Any advice is appreciated.
Thanks.
SatyaHi Satya -
It seems you should be able to get the information you are after in the "wwsbr_all_items" view. The folder_ID is the page ID. The content mangement views are documented here: http://www.oracle.com/technology/products/ias/portal/html/plsqldoc/pldoc1012/wwsbr_api_view.html%0A%0A#WWSBR_ALL_ITEMS
Hope this helps,
Candace -
Cycle Counts - Manually schedule by From and To Locator
We run Cycle Counts for a range of stock locators. However, when manually scheduling a Cycle Count, the only option is to enter locators one by one. So, if one subinventory has 300 stock locators and we'd like to count only 200 of them, we'd have to enter each locator. We are finding this very impractical. Hoping someone has come across this and thought of something innovative - as we can only think of using Dataload to load the locators.
Hi,
I think the solution for your question can be solved using the ABC compiles, ABC assignment groups. Just check the topics once.
Regards,
veeraiah chowdary.B
Maybe you are looking for
-
How to solve the library deployment reference
I have a weblogic server setup and application deployed to AdminServer working fine. Now, I'm trying to move one of application from Adminserver to another server(new server, Server-0) on the same machine, same domain. I undeployed it from Adminserve
-
Apple bluetooth Keyboard/mouse + gaming?
Hello, I've been trying to find this info on the net but haven't been able to so far... Can anyone with Apple's bluetooth keyboard tell me if its response time is quick enough to make gaming possible? Thanks Loa
-
JAXB parsing doesn't create set properties.
Using ant and JAXB - when the package is compiled with dtd and the elements are set to minOccurs="0" maxOccurs="unbounded", no set method is produced. If the minOccurs="0" maxOccurs="unbounded" is removed set methods are available, although then the
-
I was trying to recharge my Nokia N97 with a blackberry USB charger. It worked but then I realized all my inbox and sent messages have disappeared!! What happened? Can I find them back?
-
Aironet 1400 bridge Radio 802.11a disable
I have some problem with 802.11A radio is enabled but the detaild status is still display software status is disabled and hardware status is down. I checked the settings on Enable Radio is checked on enable. I can't get any radio accross. Any ideas w