Question: Is my query right?
sscrewston opened this issue · 5 comments
sscrewston commented
I'm still fairly new to SQL, I used this query
SELECT
DISTINCT shot_chart_detail.id,
strftime('%m-%d-%Y') AS game_date,
game.game_id,
player_name,
shot_type,
event_type,
action_type,
period AS quarter,
minutes_remaining,
seconds_remaining
FROM game
INNER JOIN shot_chart_detail
ON game.game_id = shot_chart_detail.game_id
INNER JOIN player
ON shot_chart_detail.player_id = player.player_id
WHERE team_id = 1610612745
ORDER BY game_date DESC
However, when I retrieve that game_date
column I see dates from one day ahead, games that haven't even happened yet. What am I doing wrong?
mpope9 commented
Try selecting game.game_date instead of strftime.
sscrewston commented
game_date
was the alias I gave the strftime
. I used strftime
to extract the date value only from the date column because by default it is a string value in YYYY-MM-DDT00:00:00
format. In default format I can't sort the date properly so I'm trying to figure out a solution with my limited knowledge of SQL.
mpope9 commented
I think strftime returns the current date. You might want game.game_date, if you want a game's date.
mpope9 commented
Or maybe pass it to strftime. Like
strftime(format, game.game_date)
sscrewston commented
Okay, thank you. I’ll try that when I get a chance.
…On Fri, Nov 18, 2022 at 8:13 AM Matthew Pope ***@***.***> wrote:
Or maybe pass it to strftime. Like
strftime(format, game.game_date)
—
Reply to this email directly, view it on GitHub
<#84 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AZFVOKBBVGHPY2NEQZMNGT3WI6FG5ANCNFSM6AAAAAASED3PGI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>