SQLite query gives 'no such column' scenarios when using CTE with UNION
I've spent hours debugging this and I'm performance testing and I've been working on this all day and Does anyone know how to I'm working on a project and hit a roadblock... I'm trying to run a query in SQLite that uses a Common Table Expression (CTE) to combine results from two different tables. The goal is to pull data from both tables and apply some transformations before merging them. However, I'm working with a 'no such column' behavior when I reference a column in the CTE. Hereβs the SQL code Iβm using: ```sql WITH combined_data AS ( SELECT id, name, created_at FROM users UNION ALL SELECT user_id AS id, user_name AS name, registration_date AS created_at FROM registrations ) SELECT id, name, strftime('%Y-%m-%d', created_at) AS formatted_date FROM combined_data; ``` The behavior message I receive is: ``` behavior: no such column: user_name ``` I've double-checked the column names in both tables, and they do exist. The `registrations` table has a `user_id` and a `user_name`, and the `users` table has the corresponding `id` and `name`. I even tried running the subqueries independently, and they work perfectly fine. Is there something Iβm missing with the way I'm referencing the columns in the CTE? I'm using SQLite version 3.36.0. Any insights into why this behavior occurs would be much appreciated! I'm working on a application that needs to handle this. I'm using Sql 3.9 in this project. This is my first time working with Sql latest. Thanks for your help in advance! Any feedback is welcome!