in reply to Dynamic SQL script
my $current_month = 11; my $num_days_of_supp = 120; my @months_of_support = ( ($current_month-($num_days_of_supp/30)+1) .. + $current_month ); my $sql = 'SELECT GREATEST(ROUND((SUM' . join( '+', map { sprintf "mth_%02i", $_ } ( 0 .. 12 ) ) . ") / 365 ) * $num_days_of_supp ), ROUND (SUM (" . join('+', map { sprintf "mth_%02i", $_ } @months_of_support) . '))) QTY, b. p_dlrn, b.p_dlrsplrcode ' . <<EOF; FROM ... EOF
That'll create the output you wanted from the input given (well, fill in the ... )-- but I'm not sure that's really what you want, given what you said. If mth_01 is the current month, why are you looking at mth_08 to mth_11 for the last 11 days?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Dynamic SQL script
by sasrs99 (Acolyte) on Nov 15, 2006 at 21:37 UTC | |
by sasrs99 (Acolyte) on Nov 15, 2006 at 21:53 UTC | |
by jhourcle (Prior) on Nov 16, 2006 at 13:02 UTC | |
by sasrs99 (Acolyte) on Nov 16, 2006 at 16:49 UTC | |
by sasrs99 (Acolyte) on Nov 17, 2006 at 18:19 UTC |