You are here: Crosstab Query « MsSQL Server « IT news, forums, messages
Crosstab Query

Posted by burke.david on 09/07/05 14:00

I have two tables Bill and Location.
Bill
(
location_id int,
prod_period datetime,
consumption float,
demand float
)

Location
(
location_id int,
location_name varchar(45)
)

I want to create a stored procedure that takes a parameter of @year. I
basically want the procedure to return results that show locations
where consumption and/or demand IS NULL or 0 for each month throughout
a given year. I would like my results to look something like this:

location_id year Jan Feb Mar Apr May Jun Jul Aug Sept Oct
Nov Dec
1 2005 0 0 0
2 2005 0 0 0 0
3 2005 0 0

If data does exist for consumption or demand, I would like to show it,
however I am really interested in the locations that have no data
associated with them.

Any ideas of how I can accomplish this?

 

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

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