# how to get the distinct value of a column from the dbt model temp staging tables

**URL:** <https://discourse.getdbt.com/t/how-to-get-the-distinct-value-of-a-column-from-the-dbt-model-temp-staging-tables/11290>\
**Category:** In-Depth Discussions\
**Created:** [December 21, 2023, 8:14pm UTC](https://discourse.getdbt.com/t/how-to-get-the-distinct-value-of-a-column-from-the-dbt-model-temp-staging-tables/11290 "2023-12-21T20:14:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vikasvimal](https://avatars.discourse-cdn.com/v4/letter/v/71e660/32.png) [@vikasvimal](https://discourse.getdbt.com/u/vikasvimal)\
**Post date:** [December 21, 2023, 8:14pm UTC](https://discourse.getdbt.com/t/how-to-get-the-distinct-value-of-a-column-from-the-dbt-model-temp-staging-tables/11290/1 "2023-12-21T20:14:18Z")

</div>

Hi Team,  
Problem statement :  
I have a dbt model which reads data from the source, performs the aggregation, and loads to a physical target table.

Granularity of source data = Daily (Field - dt, Values - 2023-01-01, 2023-01-02,…, 2023-12-01, 2023-12-02, 2023-12-03)  
Granularity of target data = Monthly (Field - month, values - 2023-Jan, 2023-Feb, 2023-Mar, —, 2023-Nov, 2023-Dec)

I am triggering the dbt model via python, and when the dbt model completes, I want to get the month values generated to the python. I don’t want to scan the entire target table to find these values.

Since dbt creates a \_\_dbt\_\_tmp staging table, is it possible to write a jinja code or macro to query the \_\_dbt\_\_tmp table and get the values outside to python

any other suggestion?
