sql - How to select the nth column, and order columns' selection in BigQuery
问题描述
I have this huge table upon which I apply a lot of processing (using CTEs), and I want to perform a UNION ALL on 2 particular CTEs.
SELECT *
, 0 AS orders
, 0 AS revenue
, 0 AS units
FROM secondary_prep_cte WHERE purchase_event_flag IS FALSE
UNION ALL
SELECT *
FROM results_orders_and_revenues_cte
I get a "Column 1164 in UNION ALL has incompatible types : STRING,DATE at [97:5]
Obviously I don't know the name of the column, and I'd like to debug this but I feel like I'm going to waste a lot of time if I can't pin-point which column is 1164. I also think this is a problem of the order of columns between the CTEs, so I have 2 questions:
- How do I identify the 1164th column
- How do I order my columns before performing the UNION ALL
I found this similar question but it is for MSSQL, I am using BigQuery
解决方案
推荐阅读
- javascript - 从 Angular 5 下载 spring boot rest services 的文件
- angularjs - 使用角度方式删除行时,角度数据表消失
- datetime - 在 ElasticSearch 中以微秒格式保存日期
- python - Is there any way to make a timeseries scatterplot with array sizing in Matplotlib?
- ios - 聊天信使 UITableViewCell,正在加载消息
- python-3.x - 多处理中的 Google Stackdriver 不起作用
- android - 与模拟器相比,毕加索在真实设备中加载图像需要花费太多时间
- amazon-web-services - 如何在 AWS Cost Explorer 中发送每月保存的报告
- javascript - Show datetimepicker last 6 days 也知道如何动态删除文本框
- c# - 实体框架在 SQL 中加密数据和解密