sql for shares_count_cache field