SQLite Forum

How to address a variable within a WITH statement
Login
Greetings.

I have this WITH Statement,
```
WITH LastEntries (ProjID, ml_insert)
AS
(
   SELECT 'PR0000019191' AS PID,
   (
        SELECT max(insertdate) FROM Project_Keytask_and_Milestones where projid = 'PR0000019191'
   )
) 
SELECT ProjID, ml_insert from LastEntries;
```

Which works, but I would like to use the first value like this,

```
WITH LastEntries (ProjID, ml_insert)
AS
(
   SELECT 'PR0000019191' AS PID,
   (
        SELECT max(insertdate) FROM Project_Keytask_and_Milestones where projid = PID
   )
) 
SELECT ProjID, ml_insert from LastEntries;
```

But, it does not work.  Any way to do this, or do I have to use the value? Thanks.

josé