0

I need to use a concat function which has an argument returned by select query like this

CONCAT(classification_version.NAME,' ', (select x.NAME,min(DATEDIFF(e.SEND_DATE, x.OPTENTION_DATE)) AS DT_DIFF from classification_version x inner join classification_element y on x.id_project=y.ID_PROJECT inner join email e on x.id_project=e.ID_PROJECT_AMENDMENT where y.ID_PROJECT=project.id and y.ID_COMPANY=company.id and e.SEND_DATE>x.OPTENTION_DATE group by e.id,e.SEND_DATE order by e.SEND_DATE ASC) 

This is only a part of a query that I have. I need to return min(datediff) because I need the corresponding name value only. But it throws an error that Operand should contain 1 column(s). I cannot use inner queries for the select statement as project.id and company.id will not be available to me then. IS there any way to solve this?

2
  • This is only a part of a query that I have Do you really expect any effort on our part if this isn't the entire query? Commented Jul 31, 2015 at 4:57
  • 1
    if you can link a sqlfiddle here then you can get help quick also it will be helpful to others to understand your problem in better way. Commented Jul 31, 2015 at 4:57

1 Answer 1

2

I modified your SQL check it once.

SELECT CONCAT(q1.NAME,' ',DT_DIFF) FROM (SELECT x.NAME,MIN(DATEDIFF(e.SEND_DATE, x.OPTENTION_DATE)) AS DT_DIFF FROM classification_version x INNER JOIN classification_element y ON x.id_project=y.ID_PROJECT INNER JOIN email e ON x.id_project=e.ID_PROJECT_AMENDMENT WHERE y.ID_PROJECT=project.id AND y.ID_COMPANY=company.id AND e.SEND_DATE>x.OPTENTION_DATE GROUP BY e.id,e.SEND_DATE ORDER BY e.SEND_DATE ASC) AS q1 

Thank you.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.