We help IT Professionals succeed at work.
Get Started

MySQL - need query to provide order totals for each store grouped by year?

sabecs
sabecs asked
on
61 Views
1 Endorsement
Last Modified: 2015-12-08
Hi,
I need a query that will give add all "order_total" based on store id for each year?

Thanks in advance for your comments.

CREATE TABLE IF NOT EXISTS `orders` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `mysql_order_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `timestamp` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `order_type` enum('normal','retail','special') DEFAULT 'normal',
  `store_name` varchar(200) DEFAULT NULL,
  `store_id` tinyint(4) DEFAULT NULL,
  `shipping_first_name` varchar(50) NOT NULL DEFAULT '',
  `shipping_last_name` varchar(50) NOT NULL DEFAULT '',
  `shipping_address1` varchar(100) NOT NULL DEFAULT '',
  `shipping_address2` varchar(100) NOT NULL DEFAULT '',
  `shipping_phone` varchar(32) NOT NULL DEFAULT '',
  `shipping_fax` varchar(20) DEFAULT NULL,
  `shipping_city` varchar(100) NOT NULL DEFAULT '',
  `shipping_state` varchar(32) NOT NULL DEFAULT '',
  `shipping_country` varchar(120) DEFAULT NULL,
  `shipping_postal_code` varchar(10) NOT NULL DEFAULT '',
  `same_address` char(1) DEFAULT 'Y',
  `order_total` double(8,2) DEFAULT NULL,
  `user_id` int(10) DEFAULT NULL,
  `email` varchar(80) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=40 ;
Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2015
Commented:
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE