473,320 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

select sum() question

hi,

i have a products database and a sales database. i have product id field in
both which relates to a given product.

i would like to have a query who's result tells me the total cost of the
products sold in the given time period.

i am having trouble with the cost price query.

was hoping for something like

select sum(products.costprice),productID from products where any product
with that productID appears in the sales table

can you help?

thanks
Jul 20 '05 #1
1 1182
mike wrote:
hi,

i have a products database and a sales database. i have product id field in
both which relates to a given product.

i would like to have a query who's result tells me the total cost of the
products sold in the given time period.

i am having trouble with the cost price query.

was hoping for something like

select sum(products.costprice),productID from products where any product
with that productID appears in the sales table

can you help?

thanks

select sum(products.costprice) AS costpricetotal, productID from
products,sales where sales.productID = products.productID;

Something like that.

PS sales and products need to be tables in the same database.
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Nuno | last post by:
Is there any SQL Error? Or I have to use Select case in VB code to control SQL instead. Thank you for any ans. Nuno
5
by: malcolm | last post by:
Example, suppose you have these 2 tables (NOTE: My example is totally different, but I'm simply trying to setup the a simpler version, so excuse the bad design; not the point here) CarsSold {...
3
by: Memduh Durmaz | last post by:
Hi, I'm using DB2 UDB 7.2. Also I'm doing some tests on SQL Server 2000 for some statements to use efectively. I didn't find any solution on Sql Server about WITH ... SELECT structure of DB2. ...
2
by: marco | last post by:
Dear List, as it seems, MS SQL as used in Access does not allow a select INTO within a UNION query. Also, it seems that a UNION query can not be used as a subquery. Maybe my (simplified)...
6
by: A_M_IS | last post by:
Hello group, hope to anybodys help on my temporary blackout. (Using Access 2003 on XP Win.) I know how to create and edit temporary query recordset, then I can set this data source as my form...
0
by: djflow | last post by:
Hi! II was wondering if you can help me with SQL query.. Below 7 separated select query works fine(only when they are retrieved separately) But I want to combined them together and so that i...
22
by: Rickster66 | last post by:
As Instructed this is a new thread regarding my original post: "Select Only 10 Columns Going Back" I'm sorry for the late response. I've been gathering up information and carefully with as much...
4
by: Seguros Catatumbo | last post by:
Hello guys, i have this query: select c8.cerveh, sum(c8.monto1) monto1, (select prima from arysauto a where a.cerveh=c8.cerveh) priari, (sum(c8.monto1)-(select prima from arysauto a where...
2
by: Joe C. | last post by:
hello, just joined the group, i've run into a wall and am seeking some help. here is my query: SELECT DATEPART(year, TTmain.TTDate) AS 'Year', SUM(TTmain.TTAmt) + SUM(TTmain.TTFee) AS...
5
by: bcaillet | last post by:
Hi all, A few weeks ago I posted a question about a potential defect in Oracle 11g. Today I have more details on the error. Please contact me if you are an Oracle Support engineer, I will like...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.