vendredi 11 septembre 2015

SQL WHERE with multiple conditions: shortcut?

I'm trying to find an average temperature on days that are Saturday or Sunday using SQL. I realize a possible solution is:

SELECT avg(cast(meantempi as integer))
FROM weather_data
WHERE cast (strftime('%w', date) as integer) = 0 or 
      cast (strftime('%w', date) as integer) = 6

However, I am curious as to whether there is an optimal shortcut possible after my WHERE statement in this particular situation.

In other words, is there an equivalent to doing the preceding problem as:

SELECT avg(cast(meantempi as integer))
FROM weather_data
WHERE cast (strftime('%w', date) as integer) = 0 or 6

Aucun commentaire:

Enregistrer un commentaire