Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 593
Default 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.

--
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Frequency Headache Rothman Excel Worksheet Functions 6 March 9th 06 09:25 PM
headache! :) unique_id's cjjoo Excel Worksheet Functions 7 October 21st 05 03:24 AM
Vlookup Headache Stressed Out!! Excel Worksheet Functions 1 September 14th 05 06:03 AM
Header Headache! CWit[_7_] Excel Programming 10 March 4th 04 09:35 PM
Look up Headache Chris Excel Programming 3 November 26th 03 02:55 PM


All times are GMT +1. The time now is 01:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"