tags:

views:

35

answers:

1

Question is already posted on June 4, but still am not get the Proper answer

Again

Table Structure:

T_Person – Table 1

CARDNO 

168 
471 
488 
247 
519 
518 
331 
240 
518 
386 
441 
331

T_Cardevent – Table 2

CARDEVENTDATE CARDEVENTTIME 

20090225 163932
20090225 164630
20090225 165027
20090225 165137
20090225 165147
20090225 165715
20090225 165749
20090303 162059
20090303 162723
20090303 155029
20090303 155707
20090303 162824

Query

SELECT CARDNO,  CARDEVENTDATE, (1000000 * CAST (CARDEVENTDATE AS BIGINT) + CAST (CARDEVENTTIME AS BIGINT) - 30001) / 1000000 AS CardEvenDateAdjusted, CARDEVENTTIME
FROM T_CARDEVENT
WHERE (CARDEVENTDATE > 20090601)
GROUP BY CARDNO, CARDEVENTDATE, CARDEVENTTIME, (1000000 * CAST(CARDEVENTDATE AS BIGINT) + CAST(CARDEVENTTIME AS BIGINT) - 30001) / 1000000
ORDER BY CARDNO, CARDEVENDATEADJUSTED

From this above query date is displaying correctly according to that time 03:00:01 to 03:00:00

How can I get min (time) and Max (time) for the adjusted date?

I need the sql query for the above condition. Help me? Urgent Please

A: 

If you want the MIN/MAX from all the CARDEVENTTIME values :

SELECT MIN(CARDEVENTTIME)
     , MAX(CARDEVENTTIME)
  FROM T_Cardevent

Result :

MIN_CARDEVENTTIME MAX_CARDEVENTTIME
----------------- -----------------
155029            165749

or if you want them sorted by CARDEVENTDATE :

SELECT CARDEVENTDATE
     , MIN(CARDEVENTTIME) AS MIN_CARDEVENTTIME
     , MAX(CARDEVENTTIME) AS MAX_CARDEVENTTIME
  FROM T_Cardevent
 GROUP BY CARDEVENTDATE

Result :

CARDEVENTDATE MIN_CARDEVENTTIME MAX_CARDEVENTTIME
------------- ----------------- -----------------
20090225      163932            165749
20090303      155029            162824
Adrian S.