title: Frequency Histogram in Clickhouse with unique and non unique data
body: <p>I have a event table with created_at(DateTime), userid(String), eventid(String) column. Here userid can be repetitive while eventid is always unique uuid. </p>
  
  <p>I am looking to build both unique and non unique frequency histogram.</p>
  
  <p>This is for both eventid and userid on basis of given three input </p>
  
  <ol>
  <li>start_datetime </li>
  <li>end_datetime and</li>
  <li>interval (1 min, 1 hr, 1 day, 7 day, 1 month).</li>
  </ol>
  
  <p>Here, bucket will be decided by (end_datetime - start_datetime)/interval. </p>
  
  <p>Output comes as start_datetime, end_datetime and frequency. 
  For any interval, if data is not available then start_datetime and  end_datetime comes but with frequency as 0.</p>
  
  <p>How can I build a generic query for this?</p>
  
  <p>I looked in histogram function but could not find any documentation for this. While trying it, i could not understand relation behind the input and output.</p>