I am trying to pull store data for locations in the US and around the world.
select
s.store,
s.store_name,
s.store_city,
s.state,
st.description as "STATE_DESC",
s.country_id,
c.country_desc
from
store s,
country c
left join state st on st.state = s.state
where c.country_id = s.country_id
and s.store in ('123456', '654321')
I get:
ORA-00904: "S"."STATE": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Error at Line: 13 Column: 34
If I join the state table regularly, it only pulls up locations in the US and does not show NULL values in the state or state description column.
How do I join the state table?
store
columns:
STORE
STORE_NAME
STORE_CITY
STATE
COUNTRY_ID
state
columns:
STATE
DESCRIPTION
I want:
STORE | STORE_NAME | STORE_CITY | STATE | STATE_DESC | COUNTRY_ID | COUNTRY_DESC |
---|---|---|---|---|---|---|
123456 | DALLAS STORE | DALLAS | TX | Texas | US | United States |
654321 | GERMANY STORE | BERLIN | null | null | DE | Germany |
I ended up doing a VLOOKUP
to add the state description in Excel.