我对下面创建的sql查询有点困惑:
SELECT CASE
WHEN (SELECT TOP 1 CAST(DAJ_KLASIFIKASI AS VARCHAR(25)) FROM BATM112_RKDKLASIFIKASI WHERE DAJ_NODAFTAR = D.DAJ_NODAFTAR ORDER BY DAJ_TKHDE DESC) IS NULL
THEN 'Tidak Diketahui'
ELSE (SELECT TOP 1 CAST(DAJ_KLASIFIKASI AS VARCHAR(25)) FROM BATM112_RKDKLASIFIKASI WHERE DAJ_NODAFTAR = D.DAJ_NODAFTAR ORDER BY DAJ_TKHDE DESC)
END AS STATUS,
CAST(D.DAJ_NODAFTAR AS VARCHAR(25)) AS 'NO ASET',
(SELECT CAST(PERIHAL AS VARCHAR(250)) FROM KOD_PERALATAN WHERE KODKATEGORI=D.DAJ_KODJENIS) AS 'KATEGORI ASET',
(SELECT CAST(NAMALAT AS VARCHAR(250)) FROM KAT_PERALATAN WHERE KODALAT=D.DAJ_KODALAT) AS 'KOD ALAT',
(SELECT CAST(NAMA AS VARCHAR(250)) FROM PASUKAN WHERE KODPASUKAN=D.DAJ_KODPASUKAN) AS PASUKAN
FROM BATM112_DES_AMJENTERA AS D
WHERE DAJ_KODKAT='VTC'
ORDER BY STATUS
当我在SQL Server 2000中测试此查询时,结果完美无缺。但是,当我复制并粘贴此查询以在Pentaho用户控制台中创建新数据源时,它会显示以下错误:
DatasourceServicelmpl.ERROR_0009
Query validation failed: Query validation failed:{0}
有人可以告诉我为什么以及如何解决这个问题?
答案 0 :(得分:0)
我在SQL 2008 R2中遇到同样的问题 - Pentaho 5.02 我无法使用“order by”运行任何查询。 如果我在没有“order by”的情况下运行相同的查询,它就会起作用。
SELECT * FROM table01 order by name
- >不要工作
SELECT * FROM table01
- >作品
答案 1 :(得分:0)
我找到了办法做到这一点!
像这样插入Top 100 PERCENT
:
SELECT Top 100 PERCENT * FROM table01 order by name
问候!