Jump to content

Query Get Max And Min With Two Situation Same And Different Date


newphpcoder

Recommended Posts

Hi..I know its a couple of weeks that i have problem in datetime..For example i have this data:00100 2011-11-20 05:35:0000100 2011-11-20 13:35:0000100 2011-11-21 21:35:0000100 2011-11-22 05:35:00when I tried this query for testing:

SELECT a.EMP_NO, max(a.DTR), min(b.DTR) FROM regular_dtr a LEFT JOIN regular_dtr b ON a.EMP_NO = b.EMP_NO;

i have this output:EMP_NO--max_dtr------------------min_dtr00100----2011-11-22 05:35:00-----2011-11-20 05:35:00i need result is:EMP_NO--max_dtr------------------min_dtr00100----2011-11-20 13:35:00-----2011-11-20 05:35:0000100----2011-11-22 05:35:00-----2011-11-21 21:35:00I really, don't know what syntax should i need..I'm sorry if until now, I did not solve this:(Any help is highly appreciated..Thank you so much...i hope you would not angry with me...the reason why i post again this problem because now i only have two columns, EMP_NO and DTR(IN and OUT) and i have no right to demand to separate the data of in and out...so that in my part I need to do that but sad to say, I have only few knowledge in mysql..specially in functions.

Link to comment
Share on other sites

I don't think you can get a result like that in SQL, it's not clear to the database which dates are supposed to match with each other with a structure like that. If you can't change the table structure then you'll need to get all of the data and process it with another language.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...