SQL Challenges-1: Writers who rated more than one topics on the same date
From the following table write a SQL query to find all the writers who rated more than one topics on the same date, sorted in ascending order by their id. Return writr ID.
Input:
Table: topics
Structure:
Field | Type | Null | Key | Default | Extra |
---|---|---|---|---|---|
topic_id | int(11) | YES | |||
writer_id | int(11) | YES | |||
rated_by | int(11) | YES | |||
date_of_rating | date | YES |
Data:
topic_id | writer_id | rated_by | date_of_rating |
---|---|---|---|
10001 | 504 | 507 | 2020-07-17 |
10003 | 502 | 503 | 2020-09-22 |
10001 | 503 | 507 | 2020-12-23 |
10002 | 501 | 507 | 2020-07-17 |
10002 | 502 | 502 | 2020-04-10 |
10002 | 504 | 502 | 2020-11-16 |
10003 | 501 | 502 | 2020-04-10 |
10001 | 507 | 507 | 2020-12-23 |
10004 | 503 | 501 | 2020-08-28 |
10003 | 505 | 504 | 2020-12-21 |
Sample Solution:
SQL Code(MySQL):
Sample Output:
Topic rated by the writer| -------------------------| 502| 507|
SQL Code Editor:
Contribute your code and comments through Disqus.
Previous: Find all the writers who rated at least one of their own topic.
Next: Sale quantity of each quarter for a product.