You are here: Re: T-SQL Challenge « MsSQL Server « IT news, forums, messages
Re: T-SQL Challenge

Posted by --CELKO-- on 10/19/07 03:37

>>We have this basic SELECT statement:

SELECT product_id, we_date, sum(demand_units)
FROM weekly_transactions
WHERE demand_units > 0
GROUP BY product_id, we_date
ORDER BY product_id, we_date ; <<

Where is your DDL? What is a week_date [weeks and dates are different
units of measurement]? Did you mean to use the ISO-8601 Standard week-
within-year or what? Why is a demand of zero not possible?

>> However, for each Product and WE_DATE, we also want the demand units for the previous 10 weeks. So far week ending 9/23/2007 [sic: '2007-09-23' as per ISO-8601 and SQL standards!!], we want the demand_units for that week PLUS the demand_units for the previous 10 weeks. <<

Are ten previous weeks on the same row? Or is the ten-week total on
the same row? Are the ten totals on separate rows? Where is the
sample data that you should have posted with the DDL?

My guess, based on the lack of clear specs, no sample data and no DDL
is that you could use a report range table which has adjustments to
your fiscal calendar definition of a week.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация