Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9094905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:27:53+00:00 2026-06-16T23:27:53+00:00

I’m not sure what has happened exactly. I have a query which gets all

  • 0

I’m not sure what has happened exactly.

I have a query which gets all sales made in a week that has slightly malfunctioned breaking up a week in to 2, here is the query…

SELECT 
    ROUND(SUM(sell_price), 2) AS sell_price, 
    ROUND(SUM(buy_price/100*20), 2) AS fees, 
    ROUND(SUM(buy_price), 2) AS buy_price, 
    ROUND(SUM(sell_price/100*80 - buy_price), 2) AS margin, 
    time 
    FROM order_items 
    GROUP BY WEEK(FROM_UNIXTIME(time), 1) 
    ORDER BY WEEK(FROM_UNIXTIME(time), 1) DESC

This outputs the following

Sell Price      Fees    Buy Price   Margin  Date
44.01           4.46    22.30       12.91   31-12-2012
464.00          46.58   232.90      138.36  27-12-2012
313.82          31.80   159.01      92.06   10-12-2012
669.91          62.13   310.67      225.26  03-12-2012
265.88          25.57   127.84      84.87   02-12-2012
208.58          15.78   78.88       87.98   24-11-2012
176.90          16.32   81.59       59.93   01-01-2013

As you can see from the table you have the week beginning from the 31/12/12 being cut off from sales made in 2013, the sales are also not being returned in descending order as sales from 2013 should be displayed at the top of the table.

The table returned should look something like…

Sell Price      Fees    Buy Price   Margin  Date
220.2           20.78   103.90      72.84   31-12-2012
464.00          46.58   232.90      138.36  27-12-2012
313.82          31.80   159.01      92.06   10-12-2012
669.91          62.13   310.67      225.26  03-12-2012
265.88          25.57   127.84      84.87   02-12-2012
208.58          15.78   78.88       87.98   24-11-2012
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T23:27:54+00:00Added an answer on June 16, 2026 at 11:27 pm

    Maybe this will work for you:

    SELECT 
        ROUND(SUM(sell_price), 2) AS sell_price, 
        ROUND(SUM(buy_price/100*20), 2) AS fees, 
        ROUND(SUM(buy_price), 2) AS buy_price, 
        ROUND(SUM(sell_price/100*80 - buy_price), 2) AS margin, 
        DATE_SUB(FROM_UNIXTIME(time), INTERVAL (DAYOFWEEK(FROM_UNIXTIME(time)) - 1) DAY) AS fdow 
        FROM order_items 
        GROUP BY fdow
        ORDER BY fdow DESC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have an array which has BIG numbers and small numbers in it. I
I have a text area in my form which accepts all possible characters from
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a small JavaScript validation script that validates inputs based on Regex. I
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I have an autohotkey script which looks up a word in a bilingual dictionary
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.