I have a table with the following columns: DATE, TICKER, and ID.
Essentially, what I am trying to do with the code below is select all of the ticker and its corresponding ID's (it can have multiple ID's). However, in the table, there are multiple entries where tickers can have the same ID, but fall under a different date, so in this case, I select the ID with the smallest date.
SELECT
MIN(DATE),
TICKER,
ID
FROM Names
GROUP BY
TICKER,
ID
WHERE TICKER IN ('A', 'B')
Now, when I try the commands independently, it works, but I believe something goes wrong when I combine the GROUP BY
and WHERE IN
commands together, as I get a syntax error.
Let me know if anything isn't clear, and I will try to clarify it.