Computing.Net > Forums > Database > Dynamic select Scripts / Pivot

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Dynamic select Scripts / Pivot

Reply to Message Icon

Name: Deon
Date: November 24, 2008 at 02:16:05 Pacific
OS: AIX5.3
CPU/Ram: 4/4
Product: P550
Comment:

Hi This is my script.

SELECT T$ITEM,
SUM(CASE WHEN T$YEAR=2005 THEN T$AUPP$1 ELSE 0 END) AS "2005 JAN",
SUM(CASE WHEN T$YEAR=2005 THEN T$AUPP$2 ELSE 0 END) AS "2005 FEB",
SUM(CASE WHEN T$YEAR=2005 THEN T$AUPP$3 ELSE 0 END) AS "2005 MARCH",
SUM(CASE WHEN T$YEAR=2006 THEN T$AUPP$1 ELSE 0 END) AS "2006 JAN",
SUM(CASE WHEN T$YEAR=2006 THEN T$AUPP$2 ELSE 0 END) AS "2006 FEB",
SUM(CASE WHEN T$YEAR=2006 THEN T$AUPP$3 ELSE 0 END) AS "2006 MARCH"
FROM baandb.ttdinv750700
GROUP BY T$ITEM

This select only few years and month. My problem is My Dates ranges from 2004 to today. And new months and years gets added. I need my script to be dynamic. Please Help. T$AUPP$1 to T$AUPP$12 is my months.

A problem well stated is a problem half solved.
-Charles F. Kettering



Sponsored Link
Ads by Google

Response Number 1
Name: wizard-fred
Date: January 11, 2009 at 03:22:23 Pacific
Reply:

Use SubStrings to extract the Year and Month and the corresponding strings to make the Target String.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Database Forum Home


Sponsored links

Ads by Google


Results for: Dynamic select Scripts / Pivot

SQL Script www.computing.net/answers/dbase/sql-script/349.html

Script to check database status www.computing.net/answers/dbase/script-to-check-database-status-/393.html

Dynamic functions in Access 2003 www.computing.net/answers/dbase/dynamic-functions-in-access-2003/326.html