P
P
Pavel Ivanov2014-09-22 13:08:50
PostgreSQL
Pavel Ivanov, 2014-09-22 13:08:50

How to check id from alias?

Good afternoon!
I have this request:

(SELECT
    T0.ID ID,
    T0.ClientID client_id,
    T0.ClassID ClassID,
    T0.SeniorID SeniorID,
    T0.DNumber DNumber,
    (SELECT
        NotEmptyStr(SO1.fullName, SO1.name) FullName$
    FROM
        ActivityDirections SO1
    WHERE
      SO1.ID = T0.ActivityDirection) AutoAlias_10750549,
    (SELECT
    SO1.ID id_type
    FROM
       ActivityDirections SO1
    WHERE SO1.ID = T0.ActivityDirection
  ) typeid
.....

There is an alias typeid that I want to check in the WHERE clause:
WHERE BLABLABLA AND typtid.id_type IN (192922, 19333, 2323)

But I can't do it, because according to the SQL standard, aliases cannot be included in the WHERE field.
I need to check SO1.ID in the main TO request. How to do it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question