views:

153

answers:

1

I have a database of users and a database of cards. The users see the cards repeatedly.

I kept a record of every time the users saw the cards and how long they looked at the card.

Now that I've got that data, I want to analyze it by considering the first time that each user looked at each card.

I got a list of the average msToAnswer for each card from this code:

SELECT  `username`,  AVG( `msToAnswer`)
FROM  `usercardinfo` 
WHERE `timeStamp` between '2009-04-01' and '2009-06-01'
GROUP BY  `username`

Now I need a list of the earliest msToAnswer for each card. Each card has a distinct name.

A: 

You didn't post the names of your columns, so I'll have to make them up:

SELECT  `username`, `card_id`, MIN(`timeStamp`)
FROM    `usercardinfo` 
WHERE   `timeStamp` between '2009-04-01' and '2009-06-01'
GROUP BY
        `username`, `card_id`
Quassnoi