FROM PPL_PRODUCT_TESTID2
WHERE ((MONO = '5750333') AND (ITNO = '132961') AND (SYSTEMTYPE = '0036') AND (TESTFLAG = '1'))
Order by TIMESTAMP ASC
==> above gives me a TOTAL of 150
SELECT DISTINCT MAINSERNO, to_char(TIMESTAMP, 'MM/DD/YYYY HH24:MI:SS') as TIMESTAMP
FROM PPL_PRODUCT_TESTID2
WHERE ((MONO = '5750333') AND (ITNO = '132961') AND (SYSTEMTYPE = '0036') AND (TESTFLAG = '1'))
Order by TIMESTAMP ASC
==> above gives me a TOTAL of 165, of which 15 are MAINSERNO are duplicates. I have used the DISTINCT, why does it still produces duplicates?
Also, based on its TIMESTAMP, I would want to extract the count, and put them into its appropriate hourly time slot as shown in the printscreen, is that possible?
That is e.g from TIMESTAMP data of HH:MM:SS, those data that are after 00:30:00 and before 01:30:00 would be counted and place into the 01:30 Hours(18) timeslot.

How do I loop through the 24-hour time slot, instead of repeating each one as below:
also possible not to include the date, and only the time in the comparison condition?



Iftikar HussainPosted Aug 12, 2013, 4:16 AM
Regards,
Iftikar
TAN WhoAMIPosted Aug 12, 2013, 8:41 AM
I rephrase again...
at each StartTime and EndTime of the hourly interval, I would like it be to dated as the MO_DATE (as below), instead of the system's clock date. Presently, it follows the system's clock date which is not what I want.
var MO_Date = (from p in context.PPL_PRODUCT_TESTID2
Iftikar HussainPosted Aug 12, 2013, 5:34 AM
Regards,
Iftikar
TAN WhoAMIPosted Aug 12, 2013, 4:34 AM
how do I set my StartTime and EndTime to be dated from the database? that is to MO_Date. It always set to today's date, which I do not want.
Iftikar HussainPosted Aug 12, 2013, 4:16 AM
Regards,
Iftikar
TAN WhoAMIPosted Aug 12, 2013, 4:08 AM
above I am able to retrieve the date and time of the minimum...
how do I set today's time to be 12:00:00AM ?
Iftikar HussainPosted Aug 11, 2013, 11:45 PM
DateTime date= Convert.ToDateTime("02/02/2013");
DateTime next = date.AddHours(7.5);
Regards,
Iftikar
TAN WhoAMIPosted Aug 11, 2013, 10:47 PM
I realize that my code works only for today's date. If I want to retrieve the records of those past dates, I need to manually change the dates to those past dates, which is troublesome.
How can we modify the query such that it does the comparison of its TIMESTAMP based on the dates from the records retrieved from the table in the database?
Presently, this attached code compared with TIMESTAMP with today's date and its hourly interval.
thanks.
Iftikar HussainPosted Aug 6, 2013, 8:39 AM
p.tt.Hour>timeCal.StartTime.Hour && p.tt.Hour
Regards,
Iftikar
Iftikar HussainPosted Aug 6, 2013, 4:48 AM
Regards,
Iftikar
Iftikar HussainPosted Aug 6, 2013, 3:03 AM
Regards,
Iftikar
TAN WhoAMIPosted Aug 6, 2013, 2:59 AM
but how do I input in the timestamp condition to do the comparison?
Iftikar HussainPosted Aug 6, 2013, 2:48 AM
public class TimeCal
{
public string StartTime {get;set;}
public string EndTime {get;set;}
public int TotalRecord {get;set;}
}
create a collection of this class
List
TimeCal timeCal=new TimeCal() { StartTime="07:30", EndTime="08:30"};
timeCals.Add(timeCal)
like that add for all time
then after getting the result by using the query, loop thru this collection
List
foreach(var timeCal in timeCals)
{
int count = (from p in dbcontext.Products
timeCal.TotalRecord=count;
timeCalsResult.Add(timeCal);
}
Regards,
Iftikar
Iftikar HussainPosted Aug 6, 2013, 2:40 AM
I will be not able join now
Regards,
Iftikar
TAN WhoAMIPosted Aug 6, 2013, 2:25 AM
Iftikar HussainPosted Aug 6, 2013, 2:22 AM
Regards,
Iftikar
TAN WhoAMIPosted Aug 6, 2013, 2:09 AM
would you like to join.me?
TAN WhoAMIPosted Aug 6, 2013, 1:58 AM
Could I have above in my C# code to extract out the count?
Iftikar HussainPosted Aug 6, 2013, 1:40 AM
//you need write all other select query till 6:30
Regards,
Iftikar
TAN WhoAMIPosted Aug 6, 2013, 1:22 AM
Iftikar HussainPosted Aug 6, 2013, 1:09 AM
let we complete this first, then will look into second one.
Regards,
Iftikar
TAN WhoAMIPosted Aug 6, 2013, 1:06 AM
how to I loop through the query to extract the count for the 24-hourly intervals?
Iftikar HussainPosted Aug 6, 2013, 12:31 AM
The difference between two query with distinct that, first one will remove the duplicate of MAINSERNO column value, where in second query it will do the same, but it will different TIMESTAMP value for same MAINSERNO value. Therefore you are getting more count. To get that kind of output, first create a table and insert all this time
CREATE TABLE TimeCal
(
StartTime varchar(5),
EndTime varchar(5)
)
insert the record in this table like this
INSERT INTO TimeCal values('07:30','08:30')
INSERT INTO TimeCal values('08:30','08:30')
INSERT INTO TimeCal values('09:30','10:30')
...........................................................
...........................................................
...........................................................
INSERT INTO TimeCal values('05:30','06:30')
INSERT INTO TimeCal values('06:30','07:30')
Then write your query like this
Regards,
Iftikar