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!

DataTable.Compute() Syntax Help

Status
Not open for further replies.

cjtaylor

Programmer
Aug 12, 2001
69
US
I am looking to sum a datatable when certain fields match a criteria. I have the follwing fields in my table TOTAL, ORDER_TYPE. I want to able to sum all fields with the ORDER_TYPE = 'Sale', ORDER_TYPE = 'Charge' AND NOT ORDER_TYPE = 'None'. Can I do this with limited syntax of the filter expression? I can't seem to get it to work properly with the following

objDT.Compute("SUM(TOTAL)", "ORDER_TYPE = 'Sale' AND ORDER_TYPE = 'Charge' AND NOT ORDER_TYPE = 'None'");

I don't get an error with this expression, it just returns 0, and it should not be 0.

How would I filter this properly?

Thanks
 
Did you try using != on that last condition, instead of the NOT keyword? so:
Code:
ORDER_TYPE = 'Sale' AND ORDER_TYPE = 'Charge' AND ORDER_TYPE != 'None'
Otherwise, everything looks OK to me (I'm surprised it didn't work your way, too, though), so I would give that a shot.

penny.gif
penny.gif

The answer to getting answered -- faq855-2992
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top