I have a table called “items”
id month year **itemname** distmoney
1 12 2012 chicken 20
2 12 2012 pork 15
3 11 2012 chicken 21
4 11 2012 pork 15
I am trying to run a “difference report” on items with the same name.
So for chicken, it is found in month 12 & 11. If distmoney is different for these two months, i want to echo a warning or something of that nature. In my example above, distmoney for chicken is 20 for month 12 but 21 for month 11. So, a “warning!” should be echoed. For pork, however, distmoney remains the same so I would just echo “no issues” or something of the sort.
How can I go about doing this?
Thanks for any help. It is much appreciated.
You can
GROUP BYthe rows on theitemnamecolumn and see how many distinct values are indistmoneycolumn. If there are more than one distinct value, then there may be a problem.