Write a query to return the top search term on new year's day: 2021-01-01
Table: search
col_name| col_type ----------+------------ country | varchar(2) date | date user_id | integer search_id | integer query | text
Sample results
top_search_term -------------------- Joe Biden
Expected results
Solution postgres
SELECT query FROM (
SELECT
query,
COUNT(*)
FROM search
WHERE date = '2021-01-01'
GROUP BY 1
ORDER BY 2 DESC
LIMIT 1
) X
Explanation
This query is selecting data from a table called "search" and is filtering for data that was recorded on January 1st, 2021. The query is then grouping the data by the "query" column and counting how many times each query appears. The results are then sorted in descending order by the count and the top result is selected (LIMIT 1).
Essentially, this query is finding the most searched query on January 1st, 2021 in the "search" table.
Copied
Your results