我正在尝试这个查询我的Android应用程序,这与mysql工作正常,但没有给sqlite正确的结果
SELECT cust.Name,cust.ID,billNo,billTime,
(SELECT SUM(b.qty*b.Price*(SELECT (1+(s.tax/100))FROM tbl_stock s
WHERE b.itemCode=s.itemCode))
FROM tbl_billitems b WHERE a.billNo=b.billNo AND a.terminal=b.terminal)AS total ,
(SELECT COUNT(*) FROM tbl_billitems c WHERE a.billNo=c.billNo
AND a.terminal=c.terminal),terminal FROM tbl_bills a, tbl_customers cust
WHERE a.ID=cust.ID AND a.billNo IN (SELECT billNo from tbl_billitems)
它使用mysql给出正确的值,但在sqlite中只给出(b.qty * b.Price)的总和
请指导我。提前谢谢
答案 0 :(得分:-1)
这是我的应用程序代码..希望你有一些想法..
SELECT t.*, ((summeJ-summeVJ)/summeVJ*100) AS variance
FROM (SELECT k.ZKUNDENNR, k.ZNAME1,
(SELECT SUM(vk.ZNETTO) FROM ZPBSROW r LEFT JOIN ZWARENGRUPPEVK vk ON vk.ZPBSROW=r.Z_PK WHERE r.ZKUNDE=k.Z_PK AND ZJAHR=2013 AND ZMONAT>=1 AND ZMONAT<=6) AS summeJ,
(SELECT SUM(vk.ZNETTO) FROM ZPBSROW r LEFT JOIN ZWARENGRUPPEVK vk ON vk.ZPBSROW=r.Z_PK WHERE r.ZKUNDE=k.Z_PK AND ZJAHR=2012 AND ZMONAT>=1 AND ZMONAT<=6) as summeVJ,
(SELECT SUM(vk.ZDB_BASIS) FROM ZPBSROW r LEFT JOIN ZWARENGRUPPEVK vk ON vk.ZPBSROW=r.Z_PK WHERE r.ZKUNDE=k.Z_PK AND ZJAHR=2012 AND ZMONAT>=1 AND ZMONAT<=6) as summeDBVJ,
(SELECT SUM(vk.ZDB_BASIS) FROM ZPBSROW r LEFT JOIN ZWARENGRUPPEVK vk ON vk.ZPBSROW=r.Z_PK WHERE r.ZKUNDE=k.Z_PK AND ZJAHR=2013 AND ZMONAT>=1 AND ZMONAT<=6) as summeDBJ
FROM ZKUNDE k
) t
WHERE summeJ>0
ORDER BY summeJ DESC
LIMIT 0,10