synking Posted April 16, 2012 Share Posted April 16, 2012 Hey guys. I asked this question in the php coding help as i was not sure where i needed to do it but got help I need to do some math to the results for the table. I need to have the all months entered group together and then have the columns K001, K002, and total multiplied by 22 to get a month total of used amount. I have a table structure that looks like this. Array ( [Manufacturer] => SUPERIOR [Description] => S-0170 B BLEND [VOCContent] => 100 [Disbursed] => 55 [Recovered] => 0 [Month] => October [K001] => 0.67 [K002] => 1.83 [usePerDay] => 2.5 [TotalVocEmissions] => 17.45 [TotalK001] => 4.68 [TotalK002] => 12.77 [Year] => 2001 ) so far i have tried this but i am not that fluent in sql statements beyond the very basic. "Select Manufacturer, Description, VOCContent, Disbursed, Recovered, Month, K001, K002, UsePerDay, TotalVocEmissions, TotalK001, TotalK002 FROM SolventUsage Where Month > '$month' and Year > '$year' Group BY month, year"; That is just one i have tried. But that gets an error about columns not being contained as aggregate or in the group by. anyone able to point me in a direction to solve this Quote Link to comment https://forums.phpfreaks.com/topic/261057-mssql-group-by-help/ Share on other sites More sharing options...
cpd Posted April 17, 2012 Share Posted April 17, 2012 From what I've read your overcomplicating things and confusing yourself. Are you trying to multiply columns K001, K002, and total by 22? If so, why are you doing that when you need the total? Unless I've completely misinterpreted your problem. Quote Link to comment https://forums.phpfreaks.com/topic/261057-mssql-group-by-help/#findComment-1338039 Share on other sites More sharing options...
synking Posted April 17, 2012 Author Share Posted April 17, 2012 I am honestly not sure the best route to take... still trying to figure it out. What i need to do is group them by month. So all of the entries for the month of august are together. Then I have a few fields that are not stored in the database that are based off of the total usage for that month. So all of august usage grouped and then used to create a total for K001, K002, and the totalvocemission are created as separate fields Quote Link to comment https://forums.phpfreaks.com/topic/261057-mssql-group-by-help/#findComment-1338090 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.