Using SQL Query problem

shophoney

Active Member
Joined
Jun 16, 2014
Messages
286
Hi I've written the statement below. But it's complaining about the "HAVING" part. I'm trying to prefilter the data prior to using Power Query.

SELECT tbljournal.posted_dt AS [JOURNAL DATE],
tblreceive.link_journal,
tblreceive.dest_loc_code,
tblreceive.reference_no,
tblreceive.vendor_code,
tblreceive.transact_type,
tblreceiveitem.sku_no,
tblreceiveitem.qty,
tblreceiveitem.cost,
tblreceiveitem.landed_cost AS [EXT LANDED COST],
tblreceive.rebate_perc,
tblreceiveitem.rebate_amount,
tblreceive.currency_code,
tblreceive.exchange_rate,
tblreceive.gst,
tblreceiveitem.retail,
tblreceive.note
FROM (tblreceiveitem
INNER JOIN tblreceive
ON ( tblreceiveitem.source_loc_code =
tblreceive.source_loc_code )
AND ( tblreceiveitem.dest_loc_code =
tblreceive.dest_loc_code )
AND ( tblreceiveitem.vendor_code =
tblreceive.vendor_code )
AND ( tblreceiveitem.reference_no =
tblreceive.reference_no ))
INNER JOIN tbljournal
ON tblreceive.link_journal = tbljournal.link_journal
GROUP BY tbljournal.posted_dt,
tblreceive.link_journal,
tblreceive.dest_loc_code,
tblreceive.reference_no,
tblreceive.vendor_code,
tblreceive.transact_type,
tblreceiveitem.sku_no,
tblreceiveitem.qty,
tblreceiveitem.cost,
tblreceiveitem.landed_cost,
tblreceive.rebate_perc,
tblreceiveitem.rebate_amount,
tblreceive.currency_code,
tblreceive.exchange_rate,
tblreceive.gst,
tblreceiveitem.retail,
tblreceive.note,
tblreceiveitem.line_no
HAVING (( ( tbljournal.posted_dt ) ># 1 / 31 / 2015# ));
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
I'm very rusty on Access and hardly ever use GROUP and HAVING, but it occurs to me you have 17 top SELECTS and 18 GROUP BY
 
Upvote 0
Hi
You have a mistake with
Code:
[COLOR=#333333](( ( tbljournal.posted_dt ) ># 1 / 31 / 2015# ));[/COLOR]
It is not allowed in HAVING clause. Use
Code:
Select fileldList From JoinedTables Where [COLOR=#333333]( tbljournal.posted_dt ) >#1/31/2015# Group By groupFields[/COLOR]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top