3
我要鏈接的表(總和(PRECO)和名稱從客戶端)SQL組2個不同的表
SELECT SUM(ARTIGO.PRECO) AS SUM_PRECO , CLIENTE.NOME_P
FROM CLIENTE
INNER JOIN ARTIGO
ON ARTIGO.ID IN
(SELECT ARTIGO_ID FROM PERTENCERV2 WHERE COMPRACLIENTE_ID IN
(SELECT ID FROM COMPRACLIENTE WHERE CLIENTE_ID IN
(SELECT ID FROM CLIENTE)))
WHERE CLIENTE.ID IN
(SELECT CLIENTE_ID FROM COMPRACLIENTE WHERE ID IN
(SELECT COMPRACLIENTE_ID FROM PERTENCERV2 WHERE ARTIGO_ID IN
(SELECT ID FROM ARTIGO)))
GROUP BY CLIENTE.NOME_P;
但是代碼的結果是上述
SUM_PRECO NOME_P
39 Joaquim
39 José
和'39 「是的總和關閉所有價格 我如何可以隔離賬戶2個客戶端的
請理想地與樣本數據一起張貼表結構。必須有一個更簡單的方法來做到這一點。 –
artigo和客人餐桌之間有一條捷徑? –
@JoeTaras i.stack.imgur.com/BPTFL.png,這是artigo和客戶之間的方式 – props