Solved

sql syntax error when communicating to an access database in vb.net

Posted on 2007-11-20
1
179 Views
Last Modified: 2013-11-26
Hi,

I have the following sql syntax that talks to an access database: -

rs.Open("Select NetDelCost, TaxCost, sum(TaxCost + NetDelCost) as 'DeliveryNetttotal' , Sum(NetDelCost) as 'DeliveryGrossTotal' from products WHERE Sold = true ", conn)

it keeps coming up: -

You tried to execute a query that does not include the specified expression 'NetDelCost' as part of an aggregate function.

When I run it in vb.net.

What am I doing wrong please.

Many Thanks
Lee
0
Comment
Question by:ljhodgett
1 Comment
 
LVL 32

Accepted Solution

by:
Daniel Wilson earned 500 total points
ID: 20319149
You're asking for both NetDelCost and its sum?  That's not going to make sense.  In order to get any benefit out of the SUM() aggregation, you're going to have to group some records together.  You're asking for each individual NetDelCost and the sum of it on each record ... which is the same thing.

What are your raw data?  And what are you trying to find?  I'm sure one of us can help you achieve that.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question