Search code examples
sqlgoogle-sheetsgoogle-sheets-query

Date comparison in Query function not returning result


I am using the below query

=QUERY(fulldata,"select avg(C) where A<>'Saturday'")

My Data looks like -

+-----------+-----------+----+-----+-----+-----+-----+---+-----+-----+-----+-----+-----+
|     A     |     B     | C  |  D  |  E  |  F  |  G  | H |  I  |  J  |  K  |  L  |  M  |
+-----------+-----------+----+-----+-----+-----+-----+---+-----+-----+-----+-----+-----+
| Sunday    | 1- Jan-18 |  6 |  12 |   0 | 1.5 | 2.5 | 2 |   0 |   0 |   0 |   0 |   0 |
| Monday    | 2- Jan-18 |  6 |   0 | 9.5 |   4 |   0 | 0 |   0 | 2.5 |   2 |   0 |   0 |
| Tuesday   | 3- Jan-18 |  7 |   0 |   7 |   0 |   0 | 2 |   0 |   4 |   1 |   3 |   0 |
| Wednesday | 4- Jan-18 |  7 | 1.5 |   6 | 1.5 |   0 | 0 |   0 |   2 | 0.5 | 5.5 |   0 |
| Thursday  | 5- Jan-18 |  8 |   1 | 7.5 |   0 |   0 | 2 |   0 | 1.5 |   1 |   3 |   0 |
| Friday    | 6- Jan-18 | 14 |   6 |   0 |   0 |   0 | 2 |   0 | 1.5 | 0.5 |   0 |   0 |
| Saturday  | 7- Jan-18 |  9 | 0.5 |   0 | 0.5 | 1.5 | 2 | 3.5 | 4.5 | 0.5 | 1.5 | 0.5 |
+-----------+-----------+----+-----+-----+-----+-----+---+-----+-----+-----+-----+-----+

However I get no response from the query. The query runs without any issue but no results.

I simply want to find the average of C when A is not Saturday . Can anyone point where my query and/or logic is going wrong ?


Solution

  • I found the answer.

    My Day column was using =DAY(Col B) which was resulting into Sun, 31 Dec 99 but it was displaying it as Sunday because of the formatting done from toolbar.

    So when I was comparing it with Saturday/Sunday it wasn't matching and hence no results.