我正在尝试UNION ALL
加入两个数据库查询结果。这是我的查询
SELECT taxrec.* FROM (
SELECT taxrec.* FROM fa_244.0_trans_tax_details AS taxrec WHERE (taxrec.amount <> 0 OR taxrec.net_amount <> 0) AND !ISNULL(taxrec.reg_type) AND taxrec.tran_date >= '2014-03-03' AND taxrec.tran_date <= '2018-03-31'
union all
SELECT taxrec.* FROM fa_244.1_trans_tax_details AS taxrec WHERE (taxrec.amount <> 0 OR taxrec.net_amount <> 0) AND !ISNULL(taxrec.reg_type) AND taxrec.tran_date >= '2014-03-03' AND taxrec.tran_date <= '2018-03-31'
ORDER BY taxrec.trans_type, taxrec.tran_date, taxrec.trans_no, taxrec.ex_rate ) a
但它显示错误。任何帮助解决问题。 #1250表'taxrec'
回答:
我找到了这个问题的答案。问题是我们不能在主查询中使用Alias,因为它们仅用于子查询。 这是问题的解决方案。
SELECT * FROM (
SELECT taxrec.* FROM fa_244.0_trans_tax_details AS taxrec WHERE (taxrec.amount <> 0 OR taxrec.net_amount <> 0) AND !ISNULL(taxrec.reg_type) AND taxrec.tran_date >= '2014-03-03' AND taxrec.tran_date <= '2018-03-31'
union all
SELECT taxrec.* FROM fa_244.1_trans_tax_details AS taxrec WHERE (taxrec.amount <> 0 OR taxrec.net_amount <> 0) AND !ISNULL(taxrec.reg_type) AND taxrec.tran_date >= '2014-03-03' AND taxrec.tran_date <= '2018-03-31'
ORDER BY trans_type, tran_date, trans_no, ex_rate ) a
就是这样。
答案 0 :(得分:0)
已移出问题:
我找到了这个问题的答案。问题是我们不能在主查询中使用别名,因为这些别名仅在子查询中使用。 这是解决问题的方法。
const XLSX = require("xlsx");
function readXls(path) {
let values = [];
try {
let wb = null;
wb = XLSX.readFile(buffer);
let ws = wb.Sheets[wb.SheetNames[0]];
let range = XLSX.utils.decode_range(ws["!ref"]).e.r;
if (range) {
let rows = XLSX.utils.sheet_to_json(ws, {
header: "A",
raw: false,
range: `A1:ZZ${range+1}`,
dateNF: "YYYY-MM-DD"
});
// here you can compute each row
return rows
}
} catch (error) {
console.log(error);
}
}
就是这样。