Reputation: 11
I am currently working on Tableau software and need to do a custom SQL query.
I currently have two tables, each of them being the result of an SQL query.
TABLE 1:
Select *
from AA
left join BB on AA.id = BB.id
TABLE 2:
Select *
from CC
inner join DD on CC.brandId=DD.brandId
where CC.Year between year(getdate())-4 and year(getdate())
and CC.productCategoryId = 'Category 1')
I would like to do a query which is:
FINAL QUERY:
Select *
from TABLE 1
LEFT JOIN Table 2 on AA.id = CC.id (both have id)
But I does not work. SQL Management server is giving me an error on the LEFT JOIN of the final query and I don't understand why... It's like it is not letting me create the left join (both requests for Table 1 and 2 work fine, it is adding them up which does not work).
Any idea?? :) Thank you in advance!
Upvotes: 0
Views: 219
Reputation: 90
Now that you put the results from AA into a new Table named Table 1, and likewise from CC to Table 2, it does not make sense to query for AA.id=CC.id. Try domething like [Table 1].id=[Table 2].id
Upvotes: 1