[英]How do I use label in this part of this query?
I am trying to figure out why I keep getting the same error when using label this way in this query.我试图弄清楚为什么在此查询中以这种方式使用 label 时会出现相同的错误。 I keep getting a syntax error.
我不断收到语法错误。
SELECT idint, elVal.idinterventovalore, concat(cast(elVal.idinterventovalore as varchar(5)) , '=' , valore as label, 1 like value) -- , elVal.IDInterventoRagg
FROM cch.pats_cch_interventi_valori val
INNER JOIN cch.pats_cch_interventielencovalori elVal ON val.idinterventoragg = elVal.idinterventoragg AND val.idinterventovalore = elVal.idinterventovalore
WHERE elVal.idinterventoragg like '%DiaValvulopatiaSede%' AND elVal.IDTipo='I'
ORDER BY idint, elVal.idinterventovalore;
--and this below is the source code that I am debugging-- --以下是我正在调试的源代码--
SELECT IDInt,
elVal.IDInterventoValore,
cast(elVal.IDInterventoValore as varchar(5)) + '=' + Valore as label,
1 as [value] -- , elVal.IDInterventoRagg
FROM AppManager_BI.PATS_CCH_Interventi_Valori val
INNER JOIN AppManager_BI.PATS_CCH_InterventiElencoValori elVal
ON val.IDInterventoRagg = elVal.IDInterventoRagg
AND val.IDInterventoValore = elVal.IDInterventoValore
WHERE elVal.IDInterventoRagg like 'DiaVasculopatiaPerifericaSede'
AND elVal.IDTipo='I'
ORDER BY IDInt, elVal.IDInterventoValore
Although I don't work on postgresql, but I understand that your use of alias inside concat
is invalid.虽然我不在 postgresql 上工作,但我知道你在
concat
中使用别名是无效的。 Try below code.试试下面的代码。
SELECT idint,
elVal.idinterventovalore,
concat(cast(elVal.idinterventovalore as varchar(5)) , '=' , valore, 1) -- , elVal.IDInterventoRagg
FROM cch.pats_cch_interventi_valori val
INNER JOIN cch.pats_cch_interventielencovalori elVal
ON val.idinterventoragg = elVal.idinterventoragg
AND val.idinterventovalore = elVal.idinterventovalore
WHERE elVal.idinterventoragg like '%DiaValvulopatiaSede%'
AND elVal.IDTipo='I'
ORDER BY idint,
elVal.idinterventovalore;
Hope this will help you.希望这会帮助你。
Given the original query (presumably T-SQL), you probably want:给定原始查询(可能是 T-SQL),您可能想要:
SELECT IDInt, elVal.IDInterventoValore,
concat(elVal.IDInterventoValore, '=', Valore) as label,
1 as value,
...
there is no need to cast the value when using concat()
使用
concat()
时无需转换值
If you want to properly deal with possible empty values in the two colums, concat_ws()
might be a better choice:如果您想正确处理两个列中可能的空值,
concat_ws()
可能是更好的选择:
SELECT IDInt, elVal.IDInterventoValore,
concat_ws('=', elVal.IDInterventoValore, Valore) as label,
1 as value,
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.