title: subrequest in case return error on clickhouse
body: <p>So i try a make a view , actually this is my code : </p>
  
  <pre class="lang-sql prettyprint-override"><code>drop table if exists computed_datum_hours_base;
  create view computed_datum_hours_base
  as select
      toStartOfHour(datetime_value) as datetime_desc,
      computed_id,
      computed_kind,
      computed_type,
      case
          when computed_type = 'intensive' then avg(value)
          when computed_type = 'extensive.some' then sum(value)
          when computed_type = 'extensive.differential' then
              (
                  select value as value_f from ref_computed_datum
                  where ref_computed_id = computed_id
                  and ref_computed_kind = computed_kind
                  and ref_computed_type = computed_type
                  and ref_datetime_value = toStartOfHour(addHours(datetime_value, 1))
              ) - (
                  select value as value_f from ref_computed_datum
                  where ref_computed_id = computed_id
                  and ref_computed_kind = computed_kind
                  and ref_computed_type = computed_type
                  and ref_datetime_value = toStartOfHour(datetime_value)
              )
      end as value,
      count(uuid) as nb_value
  from computed_datum
      join ref_computed_datum
      on computed_id = ref_computed_id
      and computed_kind = ref_computed_kind
      and computed_type = ref_computed_type
      where uuid = ref_uuid
  group by
      computed_id,
      computed_kind,
      computed_type,
      toStartOfHour(datetime_value)
  ;
  </code></pre>
  
  <p>my issue is on the case for extensive.differential ...
  clickhouse say he can found the column for computed_id ... like the subrequest is scoped and didn't have access to the colum from the main requeste ...</p>
  
  <p>So this is another bug of clickhouse ?
  Or there are a reel scope and i can't do this like this ...
  ( so How can do this ? )</p>
  
  <p>Edit: full error </p>
  
  <pre><code>Code: 47, e.displayText() = DB::Exception: Missing columns: 'datetime_value' 'computed_kind' 'computed_type' 'computed_id' 'value' while processing query: 'SELECT value AS value_f FROM api_client.ref_computed_datum WHERE (ref_computed_id = computed_id) AND (ref_computed_kind = computed_kind) AND (ref_computed_type = computed_type) AND (ref_datetime_value = toStartOfHour(addHours(datetime_value, 1)))', required columns: 'value' 'computed_id' 'ref_computed_id' 'ref_computed_kind' 'computed_type' 'ref_computed_type' 'computed_kind' 'ref_datetime_value' 'datetime_value', source columns: 'ref_flags' 'ref_computed_kind' 'ref_computed_id' 'ref_datetime_value' 'ref_computed_type' 'ref_EventDateTime' 'ref_insert' 'ref_value' 'ref_uuid' (version 20.4.2.9 (official build))
  </code></pre>
  
  <p>computed_datum folow this structure : </p>
  
  <pre><code>                EventDateTime  DateTime default now(),
                  insert         String,
                  uuid           String default generateUUIDv4(),
                  datetime_value DateTime,
                  computed_id    Int32,
                  computed_kind  String,
                  computed_type  String,
                  value          Float64,
                  flags          String
      ```
  
  I make a ref view that only prefix all colum with ref_ for making a walkaround about the alias bug.
  
  </code></pre>