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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL and Access

Status
Not open for further replies.

peekay

Programmer
Oct 11, 1999
324
ZA
I need to compile a recordset which selects all the records in a table which has two fields with a certain value for instance :<br>In the table named OrderedItems I have columns for Category,Project and Cost. I now need to sum the cost for a certain project and a certain category. The Sql I wish to use is something like the following :&nbsp;&nbsp;&nbsp;&nbsp;<br>&quot;Select * from OrderedItems where Project=&quot; & MyProject & &quot;and Category = &quot; & ThisCategory (where MyProject and ThisCategory are variables).<br>Can someone please set me on the right track to execute such a sql. <p>PK Odendaal<br><a href=mailto: pko@mweb.co.za> pko@mweb.co.za</a><br><a href= > </a><br>
 
Try this.<br><br>SELECT Sum(Cost) AS Total<br>FROM OrderedItems<br>WHERE Project=MyProject AND Category=ThisCategory;<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top