我在Access
中有这个咨询 document.getElementById(shortname).addEventListener('click', function() {
copyToClipboardMsg(document.getElementById('$id'), 'msg');
});
function copyToClipboardMsg(elem, msgElem) {
var succeed = copyToClipboard(elem);
var msg;
if (!succeed) {
msg = 'Copy not supported or blocked. Press Ctrl+c to copy.'
} else {
msg = 'Text copied to the clipboard.'
}
if (typeof msgElem === 'string') {
msgElem = document.getElementById(msgElem);
}
msgElem.innerHTML = msg;
setTimeout(function() {
msgElem.innerHTML = '';
}, 2000);
}
function copyToClipboard(elem) {
// create hidden text element, if it doesn't already exist
var targetId = '_hiddenCopyText_';
var isInput = elem.tagName === 'INPUT' || elem.tagName === 'TEXTAREA';
var origSelectionStart, origSelectionEnd;
if (isInput) {
// can just use the original source element for the selection and copy
target = elem;
origSelectionStart = elem.selectionStart;
origSelectionEnd = elem.selectionEnd;
} else {
// must use a temporary form element for the selection and copy
target = document.getElementById(targetId);
if (!target) {
var target = document.createElement('textarea');
target.style.position = 'absolute';
target.style.left = '-9999px';
target.style.top = '0';
target.id = targetId;
document.body.appendChild(target);
}
target.textContent = elem.textContent;
}
// select the content
var currentFocus = document.activeElement;
target.focus();
target.setSelectionRange(0, target.value.length);
// copy the selection
var succeed;
try {
succeed = document.execCommand('copy');
} catch(e) {
succeed = false;
}
// restore original focus
if (currentFocus && typeof currentFocus.focus === 'function') {
currentFocus.focus();
}
if (isInput) {
// restore prior selection
elem.setSelectionRange(origSelectionStart, origSelectionEnd);
} else {
// clear temporary content
target.textContent = '';
}
return succeed;
}
这里的一切都很好我得到了我想要的东西,但现在我需要在咨询SELECT CREDITOS.Id AS [Num Credito], CREDITOS.CLIENTE AS [Cedula Cliente],
CLIENTES.NOMBRES AS [Nombres Cliente], CLIENTES.APELLIDOS AS [Apellidos Cliente],
CREDITOS.FECHA_INICIAL AS [Fecha Inicial], CREDITOS.FECHA_FINAL AS [Fecha Final],
CREDITOS.CONCEPTO AS [Concepto], CREDITOS.VALOR_CREDITO AS [Valor],
CREDITOS.NUMERO_CUOTAS AS [Numero Cuotas], CREDITOS.MONTO AS [Monto],
CREDITOS.PORCENTAJE AS [Porcentaje], CREDITOS.UTILIDAD AS [Utilidad],
CREDITOS.VALOR_CUOTAS AS [Valor Cuotas], CREDITOS.EMPLEADO AS [Cedula Empleado],
EMPLEADOS.NOMBRES AS [Nombres Empleado], EMPLEADOS.APELLIDOS AS [Apellidos Empleado],
Nz(t.Conteo,0) AS [Días de retraso]
FROM (CLIENTES
INNER JOIN (EMPLEADOS
INNER JOIN (CREDITOS
LEFT JOIN (
SELECT CREDITOS.Id AS Cred, Count(RECAUDOS.Id) AS Conteo
FROM CREDITOS
INNER JOIN RECAUDOS
ON(CREDITOS.Id = RECAUDOS.CREDITO
AND CREDITOS.VALOR_CUOTAS = RECAUDOS.SALDO)
GROUP BY CREDITOS.Id
) AS t
ON CREDITOS.Id = t.Cred)
ON EMPLEADOS.ID = CREDITOS.EMPLEADO)
ON CLIENTES.Id = CREDITOS.CLIENTE)
中添加一个列,但是当我在第一个SUM(RECAUDOS.VALOR_RECAUDO)
之前添加该列时,我得到了错误{ {1}}。我认为这个问题是因为FROM
Your query does not include the specified expression 'Num Credito' as part of an aggregate function
INNER JOIN
,但是我需要计算表格RECAUDOS
中符合此条件{{1}的记录},但是现在我需要每个ON(CREDITOS.Id = RECAUDOS.CREDITO AND CREDITOS.VALOR_CUOTAS = RECAUDOS.SALDO)
的所有RECAUDOS
的总和,即使这个总数为零,请我真的需要帮助
答案 0 :(得分:1)
只需将新聚合添加到派生表(JOIN
子句中的嵌套LEFT JOIN (
SELECT CREDITOS.Id AS Cred, Count(RECAUDOS.Id) AS Conteo,
SUM(RECAUDOS.VALOR_RECAUDO) AS new_field
FROM CREDITOS INNER JOIN RECAUDOS ON(CREDITOS.Id = RECAUDOS.CREDITO
AND CREDITOS.VALOR_CUOTAS = RECAUDOS.SALDO)
GROUP BY CREDITOS.Id
) AS t
查询),然后在外部主查询中引用它,就像使用 t.Conteo :
/opt/rbenv/plugins/ruby-build/share/ruby-build/<ruby-version>
答案 1 :(得分:0)
对于这个解决方案,对Parfait gime的一个好主意,问题在于子查询,最准确的是在INNER JOIN... ON(CREDITOS.Id = RECAUDOS.CREDITO AND CREDITOS.VALOR_CUOTAS = RECAUDOS.SALDO)
Sum(RECAUDOS.VALOR_RECAUDO)
的条件下我不知道为什么给我所有的零这些行,但我认为对于所有与INNER JOIN
中的条件不匹配的值,由于obius原因而给我null ...所以,我以这种方式离开JOIN INNER JOIN... ON(CREDITOS.Id = RECAUDOS.CREDITO)
现在{{1做他的工作,问题是SUM()
,我需要条件COUNT()
来计算,如果我为JOIN CREDITOS.VALOR_CUOTAS = RECAUDOS.SALDO
删除它们将“计算”所有行在COUNT()
中(没有条件),所以我设想了这个this,所以我将RECAUDOS
替换为Count(RECAUDOS.Id)
,现在一切都在轨道上,最后的咨询是这样的:
Count(IIf(CREDITOS.VALOR_CUOTAS = RECAUDOS.SALDO, 1, Null))