I use Stack Exchange Data Explorer to learn SQL, but I think the basics of the question apply to other databases.
I am trying to query a table Badgesthat, according to Stexdex (what I'm going to call it now), has the following schema:
This works well for badges like [Epic]and [Legendary]that have unique names, but badges labeled silver and gold seem to mix together with the exact same name.
Here is an example of the query I wrote for the tag [mysql]:
SELECT
UserId as [User Link],
Date
FROM
Badges
Where
Name = 'mysql'
Order By
Date ASC
Output (slightly annotated): as shown on stexdex :
User Link Date
--------------- ------------------- // all for silver except where noted
Bill Karwin 2009-02-20 11:00:25
Quassnoi 2009-06-01 10:00:16
Greg 2009-10-22 10:00:25
Quassnoi 2009-10-31 10:00:24 // for gold
Bill Karwin 2009-11-23 11:00:30 // for gold
cletus 2010-01-01 11:00:23
OMG Ponies 2010-01-03 11:00:48
Pascal MARTIN 2010-02-17 11:00:29
Mark Byers 2010-04-07 10:00:35
Daniel Vassallo 2010-05-14 10:00:38
, , 2010 2 [mysql]: Quassnoi Bill Karwin, , , .
, :
. :
- //, ?
- , ?
GROUP BY Id - min/max first/second Date?- , , ?
- , ?
- ? "" , "" - ?
, :
User Link Date
--------------- -------------------
Bill Karwin 2009-02-20 11:00:25
Quassnoi 2009-06-01 10:00:16
Greg 2009-10-22 10:00:25
cletus 2010-01-01 11:00:23
OMG Ponies 2010-01-03 11:00:48
Pascal MARTIN 2010-02-17 11:00:29
Mark Byers 2010-04-07 10:00:35
Daniel Vassallo 2010-05-14 10:00:38
------- maybe some sort of row separator here? can SQL do this? -------
Quassnoi 2009-10-31 10:00:24
Bill Karwin 2009-11-23 11:00:30
, . , .