简体   繁体   中英

Calculate the number of occurrences of the text in Redshift

Calculate the number of occurrences of the text, “university”, anywhere in the "School" field for each day in the 15 day period between 2018-12-15 to 2018-12-31?

Can someone help me with this query? I am working on a redshift environment.

You haven't supplied any information about the table, but the query would probably be similar to this:

SELECT
  date_field,
  COUNT(*) as qty
FROM table
WHERE
  school ILIKE '%university%' AND
  date_field BETWEEN '2018-12-15' AND '2018-12-31'
GROUP BY date_field
ORDER BY date_field

This counts the number of rows containing a case-insensitive university where a date field is between the indicated dates. This assumes that date_field is a DATE , not a TIMESTAMP .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM