Skip to content
Advertisement

Building Subquery to be a column/Field Name

I am unable to bundled groups of subqueries correctly in order to create column titled “Discharge_To”

I am using Teradata Studio Express. I was asked to create a column for field that is not inside a table we normally used. We want to know where a patient was discharged to from a previous place of service. In order to answer this, there has to be steps to determine that. So far, I can get it read correctly until line 94.

There should be 7 columns with the 7th column titled “Discharge_to” and values in the seventh column would be text (e.g., “Home without Care”)

Advertisement

Answer

Posting here, since it’s easier. Your query doesn’t seem to be formatted correctly. It’s of this form:

A couple notes:

  • There is no FROM clause in the outer query yet you are trying to return S. fields
  • There is no S result set to join your E result to
  • The E result set is trying to be used as a sub-SELECT, but it also has an alias

Not knowing what your error message is, I’d suggest breaking apart the query into its sub-queries and running those individually to try to determine where the problem lies.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement