简体   繁体   English

table1.date1 = 从雅典娜的 table2.monthyear 中的 date1 获取前 12 个月的数据? 如何在年月中获取 12 个月之前的数据?

[英]table1.date1 = get prior 12 months data from date1 in table2.monthyear in Athena? how to get 12 months prior data in year month?

select 
   amt1,
   amt2 
from table2 
inner join table1 on table1.field1 = table2.field2 
        and table2.month_year between (substring(table1.date1,1,6) -12 month)
SELECT
    amt1,
    amt2
FROM    Table2      AS t2
INNER JOIN Table1 AS t1
    ON t1.Field1 = t2.Field2
    AND SUBSTRING(t1.DATE1, 1, 6) BETWEEN LEFT(t2.month_year, 4) + CAST(CAST(RIGHT(t2.month_year, 2) AS int) - 12 AS varchar(2)) AND t2.month_year;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何获得特定月份但动态年份的 Trailing 12 Months? - How do I get Trailing 12 Months for a specific month but dynamic year? 如何运行查询以获取过去 12 个月的结果 (BigQuery) - How to run a query to get results of last 12 months ( BigQuery) 从存储帐户的年/月/日目录中获取所有文件时,如何将修改日期作为表中的列获取? - How to get modified date as column in table while ingesting all files from year/month/date directories of storage account? 如何在 Athena 中按月和年过滤数据? - How to filter data by month and year in Athena? Airflow:如何获取数据插入BigQuery表的当前日期? - Airflow: How to get the current date of when data is inserted into a BigQuery table? 使用 s3 存储桶从雅典娜表中获取没有时间的日期 - get date without time from athena table using s3 bucket 12个月的滚动数据 - Rolling data for 12 month period 从 BigQuery 中的先前 WITH 子句创建表 - Creating a table from a prior WITH clause in BigQuery 我如何在 flutter 中获取日期月份年份值 - how i get date month year values in flutter 大查询——获取一年中每个月的最后日期 - Big query- get last date of every month in a year
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM