db design or query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alipark
    New Member
    • Aug 2008
    • 1

    db design or query

    hi,
    I am fairly newb to mysql, so excuse my silly question. I am working on a vbmysql application for a warehouse. Here I am importing an excel sheet to mysql which has weekly status of the products. I am storing it in the same table with date and product code and qty.
    I want to display the weekly report and monthly report. Monthly report is easy but the problem is getting distinct values of rows as different columns for weekly report. i.e. I have stored dates, which I want to pick up distinct in different columns i.e.

    qty where week(idate)=wee k(20080818)-4, qty where week(idate)=wee k(20080818)-3, ..... and so on.

    I cant get it to work. I was wondering if there is a flaw in my db design, if so any suggestions how do I fix it? if not, then how do I get this query to work

    thanks in advance,

    regards,
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    Are you talking about something like:
    [code=php]
    SELECT WEEK(date_col) AS week, SUM(qty)
    FROM dates GROUP BY week;
    [/code]

    Comment

    Working...