SQL Query Headache
poppy wrote ...
This is the modifications carried out on my code:
------------------------------------------------------------------------------------
SELECT Group_A.group_descr, Group_A.qty, Group_A.[Value], Group_B.qty,
Group_B.[Value]
FROM
(SELECT a.group_descr, SUM(b.qty) AS qty, SUM(b.value_incl_vat - b.vat)
AS [Value] FROM py_group a
LEFT OUTER JOIN cb b
ON a.pymat_no = b.py_mat_no AND Month(b.Inv_date) = 01
AND Year(b.inv_date) = 2004 and Upper(hstatus) < 'D'
GROUP BY a.group_descr) AS Group_A
(SELECT a.group_descr, SUM(a.qty) AS qty, SUM(a.value_incl_vat - a.vat)
AS [Value] FROM cb a LEFT OUTER JOIN chain_group b
ON a.mat_no = b.product_code AND Month(a.Inv_date) = 01
AND Year(a.inv_date) = 2004 and Upper(hstatus) < 'D'
AND a.mat_group IN
('CBS04','CBS09','CBS12','CBS14','CBS22','CBS42',' CBS95',' CBS96')
GROUP BY a.group_descr) AS Group_B
WHERE Group_B.descr = Group_descr
ORDER BY a.group_descr
------------------------------------------------------------------------------------
When I try to run both queries I get the this error in line 10:
"Incorrect syntax near the keyword 'SELECT' " and in line 16 this
error: "Incorrect syntax near ')' "
I think you merely missing a comma. Replace
AS Group_A
with
AS Group_A,
Jamie.
--
|