Count, Group by between dates
I am trying to count the number of IDs dropped and enrolled in each unit for each of the 4 terms between their perspective dates.
There are 4 Terms and an ID can participate in a unit in any of these terms:
TERM
START_DATE
END_DATE
1
25-Feb-13
18-Mar-13
2
27-May-13
17-Jun-13
3
26-Aug-13
16-Sep-13
4
25-Nov-13
16-Dec-13
I am trying to count how many IDs enrolled in a unit between those dates and how many doped before the end date
The ENROL_DATE for each ID in a unit has to be between the given Term Dates to count.
Unit KIS has 1 ENROL and one DROP in TERM 1
UNIT POL occurs in TERM 2 and 4 and both DROP
UNIT LIN and 1 ENROL and 1 DROP in 2 different TERMS
My problem is how do i specify count ENROL and count drop between the Term dates and then group by TERM and UNIT.
Please see below table for given data and expected result. It should make sense.
Thanks,
{code}
CREATE TABLE DAN_GR4
(ID NUMBER(12),
STATUS VARCHAR2(12),
TERM NUMBER(12),
ENROL_DTE DATE,
TERM_START_DTE DATE,
TERM_END_DATE DATE,
UNIT VARCHAR2 (12));
INSERT INTO DAN_GR4 (ID,STATUS,TERM,ENROL_DTE,TERM_START_DTE,TERM_END_DATE,UNIT) VALUES ('1', 'ENROL' ,'1', '15-Mar-13' ,'25-Feb-13' ,'18-Mar-13', 'KIS');
INSERT INTO DAN_GR4 (ID,STATUS,TERM,ENROL_DTE,TERM_START_DTE,TERM_END_DATE,UNIT) VALUES ('1', 'DROP' ,'2', '27-MAY-13' ,'27-MAY-13' ,'17-JUN-13', 'POL');
INSERT INTO DAN_GR4 (ID,STATUS,TERM,ENROL_DTE,TERM_START_DTE,TERM_END_DATE,UNIT) VALUES ('1', 'DROP' ,'2', '27-JUN-13' ,'27-MAY-13' ,'17-JUN-13', 'LIN');
INSERT INTO DAN_GR4 (ID,STATUS,TERM,ENROL_DTE,TERM_START_DTE,TERM_END_DATE,UNIT) VALUES ('1', 'DROP' ,'3', '27-JUN-13' ,'27-MAY-13' ,'17-JUN-13', 'PUI');
INSERT INTO DAN_GR4 (ID,STATUS,TERM,ENROL_DTE,TERM_START_DTE,TERM_END_DATE,UNIT) VALUES ('2', 'DROP' ,'3', '26-SEP-13' ,'26-AUG-13' ,'16-SEP-13', 'POL');
INSERT INTO DAN_GR4 (ID,STATUS,TERM,ENROL_DTE,TERM_START_DTE,TERM_END_DATE,UNIT) VALUES ('2', 'ENROL' ,'4', '26-NOV-13' ,'25-NOV-13' ,'16-DEC-13', 'LIN');
INSERT INTO DAN_GR4 (ID,STATUS,TERM,ENROL_DTE,TERM_START_DTE,TERM_END_DATE,UNIT) VALUES ('3', 'DROP' ,'4', '15-DEC-13' ,'25-NOV-13' ,'16-DEC-13', 'LIN');
INSERT INTO DAN_GR4 (ID,STATUS,TERM,ENROL_DTE,TERM_START_DTE,TERM_END_DATE,UNIT) VALUES ('3', 'DROP' ,'4', '15-DEC-13' ,'25-NOV-13' ,'16-DEC-13', 'POL');
INSERT INTO DAN_GR4 (ID,STATUS,TERM,ENROL_DTE,TERM_START_DTE,TERM_END_DATE,UNIT) VALUES ('3', 'DROP' ,'1', '15-DEC-13' ,'25-FEB-13' ,'18-MAR-13', 'KIS');
{code}
GIVES:
ID
STATUS
TERM
ENROL_DTE
TERM_START_DTE
TERM_END_DATE
UNIT
1
ENROL
1
15-Mar-13
25-Feb-13
18-Mar-13
KIS
1
DROP
2
27-May-13
27-May-13
17-Jun-13
POL
1
DROP
2
27-Jun-13
27-May-13
17-Jun-13
LIN
1
DROP
3
27-Jun-13
27-May-13
17-Jun-13
PUI
2
DROP
3
26-Sep-13
26-Aug-13
16-Sep-13
POL
2
ENROL
4
26-Nov-13
25-Nov-13
16-Dec-13
LIN
3
DROP
4
15-Dec-13
25-Nov-13
16-Dec-13
LIN
3
DROP
4
15-Dec-13
25-Nov-13
16-Dec-13
POL
3
DROP
1
15-Dec-13
25-Feb-13
18-Mar-13
KIS
WANT:
UNIT
TERM_START_DTE
DROP_BEFORE_END_DATE
TERM
KIS
1
1
1
POL
1
2
POL
1
3
POL
1
4
LIN
1
1
4
LIN
1
2
PUI
1
3
USING:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
with
dan_gr4 as
(select '1' id,
'ENROL' status,
'1' term,
to_date('15-Mar-13','dd-MON-rr') enrol_dte,
to_date('25-Feb-13','dd-MON-rr') term_start_dte,
to_date('18-Mar-13','dd-MON-rr') term_end_dte,
'KIS' unit
from dual
union all
select '1','DROP','2',to_date('27-MAY-13','dd-MON-rr'),to_date('27-MAY-13','dd-MON-rr'),to_date('17-JUN-13','dd-MON-rr'),'POL' from dual union all
select '1','DROP','2',to_date('27-JUN-13','dd-MON-rr'),to_date('27-MAY-13','dd-MON-rr'),to_date('17-JUN-13','dd-MON-rr'),'LIN' from dual union all
select '1','DROP','3',to_date('27-JUN-13','dd-MON-rr'),to_date('27-MAY-13','dd-MON-rr'),to_date('17-JUN-13','dd-MON-rr'),'PUI' from dual union all
select '2','DROP','3',to_date('26-SEP-13','dd-MON-rr'),to_date('26-AUG-13','dd-MON-rr'),to_date('16-SEP-13','dd-MON-rr'),'POL' from dual union all
select '2','ENROL','4',to_date('26-NOV-13','dd-MON-rr'),to_date('25-NOV-13','dd-MON-rr'),to_date('16-DEC-13','dd-MON-rr'),'LIN' from dual union all
select '3','DROP','4',to_date('15-DEC-13','dd-MON-rr'),to_date('25-NOV-13','dd-MON-rr'),to_date('16-DEC-13','dd-MON-rr'),'LIN' from dual union all
select '3','DROP','4',to_date('15-DEC-13','dd-MON-rr'),to_date('25-NOV-13','dd-MON-rr'),to_date('16-DEC-13','dd-MON-rr'),'POL' from dual union all
select '3','DROP','1',to_date('15-DEC-13','dd-MON-rr'),to_date('25-FEB-13','dd-MON-rr'),to_date('18-MAR-13','dd-MON-rr'),'KIS' from dual
select unit,term,max(decode(enrolled,'within','Late')) late_enrolment,max(dropped) when_dropped
from (select unit,term,
case when status = 'ENROL'
then case when enrol_dte between term_start_dte and term_end_dte
then 'within'
else 'outside'
end
end enrolled,
case when status = 'DROP'
then case when enrol_dte < term_start_dte
then 'before start'
when enrol_dte < term_end_dte
then 'before end'
else 'after end'
end
end dropped
from dan_gr4
group by unit,term
order by unit,term
UNIT
TERM
LATE_ENROLMENT
WHEN_DROPPED
KIS
1
Late
after end
LIN
2
after end
LIN
4
Late
before end
POL
2
before end
POL
3
after end
POL
4
before end
PUI
3
after end
Regards
Etbin
Similar Messages
-
How to count the days between Date Range using OO ABAP?
hi experts,
i want to count the days between Date Range using OO ABAP for that which class and method can i use?.
Thanks,
Mahesh.Not sure I understand the requirement for it to be OO, but you could always write your own (i.e. use this):
REPORT zz_date_diff.
CLASS date_diff DEFINITION.
PUBLIC SECTION.
METHODS diff IMPORTING i_date_fm TYPE d
i_date_to TYPE d
EXPORTING e_days TYPE i.
ENDCLASS."
CLASS date_diff IMPLEMENTATION.
METHOD diff.
e_days = i_date_to - i_date_fm.
ENDMETHOD."
ENDCLASS."
DATA: g_ref TYPE REF TO date_diff,
g_days TYPE i,
g_date_fm TYPE d VALUE '20080101',
g_date_to TYPE d VALUE '20090101'.
START-OF-SELECTION.
CREATE OBJECT g_ref.
CALL METHOD g_ref->diff
EXPORTING
i_date_fm = g_date_fm
i_date_to = g_date_to
IMPORTING
e_days = g_days.
WRITE g_days. -
A counter of periods between dates
Hi all,
i got a query, that the user input a fiscper for example: 005.2009,
now i have to make a counter of periods from 000 to the selected, in this case = 5 periods,
then, y got a KF with an amount for example = 1000, this amount i have to divide between the counter, in this case
1000 / 5 = 200, this 200 is the number what i need to do, but this i can do it with the counter of periods, thats what i m looking for, how to do this counter of periods, help guysHi John,
Please use exception aggregation to create a count restricted on Fiscal Period ( Count of all values ) . Now you can use this in your formula.
-Vikram -
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
ThankThis one is duplicate. see the following link
Count(*) with group by max(date)
Thanks -
Hi,
I need to create a counter kf which should populate 1 and 0 to this counter field. Please let me know is there any difference between data type
NUMBER (DEC) and INTEGER (INT4).
Please suggest.
Thanks & Regards,
Pavan kumarHi Pavan,
The basic difference between Number(DEC) and INT4 is its internal storage in system.
For Number (DEC) - Value internally stored as packed number with 3 decimal places whereas INT 4 as 4 byte integer without decimal places.
For counter KF, you can go for INT 4.
Hope this helps.
Thanks -
Grouping with 2 date in sql server
totle_count
dt
name
program_id
1
1/3/2015
Tea
14
1
1/5/2015
Tea
14
1
1/6/2015
Lunch
13
17
1/6/2015
Tea
14
2
1/9/2015
Breakfast
1008
39
1/10/2015
Breakfast
1008
4
1/19/2015
Breakfast
1008
1
1/19/2015
Dinner
1009
3
1/21/2015
Tea
14
totle_count
dt
name
program_id
1
1/6/2015 and 1/8/2015
Lunch
13
2
1/3/2015 and 1/5/2015
Tea
14
17
1/6/2015 and 1/9/2015
Tea
14
3
1/21/2015 and 1/23/2015
Tea
14
41
1/9/2015 and 1/11/2015
Breakfast
1008
4
1/18/2015 and 1/20/2015
Breakfast
1008
1
1/18/2015 and1/20/2015
Dinner
1009
Here is 2 table, 1st is my row table, and I want to group with 2 date.
Here is 3 days difference. and sum of value is coming.
2nt table is my expectation table.
Plz help me for this problem.
Thanks
SamirI am doing 3 days grouping here
"dt" is name of date column
if "dt" column has '1/19/2015' then next in group it will come in "1/18/2015 and1/20/2015"
any date of 18 or 19 0r 20 it will come in "1/18/2015 and1/20/2015"
and counting will add between 3 date
Sorry your posted output is not as per above rule
How did row for 1/6/2015 and 1/9/2015 got included then. If you group by 3 days you wont get
this row as 6-9 is 4 days not 3 days
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
Post Author: tadj188#
CA Forum: Formula
Needed: Sum of LineCount Including Groups and Detail Data On Each Page Used To Generate New Page If TotalPageLineCount > 28
Background:
1) Report SQL is created with unions to have detail lines continue on a page, until it reaches page footer or report footer, rather than using subreports. A subreport report is now essentially a group1a, group1b, etc. (containing column headers and other data within the the report with their respective detail lines). I had multiple subreports and each subreport became one union.
Created and tested, already:
1) I have calculated @TotalLineForEachOfTheSameGroup, now I need to sum of the individual same group totals to get the total line count on a page.
Issue:
1) I need this to create break on a certain line before, it dribbles in to a pre-printed area.
Other Ideas Appreciated:
1) Groups/detail lines break inconveniently(dribble) into the pre-printed area, looking for alternatives for above situation.
Thank you.
Tadjexport all image of each page try like this
var myDoc = app.activeDocument;
var myFolder = myDoc.filePath;
var myImage = myDoc.allGraphics;
for (var i=0; myImage.length>i; i++){
app.select(myImage[i]);
var MyImageNmae = myImage[i].itemLink.name;
app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.high;
app.jpegExportPreferences.exportResolution = 300;
app.selection[0].exportFile(ExportFormat.JPG, File(myFolder+"/"+MyImageNmae+".JPEG"), false);
alert(myImage[i].itemLink.name) -
Returne between dates in case when
i want to return between dates values on case when clauses on where clauses
like
and
(case
when (cc.segment3 NOT like '4%' and cc.segment3 NOT like '5%')
then (between to_date('01/07/2012','dd/mm/rrrr') and to_date('31/07/2012','dd/mm/rrrr'))
when (cc.segment3 like '4%' or cc.segment3 like '5%')
then (between to_date('01/07/2012','dd/mm/rrrr') and to_date('31/07/2012','dd/mm/rrrr'))
end) h.default_effective_date
the problem is in the = operator but i don't know haw to use this
any help??ok here is the full coad
select
DECODE(SUBSTR (CC.segment1, 1, 1), 'J', 'OFFSHORE', 'I', 'OFFSHORE','IN COUNTRY')branch_nature,
decode(cc.segment1,'A6260','Head Office','Branches') branch_type,
cc.segment1,
decode (h.currency_code,'EGP','mahly','agnaby') currency_code ,
cc.segment3,
t.description,
CASE
when h.currency_code in('EGP') then sum(l.entered_cr)
else 0
end entered_cr,--sum(l.entered_cr) entered_cr,
CASE
when h.currency_code in('EGP') then sum(l.entered_dr)
else 0
end entered_dr, --sum(l.entered_dr) entered_dr,
CASE
when h.currency_code NOT in('EGP') then sum(l.accounted_cr)
else 0
end accounted_Dr,--0 accounted_Dr,
CASE
when h.currency_code NOT in('EGP') then sum(l.accounted_dr)
else 0
end accounted_cr --0 accounted_cr
from apps.gl_je_headers h,
apps.gl_je_lines L,
apps.gl_code_combinations cc,
apps.fnd_flex_values_tl t ,
applsys.fnd_user us,
apps.gl_je_batches b
where h.status = 'P'
and us.user_id = h.Created_by
--and h.currency_code in('EGP')
and l.je_header_id = h.je_header_id
and l.code_combination_id =cc.code_combination_id
and cc.segment3 = t.flex_value_meaning
and cc.segment3 in ('31000020','40505020')
and cc.segment1 in ('A5550','B0010')
-- and (DECODE(SUBSTR (CC.segment1, 1, 1), 'J', 'OFFSHORE', 'I', 'OFFSHORE','IN COUNTRY') =:P_branch_nature OR :P_branch_nature is NULL)
--and (decode(cc.segment1,'A6260','Head Office','Branches') = :P_BRANCH_TYPE OR :P_BRANCH_TYPE is NULL)
and t.description is not null
and t.language ='AR'
and h.je_batch_id = b.je_batch_id
and
(case
when (cc.segment3 NOT like '4%' and cc.segment3 NOT like '5%')
then (between to_date(:P_Start_date,'dd/mm/rrrr') and to_date(:P_END_date,'dd/mm/rrrr'))
when (cc.segment3 like '4%' or cc.segment3 like '5%')
then (between to_date(:P_Start_date2,'dd/mm/rrrr') and to_date(:P_END_date,'dd/mm/rrrr'))
end) h.default_effective_date
and (case
when (cc.segment3 like '4%' or cc.segment3 like '5%')
then (h.default_effective_date)
end) between to_date('01/07/2012','dd/mm/rrrr') and to_date('31/07/2012','dd/mm/rrrr')*/
group by cc.segment3 , t.description , cc.segment1,h.currency_code;
the part between tages need to modigied -
Passing between date paramters to a different page in the application
Hi,
I'm woking on a drill down report in Apex 4.0.
Page1: (standard Report)
select transactiondate, storenumber, count(amount) as Count from transactions (transactiondate data type is DATE).
Created two items :P1_From_Date and :P1_To_Date
When i run the Page1 with the from_date and to_date given, reports populate the data for the particular date,(eg: 15-NOV-2011).
Until this point everything is fine.
In Page 2, I need to show the detail of every transactions for a particular store.
Created a hidden item in page 2 as :P2_storenumber
created a link on the Count column in Page1, select :P2-storenumber corresponding to the #COUNT#
Query on page 2 is : select transactiondate, storenumber,amount from transactions
here i want to get the transaction for a day (between 15-NOV-2011 00:00 and 15-NOV-2011 23:59 ).
How can I accomplish this requirement, by passing the date parameters from the Page1 for any date in Page2.
Please help.
thanks in advance.Hi user13561710,
Assuming the items on page 1 are populated with date values, you can simply reference them in the query on page 2:
select transactiondate, storenumber,amount from transactions where storenumber = :P2_storenumber and transaction_date between :P1_from_date and :P1_to_date
If need be, you could always explicitly convert the date items to a date (and not rely upon the implicit conversion), for example:
select transactiondate, storenumber,amount from transactions where storenumber = :P2_storenumber and transaction_date between to_date(:P1_from_date,'DD-MON-RRRR') and to_date(:P1_to_date,'DD-MON-RRRR')
assuming the formart of the date value on page 1 is DD-MON-RRRR.
I hope this helps.
Joel -
Dynamically group records by date
I am attempting to create a report that will dynamically group records into a set number of date buckets. This is similar to grouping records by a date field and setting the days, weeks, months, etc property but instead of grouping by a set time span I want to a specific number of date groups regardless of date span. So say i have records where the first date is today at 1am and the last record is today at 9 pm. I want the data grouped into 10 groups and the time calculated for that group based on total time span / 10. The first group would be 1AM to 3AM, the second would group 3AM to 5AM, etc.. The reason I am doing this is for a chart that displays record counts over time but the overall timespan will never be known until runtime. Setting the chart for hourly or weekly doesn't work because if the user runs the report over a year the dates will be illegible.
Thanks in advance!Well this SHOULD be easy. But leave it to CR make not...
You can start by finding the minimum & maximum dates within your range:
Local DateTimeVar MinDate;
MinDate := Minimum({Table.DateField})
and
Local DateTimeVar MaxDate;
MaxDate := Maximum({Person.ModifiedDate})
Then figure out what the the interval would be if the span is broken down into 10 equal parts"
DateDiff("n", {@MinDate}, {@MaxDate}) / 10
From there just use a formula to segregate each records into the appropriate groups:
EvaluateAfter({@Interval});
IF {Table.DateField} >= {@MinDate}
AND {Table.DateField} <= DateAdd("n",{@Interval}, {@MinDate}) THEN 1 ELSE
IF {Table.DateField} > DateAdd("n",{@Interval}, {@MinDate})
AND {Table.DateField} <= DateAdd("n",{@Interval} * 2, {@MinDate}) THEN 2 ELSE
IF {Table.DateField} > DateAdd("n",{@Interval} * 2, {@MinDate})
AND {Table.DateField} <= DateAdd("n",{@Interval} * 3, {@MinDate}) THEN 3 ELSE
IF{Table.DateField} > DateAdd("n",{@Interval} * 3, {@MinDate})
AND{Table.DateField} <= DateAdd("n",{@Interval} * 4, {@MinDate}) THEN 4 ELSE
IF {Table.DateField} > DateAdd("n",{@Interval} * 4, {@MinDate})
AND {Table.DateField} <= DateAdd("n",{@Interval} * 5, {@MinDate}) THEN 5 ELSE
IF {Table.DateField} > DateAdd("n",{@Interval} * 5, {@MinDate})
AND {Table.DateField} <= DateAdd("n",{@Interval} * 6, {@MinDate}) THEN 6 ELSE
IF {Table.DateField} > DateAdd("n",{@Interval} * 6, {@MinDate})
AND {Table.DateField} <= DateAdd("n",{@Interval} * 7, {@MinDate}) THEN 7 ELSE
IF {Table.DateField} > DateAdd("n",{@Interval} * 7, {@MinDate})
AND{Table.DateField} <= DateAdd("n",{@Interval} * 8, {@MinDate}) THEN 8 ELSE
IF {Table.DateField} > DateAdd("n",{@Interval} * 8, {@MinDate})
AND {Table.DateField} <= DateAdd("n",{@Interval} * 9, {@MinDate}) THEN 9 ELSE
IF {Table.DateField} > DateAdd("n",{@Interval} * 9, {@MinDate})
AND {Table.DateField} <= {@MaxDate} THEN 10
This is where CR drops the ball... IMHO... it WON'T allow you to to group by a formula field that uses an aggregate in the formula (in this case Minimum & Maximum)... It will however allow to to graph on it, which I assume is what you are actually trying to do. If anyone knows a way to work around the grouping issue, I'd love to know it myself.
HTH,
Jason -
Hi ,
I need the data of NOV and DEC 2007. First i need to check in my table whether i have the data of NOV and DEC 2007 .
I am not able to use a proper query to find out the data .
select count(*) from optout_tbl where date between ("2007-11-07" and "2007-12-07");
I am using this please query . but its saying missing expression . I think i am wrong .
Could any one suggest to me to find the data . Moreover its a normal table not a partitioned one.
ThanksWhen i am using the below query to get the data between the selected months . I am getting error like missing expression , even i tried with double code' still have the same problem .
plz tell me that which am using queyr have any changes required.
SQL> select count(*)
from optout_tbl
where date between TO_DATE('2007-11-07', 'YYYY-MM-DD')
and TO_DATE('2007-12-07', 'YYYY-MM-DD');
where date between TO_DATE('2007-11-07', 'YYYY-MM-DD')
ERROR at line 3:
ORA-00936: missing expression
Thanks -
Hello -
I've been tearing my hair out over this problem i'm trying to solve, probably just been staring at it too long which is making it worse -
I have a series of open support tickets which are supposed to be updated on a daily basis, the problem is that they aren't always being updated daily. So, the business wants to know the number of days from when a ticket was last updated and today's
date. I have this basic calculation and it's working fine, however now the business wants to exclude weekends from the calculation. The other problem is that some reps DO go in on weekends and update their tickets, so sometimes there will be updates
made on weekend dates.
To give an example -
Today's date is 2014-02-10 (Monday). A ticket was last updated last Thursday, 2014-01-30. The difference between the two dates is 11, so it's been 11 days since the ticket was last updated. Now, if I exclude Saturdays and Sundays, then
it's actually been 7 days since the ticket was last updated. I'm not sure how to do this in T-SQL.
Now, to further complicate the problem, sometimes a ticket IS updated on a Saturday or Sunday. So, if a ticket was updated on 2014-02-02 (Sunday), then it should be counted. Again i'm not sure how to do this.
What gets me is that this is probably fairly simple and i've just been staring at it too long. In the meantime, can someone offer some guidance?
Thanks!!I've adapted this from a function on my blog. you will need to add set the YourTicketTable to where ever your tickets are stored.
CREATE
FUNCTION [dbo].[CalcWorkDaysBetween](@StartDate
As DateTime,@EndDate
AS DateTime)
RETURNS
INT AS
BEGIN
SET @EndDate
=DATEADD(DAY,1,@EndDate)
DECLARE @Count
AS Int= 0
DECLARE @Date
As Date=@StartDate
WHILE @Date
< @EndDate
BEGIN
IF (DATEPART(WEEKDAY,@Date)IN(1,7)
OR (SELECT
Count(*)
FROM YourTicketTable WHERE TicketDate=@Date)=1)
BEGIN
SELECT @Count = @Count
+ 1
END
SELECT @Date=DATEADD(Day,
1,@Date)
END
RETURN
DATEDIFF(DAY,@StartDate,@EndDate)- @Count
END
Regards, -
Difference Between Data Type and Data Object
Difference Between Data Type and Data Object
hi magesh
<u><b>Data types</b></u> can be divided into
elementary,
reference, and
complex types.
<u><b>Elementary Types</b></u>
Elementary types are the smallest indivisible unit of types. They can be grouped as those with fixed length and those with variable length.
<u><b>Fixed-Length Elementary Types</b></u>
There are eight predefined types in ABAP with fixed length:
<u><b>Four character types:</b></u>
Character (C),
Numeric character (N),
Date (D),
and Time (T).
<b>One hexadecimal type:</b>
Byte field (X).
<b>Three numeric types:</b>
Integer (I),
Floating-point number (F)
and Packed number (P).
<u><b>Variable-Length Elementary Types</b></u>
There are two predefined types in ABAP with variable length:
STRING for character strings
XSTRING for byte strings
Reference Types
<b>Reference types</b>
describe data objects that contain references (pointers) to other objects (data objects and objects in ABAP Objects).
<u><b>Data Types</b></u>
1) As well as occurring as attributes of a data object, data types can also be defined independently.
2)You can then use them later on in conjunction with a data object.
3) The definition of a user-defined data type is based on a <b>set of predefined elementary data types.</b>
4) You can define data types <b>either locally in the declaration part of a program</b> using the TYPESstatement) or <b>globally in the ABAP</b> Dictionary.
5) You can use your own data types to declare data objects or to check the types of parameters in generic operations.
<u><b>Data Objects</b></u>
1)<b>Data objects</b> are the physical units with which ABAP statements work at runtime.
2) The contents of a data object occupy memory space in the program.
3) <b>ABAP statements access these contents by addressing the name of the data object</b> and interpret them according to the data type..
4) For example, statements can write the contents of data objects in lists or in the database, they can pass them to and receive them from routines, they can change them by assigning new values, and they can compare them in logical expressions.
5) Each <b>ABAP data object has a set of technical attributes</b>, which are fully defined at all times when an ABAP program is running (field length, number of decimal places, and data type).
6) You <b>declare data objects</b> either <b>statically in the declaration part</b> of an ABAP program (the most important statement for this is DATA), or <b>dynamically at runtime</b> (for example, when you call procedures).
7) As well as fields in the memory area of the program, the program also treats literals like data objects.
hope this helps u,
reward points if useful
Ginni -
I am trying to develop a query in MS Access 2010 to join two tables using three joins, one of which is a (between) date range. The tables are contained in Access. The reason
the tables are contained in access because they are imported from different ODBC warehouses and the data is formatted for uniformity. I believe this cannot be developed using MS Visual Query Designer. I think writing a query in SQL would be suiting this project.
ABCPART links to XYZPART. ABCSERIAL links to XYZSERIAL. ABCDATE links to (between) XYZDATE1 and ZYZDATE2.
[ABCTABLE]
ABCORDER
ABCPART
ABCSERIAL
ABCDATE
[ZYXTABLE]
XYZORDER
XYZPART
XYZSERIAL
XYZDATE1
XYZDATE2Thank you for the looking at the post. The actual table names are rather ambiguous. I renamed them so it would make more sense. I will explain more and give the actual names. What I do not have is the actual data in the table. That is something I don't have
on this computer. There are no "Null" fields in either of the tables.
This table has many orders (MSORDER) that need to match one order (GLORDER) in GLORDR. This is based on MSPART joined to GLPART, MSSERIAL joined to GLSERIAL, and MSOPNDATE joined if it falls between GLSTARTDATE and GLENDDATE.
[MSORDR]
MSORDER
MSPART
MSSERIAL
MSOPNDATE
11111111
4444444
55555
2/4/2015
22222222
6666666
11111
1/6/2015
33333333
6666666
11111
3/5/2015
This table has one order for every part number and every serial number.
[GLORDR]
GLORDER
GLPART
GLSERIAL
GLSTARTDATE
GLENDDATE
ABC11111
444444
55555
1/2/2015
4/4/2015
ABC22222
666666
11111
1/5/2015
4/10/2015
AAA11111
555555
22222
3/2/2015
4/10/2015
Post Query table
GLORDER
MSORDER
GLSTARTDATE
GLENDDATE
MSOPNDATE
ABC11111
11111111
1/2/2015
4/4/2015
2/4/2015
ABC22222
22222222
1/5/2015
4/10/2015
1/6/2015
ABC22222
33333333
1/5/2015
4/10/2015
3/5/2015
This is the SQL minus the between date join.
SELECT GLORDR.GLORDER, MSORDR.MSORDER, GLORDR.GLSTARTDATE, GLORDR.GLENDDATE, MSORDR.MSOPNDATE
FROM GLORDR INNER JOIN MSORDR ON (GLORDR.GLSERIAL = MSORDR.MSSERIAL) AND (GLORDR.GLPART = MSORDR.MSPART); -
My current application acquires data when it sees a TTL trigger line. Then it wait until the next TTL pulse and continues taking data until the user stop the data acquisition process. I use "counter 0" as counter source. The program works well. However I need to read digital data everytime I take AI data. I plan to use "counter 1" to read the digital data. The trick is that I need to synchronize both AI and counter 1 readings. Therefore the counter 2 will acquire data when AI acquires data.
Here is the code I implemented and would like to know if it is correct. The new code (implementation of second counter) is in the bottom part of the code. I will really appreciate your help.
Yajai
Attachments:
code.txt 6 KBHi DrObb,
What is sounds like you want to do is to specify an external sample clock for your analog acquisition and a digital acquisition. Is there a reason in particular that you're using a counter? What hardware are you using? If you simply want to sample a digital and analog channel on the same clock edge, this won't be very difficult (provided your hardware supports hardware-timed digital IO). You can find an example of this being done in C by going to:
Start » All Programs » National Instruments » NI-DAQ » Text-Based Code Support » ANSI C Examples and then navigating to Synchronization\Multi-Function\ContAI-Read Dig Chan
Regards,
Sean
Sean Ferguson
Application Engineering Specialist | RF and Reconfigurable Test
Maybe you are looking for
-
Error in send message to A large number of audience
I want to send a message to A large number of audience but I get an error This error << Messaging is sending a large number of SMS messages. Do you want to allow this app to continue sending messages? >> Deny ....... Allow Please Help me
-
Hi, Can anyone provide me any documents on ABAP Querry. I need to modify one sap standard program on abap querry urgently, any help in this regard will be very much appreciated. Thanks. Lokesh.
-
Connecting Flex 2 To Data Sources
I have order flex 2 (out of my own pocket) so I can learn how to use it. Hopefully I should have it in the next day or two. It seems that once I get going, the truly cool stuff will be connected to some sort of data source. Any suggestions for gettin
-
Advice needed on which processor to buy for a Mega PC Pro
Hello all, just registered, Could anyone recommend which processor I should buy for the MEGA PC 865 Pro I just ordered? I can see a Intel Pentium 4 630 3 Ghz Socket 775 800Mhz 2mb Retail Boxed on Ebuyer for £124 which is my price range but I'm not su
-
Uninstall photo shop elements 6
I bought a new V500 epson scanner from Staples about a week ago. When I tried to install photo shop elements 6 the install got down to 38 seconds left and froze up. I turned the computer off and then on again. I found that the photo shop was not c