Reputation: 469
I am trying to write a nested query:
Query(get all compensation for an Assignment where Assignment ID = query(Get Assignment ID for <Person Name>))
Sources Assignments and Compensations are on two different worksheets.
As new to Google's version of SQL, I am trying it step by step. Example file is here.
A14 contains query for getting the Assignment ID.
=query(Demographics!A1:AA316,"select B where I LIKE 'Christopher Lee' ORDER BY B LIMIT 1 ")
A18 - query to get all compensation using assignment id from cell A15 (result of query on A14)
=QUERY(Compensation!A2:F109012,"select sum(B) where year(C) = year(now()) - 4 and A = "&A15&" ")
On A21 - I am trying to replace reference to Cell A15 with query from A14.
QUERY(Compensation!A2:F109012,"select sum(B) where year(C) = year(now()) - 4 and A = "&query(Demographics!A1:AA316,"select B where I LIKE 'Christopher Lee' ORDER BY B LIMIT 1 ")&" ")
I get the error message:
Error Unable to parse query string for Function QUERY parameter 2: NO_COLUMN: Assignment_ID
Is it anything to do with the column header I get on my A14 query?
Your help is really appreciated.
Upvotes: 1
Views: 618
Reputation: 59475
I think we have been through this before. Please try:
=QUERY(Compensation!A2:F109012,"select sum(B) where year(C) = year(now()) - 4 and A = "&query(Demographics!A1:AA316,"select B where I LIKE 'Christopher Lee' ORDER BY B LIMIT 1 label(B) '' ")&" ")
Maybe only Google knows exactly why but it is the nature of QUERY that formatting Text or Number is significant (can't be mixed in a single field). With the Header you have a Text entry at the top - above a Number format record.
Upvotes: 1