Loading ...
Sorry, an error occurred while loading the content.

sql puzzle

Expand Messages
  • VISHNAT
    hi I found this interesting puzzle and am putting this across ... Consider RAM a mango seller he sells mangoes everyday .Now for future sales projections he
    Message 1 of 1 , Nov 1, 2004
    • 0 Attachment
      hi

      I found this interesting puzzle and am putting this across ...

      Consider RAM a mango seller he sells mangoes everyday .Now for future
      sales projections he wants to obtain the value of sales for a
      week,Month,and the average for the week,month.


      For Example Mangoes sales figures for a week

      100 Mangoes on Monday
      200 Mangoes On Tuesday
      300 Mangoes On Wednesday
      400 Mangoes On thursday
      500 Mangoes On Friday

      Now as he sells mangoes he wants to know on sundays how much mangoes
      was sold from monday to sunday so that he can prepare his weekly and
      monthly report

      Desired Output :

      The Desired output should have value cumulated for all sundays in the
      month and one record for the month end.


      CREATE TABLE Sales
      (MongerID INT
      ,SoldDate int
      ,Qty Int )


      INSERT Sales 1,'2004-01-01',100
      INSERT Sales 1,'2004-01-02',200
      INSERT Sales 1,'2004-01-03',300
      INSERT Sales 1,'2004-01-04',400


      Note :
      For Those weeks that overlap over 2 months ie If 5th week has 2 days
      in december and 5 days in january
      include 2 days in the monthly calculation for December
      and include only 5 days in weekly and monthly calculation for january.



      Regards
      Viswanath
    Your message has been successfully submitted and would be delivered to recipients shortly.