Jump to content

Help with query


kevinfwb

Recommended Posts

I'm stumped and I need some help with a MySQL query.

 

I have a table that keeps track of sales and has the following fields:

 

storeNum = the company assigned number to the stores

week - the week of the recorded sales

period - the period of the recorded sales

year - the year of the recorded sales

month - the month the recorded sales

sales - the dollar amount of the sales

 

Our fiscal year is divided into 13 periods with 4 weeks in each period.

 

I'm trying to create a query that will give me all 4 weeks of sales in a given period.

 

Store    Period 1      Week 1    Week 2  Week 3  Week 4

1234        1            $8400      $6500    $7412    $7142

 

I have the following query, but it gives me 4 separate rows instead of one row.

 

SELECT storeNum, sales FROM Sales WHERE period = 12 AND year = 2007;

 

I hope that I've provided enough information as to what I'm looking for.  I know that it's not an incredibly difficult query, I'm just stumped at the moment.

 

Thanks

 

-Kevin 

 

Link to comment
Share on other sites

I'm not sure I follow your question.

We have about 165 stores and the results are sent to an html table.

If I can get the query to return storeNum, week 1, week 2, week 3, week 4

I'll still have 165 rows returned instead of 660.. wouldn't that be far more efficient?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.