1

I'm trying to write subquery that use a value from parent query.

Like this:

SELECT
    e.id,
    e.name,
    (SELECT COUNT(ea.id)
     FROM employee_attendance ea
     WHERE ea.emp_id == e.id) AS attendance
FROM 
    employee e

Is there anyway to use this in SQLAlchemy subquery ?

3
  • 1
    Some DBMS's will allow what he is doing. I THINK Microsoft SQL Server will allow this. Commented Jul 11, 2019 at 10:27
  • is this returning an error? Why won't this work? If it returns an error, what is it? I'm not seeing the connection between your problem and python/sqlalchemy specifically. Commented Jul 11, 2019 at 10:47
  • @JoshuaSchlichting in this query employee id from parent query passing to subquey. is this possible in sqlalchemy subquery ? Commented Jul 11, 2019 at 11:32

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.