Request JPA with date and join

i have 2 tables : man and Entrance .

[man]

+------+-------+
| id   | name  |
+------+-------+
| 1    | man1  |
| 2    | man2  |
+------+-------+ 

[Entrance]

+------+--------------------------+-------+
| id   |         date             | idman |
+------+--------------------------+-------+
| 1    | 2008-10-29 14:56:59      |   1   |
| 2    | 2008-10-29 14:56:59      |   2   |
| 3    | 2008-10-29 17:56:59      |   2   |
| 4    | 2008-10-30 14:56:59      |   2   |
+------+--------------------------+-------+ 

[result]


+----------------+-------+
| count entrance | name  |
+----------------+-------+
| 1              | man1  |
| 2              | man2  |
+----------------+-------+ 

The man2 have than 2 because 2 entrance are on the same day. Can you help me for pour Requette jpa make this?

Thanks you for your help .

Answers


is it what you're expecting?

SELECT max(t1.count_by_id), m.name, FROM (  
   SELECT id, cast(date as date) as cdate, count(*) as count_by_id
   FROM entrance    
   GROUP BY cdate, id) as t1 
INNER JOIN man m ON (t1.id = m.id) 
GROUP BY t1.id;

Need Your Help

CinternetSession: Strange behavior when connecting

c++ visual-studio-2010 mfc proxy network-programming

It should be added to the project check the validity of proxy servers. The algorithm works is simple:

When you make a file read-only via Properties, can your program write directly to that file?

c++ windows file readonly

I'm wondering whether making files read-only so the user can't mess with them will disallow my program from writing information to them via an fstream.