Sql query two first rows group by userId : <p>I have the data like this</p>

<pre><code>deviceId | userId | Time
20       | 1      | 2-Jan-18
21       | 1      | 2-Jan-19
22       | 1      | 2-Jan-10
30       | 2      | 2-Jan-18
30       | 2      | 2-Jan-19
</code></pre>

<p>I would like to query 2 first devices that the user uses and also the time (group by userId)</p>

<pre><code>userId|firstDeviceId|firstDeviceTime|secondDeviceId|secondDeviceTime
1     |20           | 2-Jan-18      | 21           | 2-Jan-19
2     |30           | 2-Jan-18      | 30           | 2-Jan-19
</code></pre>

<p>Could you guys show me the way to do it? Thanks</p>
