Just a quick code post at work, I'd wanted a Halloween image which I clearly don't have access to at work, so keeping it just to the code, and maybe I'll put up something Halloween-y later on (assuming I have images that aren't merely leaning to the gothic side of things) and by later I do mean much later, as in another day, as I'll probably be playing Hellgate all evening.
Anyways, SQL madness
select
DATEDIFF(n, pj_print_time_on, pj_print_time_off) [Print Minutes]
,(CAST(pj_print_counter_end AS int) - CAST(pj_print_counter_start AS int)) [Print Total]
,pj_print_spoilage_qty [Print Spoil]
,(((CAST(pj_print_counter_end AS int) - CAST(pj_print_counter_start AS int))) / (DATEDIFF(n, pj_print_time_on, pj_print_time_off))) [Print per Minute]
,pj_comments [Comments]
,DATEDIFF(n, pj_folding_time_on, pj_folding_time_off) [Fold Minutes]
,pj_total_folded [Fold Total]
,((pj_total_folded)/(DATEDIFF(n, pj_folding_time_on, pj_folding_time_off))) [Fold per Minute]
,pj_folding_spoilage_qty [Fold Spoil]
,DATEDIFF(n, pj_insert_time_on, pj_insert_time_off) [Insert Minutes]
,pj_insert_total [Insert Total]
,pj_insert_spoilage_qty [Insert Spoilage]
,((pj_insert_total) / (DATEDIFF(n, pj_insert_time_on, pj_insert_time_off))) [Insert per Minute]
from print_jobs
where DATEDIFF(n, pj_print_time_on, pj_print_time_off) > 0
AND (CAST(pj_print_counter_end AS int) - CAST(pj_print_counter_start AS int)) > 0
AND DATEDIFF(n, pj_folding_time_on, pj_folding_time_off) > 0
AND DATEDIFF(n, pj_insert_time_on, pj_insert_time_off) > 0
AND pj_entered_date_time > @StartDate and pj_entered_date_time < @EndDate
All it really lacks to truly impress myself is variable declaration to avoid the repeated usage of the mathematics in getting the 'per minute' values.
Showing posts with label Code Whoring. Show all posts
Showing posts with label Code Whoring. Show all posts
Wednesday, October 31, 2007
Wednesday, June 20, 2007
The Dangers of Letting me Code
Variable GiftArray05 = Floor(Block.[Record].[Record_gift1].[giftamount])
Variable GiftArray15 = Floor(1.5 * Block.[Record].[Record_gift1].[giftamount])
Variable GiftArray25 = Floor(2 * Block.[Record].[Record_gift1].[giftamount])
Variable GiftArray10 = IIF (((Variable.[GiftArray05] % 5) = 0), FormatCurrency(Variable.[GiftArray05]) , IIF (((Variable.[GiftArray05] + 1) % 5) = 0, FormatCurrency(Variable.[GiftArray05] + 1), IIF (((Variable.[GiftArray05] - 1) % 5) = 0, FormatCurrency(Variable.[GiftArray05] - 1), IIF (((Variable.[GiftArray05] + 2) % 5) = 0, FormatCurrency(Variable.[GiftArray05] + 2), IIF (((Variable.[GiftArray05] - 2) % 5) = 0, FormatCurrency(Variable.[GiftArray05] - 2), 0)))))
Variable GiftArray20 = IIF (((Variable.[GiftArray15] % 5) = 0), FormatCurrency(Variable.[GiftArray15]) , IIF (((Variable.[GiftArray15] + 1) % 5) = 0, FormatCurrency(Variable.[GiftArray15] + 1), IIF (((Variable.[GiftArray15] - 1) % 5) = 0, FormatCurrency(Variable.[GiftArray15] - 1), IIF (((Variable.[GiftArray15] + 2) % 5) = 0, FormatCurrency(Variable.[GiftArray15] + 2), IIF (((Variable.[GiftArray15] - 2) % 5) = 0, FormatCurrency(Variable.[GiftArray15] - 2), 0)))))
Variable GiftArray30 = IIF (((Variable.[GiftArray25] % 5) = 0), FormatCurrency(Variable.[GiftArray25]) , IIF (((Variable.[GiftArray25] + 1) % 5) = 0, FormatCurrency(Variable.[GiftArray25] + 1), IIF (((Variable.[GiftArray25] - 1) % 5) = 0, FormatCurrency(Variable.[GiftArray25] - 1), IIF (((Variable.[GiftArray25] + 2) % 5) = 0, FormatCurrency(Variable.[GiftArray25] + 2), IIF (((Variable.[GiftArray25] - 2) % 5) = 0, FormatCurrency(Variable.[GiftArray25] - 2), 0)))))
Variable GiftArray1 = Variable.[GiftArray10]
Variable GiftArray2 = IIF (Variable.[GiftArray10] = Variable.[GiftArray20], FormatCurrency(Variable.[GiftArray20] + 5), Variable.[GiftArray20])
Variable GiftArray3 = IIF (Variable.[GiftArray20] = Variable.[GiftArray30], FormatCurrency(Variable.[GiftArray30] + 5), Variable.[GiftArray30])
Variable GiftArray15 = Floor(1.5 * Block.[Record].[Record_gift1].[giftamount])
Variable GiftArray25 = Floor(2 * Block.[Record].[Record_gift1].[giftamount])
Variable GiftArray10 = IIF (((Variable.[GiftArray05] % 5) = 0), FormatCurrency(Variable.[GiftArray05]) , IIF (((Variable.[GiftArray05] + 1) % 5) = 0, FormatCurrency(Variable.[GiftArray05] + 1), IIF (((Variable.[GiftArray05] - 1) % 5) = 0, FormatCurrency(Variable.[GiftArray05] - 1), IIF (((Variable.[GiftArray05] + 2) % 5) = 0, FormatCurrency(Variable.[GiftArray05] + 2), IIF (((Variable.[GiftArray05] - 2) % 5) = 0, FormatCurrency(Variable.[GiftArray05] - 2), 0)))))
Variable GiftArray20 = IIF (((Variable.[GiftArray15] % 5) = 0), FormatCurrency(Variable.[GiftArray15]) , IIF (((Variable.[GiftArray15] + 1) % 5) = 0, FormatCurrency(Variable.[GiftArray15] + 1), IIF (((Variable.[GiftArray15] - 1) % 5) = 0, FormatCurrency(Variable.[GiftArray15] - 1), IIF (((Variable.[GiftArray15] + 2) % 5) = 0, FormatCurrency(Variable.[GiftArray15] + 2), IIF (((Variable.[GiftArray15] - 2) % 5) = 0, FormatCurrency(Variable.[GiftArray15] - 2), 0)))))
Variable GiftArray30 = IIF (((Variable.[GiftArray25] % 5) = 0), FormatCurrency(Variable.[GiftArray25]) , IIF (((Variable.[GiftArray25] + 1) % 5) = 0, FormatCurrency(Variable.[GiftArray25] + 1), IIF (((Variable.[GiftArray25] - 1) % 5) = 0, FormatCurrency(Variable.[GiftArray25] - 1), IIF (((Variable.[GiftArray25] + 2) % 5) = 0, FormatCurrency(Variable.[GiftArray25] + 2), IIF (((Variable.[GiftArray25] - 2) % 5) = 0, FormatCurrency(Variable.[GiftArray25] - 2), 0)))))
Variable GiftArray1 = Variable.[GiftArray10]
Variable GiftArray2 = IIF (Variable.[GiftArray10] = Variable.[GiftArray20], FormatCurrency(Variable.[GiftArray20] + 5), Variable.[GiftArray20])
Variable GiftArray3 = IIF (Variable.[GiftArray20] = Variable.[GiftArray30], FormatCurrency(Variable.[GiftArray30] + 5), Variable.[GiftArray30])
Subscribe to:
Posts (Atom)