Linked Questions

Popular Questions

i have rows, in a table, which have dates where a patient got infected by a virus, and when she was healed. I also have in a column, the virus id, which is a foreign key, and points to another table, where the name of the virus is stored What i have come up with so far:

SELECT myColumns
FROM myTable
WHERE dateColumn BETWEEN '2018-01-01' AND '2018-12-31';

the datecolumn has the date stored like:

patient infected date
2002-01-22 13:25:41
patient healed date
2002-01-24 10:35:21

What i try to do, is have the say 100 most usually seen viruses, that had infected and were healed in the same year, along their titles.

something like (order by the number of occurrences)

virus1 | name of the virus | number of occurrences 
virus2 | name of the virus | number of occurrences 

How the above query should become?

The table that has the patient data, along with the virus id:

Column  Type    Comment
dateInfected    datetime NULL    
dateHealed  datetime NULL    
idOfVirus   bigint(20) NULL 

the table that has the name of the virus:

Column  Type    Comment
id  bigint(20)   
virusName   text NULL

Related Questions