Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help with SQL Statement

Status
Not open for further replies.

IMCCoy

IS-IT--Management
Apr 24, 2009
2
I'm accessing a Pervasive.SQL 9.61 database using ODBC and I need some help coming up with a SQL statement. I haven't used Pervasive before so any help is appreciated. I'm programming using C# in Visual Studio 2008. Here's my info:

Table 1
Cost_Codes:
Job
Cost_Code
Description

Table 2
Job_Cost:
Job
Cost_Code
Cost_Code_Cat
WTD_Units
WTD_Cost

I need to SUM the WTD_Units in one field and WTD_Cost in another field based on Job and Cost_Code. So, these are the fields I need to return:

Cost_Code.Job, Cost_Code.Cost_Code, Cost_Code.Description, SUM(Job_Cost.WTD_Units), SUM(Job_Cost.WTD_Cost)

Thanks for any help!
 
Something like:

select Cost_Code.Job, Cost_Code.Cost_Code, Max(Cost_Code.Description), SUM(Job_Cost.WTD_Units), SUM(Job_Cost.WTD_Cost)
group by Cost_Code.Job, Cost_Code.Cost_Code
 
Thanks for the response. I didn't need to sum after all. The program I am getting numbers from has a field that keeps the totals.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top