On 14 Aug 2002, at 13:31, Sean C. Burbidge wrote: > The query is: select t.lu_cn as cn, > sum(if(strcmp(t.work_item_type, 'OPERATIONS'), > t.reference_dollars_labor + > t.reference_dollars_equip + > t.reference_dollars_travel + > t.reference_dollars_matl + > t.reference_dollars_service, 0)) as ROPC,
There you're summing the rows where t.work_item_type does not equal 'OPERATIONS'. Read the documentation for STRCMP(): http://www.mysql.com/doc/en/String_comparison_functions.html [snip] > The problem I am encountering is that the figures for ROPC and NOPC > *should* be in the RAMC and NAMC columns respectively, and vice-versa. > If I run this query: > > select sum(t.reference_dollars_labor + t.reference_dollars_travel + > t.reference_dollars_matl + t.reference_dollars_service + > t.reference_dollars_equip) as ROPCfrom ii_tasks t where > t.work_item_type = 'OPERATIONS' and t.lu_cn = '5016.003441' group by > t.lu_cn; There you're summing the rows with t.work_item_type equals 'OPERATIONS'. It might be best to avoid STRCMP() entirely and just use =, which is generally clearer and less likely to lead to such errors. -- Keith C. Ivey <[EMAIL PROTECTED]> Tobacco Documents Online http://tobaccodocuments.org --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php