0

I have two tables:

Players

Player_id
email_address
highest_level

Login

login_id
ip_address
player_id
login_date
login_time

I'm looking to count the number of distinct logins per player, but only for login date 2014-06-01 and only for player email addresses ending in .net.

I know how to do these things individually, but I'm struggling to put it all together. I'm stuck between using JOIN or IN and how exactly to set it up. Any help would be appreciated.

newfurniturey
  • 37,556
  • 9
  • 94
  • 102
PVic
  • 417
  • 1
  • 4
  • 13
  • This sounds like a homework assignment. Have you attempted anything? – Siyual Jul 11 '14 at 14:09
  • Yes, I just couldn't remember how to do the JOIN. I knew the WHERE email LIKE '*.net', filtering the dates WHERE login_date = '2014-06-01', and to count(*). I just needed refreshing my memory on joins. – PVic Jul 11 '14 at 14:51

1 Answers1

0

You can try this,

SELECT p.Player_id,COUNT(*) FROM PLAYERS p
INNER JOIN LOGIN l ON p.Player_id = l.Player_id
WHERE l.login_date = '2014-06-01' AND l.email_address LIKE '%.net'
GROUP BY p.Player_id

Sorry, i forget group by.. now i added.

Serkan Algül
  • 93
  • 1
  • 7