I want to display some statistics to users that entered a command and I’m using to different SQL queries for that.
The first one:
SELECT COUNT(*) FROM guild_finished_giveaways WHERE guild_id = {} AND winner_id LIKE '%750718563651944518%'
I want to get the giveaway win count from this specific user on the specified guild.
But in the second query, I want the same, except for the specified guild. It should count all entries, like a "global" giveaway win count.
The second one:
SELECT COUNT(*) FROM guild_finished_giveaways winner_id LIKE '%750718563651944518%'
How can I combine them into only run one query? I need this solution to improve my code performance and reduce code.
2
Answers
You can use SUM() instead.
Use conditional aggregation:
or: