bsamson Posted April 5, 2008 Share Posted April 5, 2008 Hello, I have a DB named REPORTS. Here's the structure ... ID ENTRYDATE STORE NEWACTS 12MOACTS 22MOACTS Basically this is a small internal website that serves 20 stores. Each store has to complete a report on the site every night that gets put into the DB. Each store is assigned a STORE # which is what is stored in the STORE field. The number never changes and is unique to that store. Every Store completes this report every night. Now, I need to create a PHP script that computes how many NEW activations(month to date) each store has done and display the top 2 stores. This needs to be repeated for 12MOACTS and 22MOACTS. By the way, the NEWACTS, 12MOACTS, and 22MOACTS are new activations which are reported daily. Any help will be GREATLY appreciated! Thanks! Link to comment https://forums.phpfreaks.com/topic/99704-mysql-adding-fields/ Share on other sites More sharing options...
DanielWhite Posted April 5, 2008 Share Posted April 5, 2008 First off all you need to store every months data 01MOACT ect or you won't be able to calculate 12 and 22. Link to comment https://forums.phpfreaks.com/topic/99704-mysql-adding-fields/#findComment-510054 Share on other sites More sharing options...
bsamson Posted April 5, 2008 Author Share Posted April 5, 2008 Let me clarify ... Let's go with these fields instead: ID ENTRYDATE STORE NEWACTS UPGACTS How do I add all the new acts for each store then grab the the store with the highest new acts? Link to comment https://forums.phpfreaks.com/topic/99704-mysql-adding-fields/#findComment-510068 Share on other sites More sharing options...
bsamson Posted April 7, 2008 Author Share Posted April 7, 2008 ** Bump ** Link to comment https://forums.phpfreaks.com/topic/99704-mysql-adding-fields/#findComment-511434 Share on other sites More sharing options...
craygo Posted April 7, 2008 Share Posted April 7, 2008 something like this. (not tested) $sql = "SELECT count(`NEWACTS`) AS `totalnew`, `STORE` FROM `REPORTS` GROUP BY `STORE` ORDER BY `totalnew` DESC LIMIT 1"; Ray Link to comment https://forums.phpfreaks.com/topic/99704-mysql-adding-fields/#findComment-511441 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.