2017-08-02 88 views
1

我試圖從運行Node.js的卡桑德拉的複雜SQL和使用Cassandra的快遞包裹它以下是查詢卡珊德拉的複雜的SQL:如何運行通過節點JS

client.execute("select distinct c.objekt PSP, b.bestellung purchase_order, b.details, b.bestellnettowert Budget, c.Interim_Amounts, c.belegdatum, b.cost_centre 
           from 
              (select objekt, sum("Wert/KWahr") Interim_Amounts, belegdatum, bestellung from bdr.cj74 where year(belegdatum) = '2016' group by objekt, belegdatum, bestellung) c, 
              (select bestellung, "Lieferant/Lieferwerk" details, bestellnettowert, belegdatum, "PSP-Elm", "Kostenst." cost_centre from bdr.opexcapex where year(opexcapex.belegdatum) = '2016') b 
           where b."PSP-Elm" = c.objekt 
              and year(c.belegdatum) = year(b.belegdatum) 
              and c.bestellung = b.bestellung", [], 

function(err, result) { 

如果我運行簡單的選擇聲明它正在工作,任何幫助將是偉大的!

回答

0

簡而言之,你不能。 Cassandra支持CQL,而不是SQL。 CQL與SQL有相似的語法,但許多SQL關鍵字在CQL中表現不同。

例如,你不能做JOIN或子查詢之類的事情。它確實允許您執行DISTINCT和SUM等某些聚合,但在何時以及如何使用這些方法方面存在限制(只允許在某些鍵上使用)。以下是查詢聚合查詢文檔的鏈接:https://docs.datastax.com/en/cql/latest/cql/cql_using/useQueryStdAggregate.html

此外,聚合是Cassandra 3.0的新增功能。如果您使用的是2.x版本,則唯一的選擇是在客戶端執行一些處理。