Click here to Skip to main content
15,887,267 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Anagram finder Pin
akidan11-Sep-09 7:27
akidan11-Sep-09 7:27 
GeneralRe: Anagram finder Pin
Ian Shlasko11-Sep-09 8:05
Ian Shlasko11-Sep-09 8:05 
GeneralRe: Anagram finder Pin
justastupidgurl12-Sep-09 2:37
justastupidgurl12-Sep-09 2:37 
GeneralRe: Anagram finder Pin
ClementsDan11-Sep-09 17:48
ClementsDan11-Sep-09 17:48 
GeneralRe: Anagram finder Pin
justastupidgurl12-Sep-09 2:19
justastupidgurl12-Sep-09 2:19 
GeneralRe: Anagram finder Pin
dawmail33316-Sep-09 2:11
dawmail33316-Sep-09 2:11 
GeneralRe: Anagram finder Pin
dojohansen15-Oct-09 1:25
dojohansen15-Oct-09 1:25 
GeneralHow to group by hour properly. [modified] Pin
Brady Kelly20-Aug-09 22:33
Brady Kelly20-Aug-09 22:33 
I've just found a another report query by my favourite genii, which gives call volumns per hour. You see, datetime columns are once again frowned upon, so we store the call time formatted as 'hh:mm:ss', then we 'group' by the call time as follows:
, CASE WHEN Sum(CASE WHEN TimeText>='01:00:00' And TimeText<='01:59:59' THEN Cost ELSE 0 END) IS Null THEN 0 ELSE Sum(CASE WHEN TimeText>='01:00:00' And TimeText<='01:59:59' THEN Cost ELSE 0 END) END AS T1_2
, CASE WHEN Sum(CASE WHEN TimeText>='02:00:00' And TimeText<='02:59:59' THEN Cost ELSE 0 END) IS Null THEN 0 ELSE Sum(CASE WHEN TimeText>='02:00:00' And TimeText<='02:59:59' THEN Cost ELSE 0 END) END AS T2_3
, CASE WHEN Sum(CASE WHEN TimeText>='03:00:00' And TimeText<='03:59:59' THEN Cost ELSE 0 END) IS Null THEN 0 ELSE Sum(CASE WHEN TimeText>='03:00:00' And TimeText<='03:59:59' THEN Cost ELSE 0 END) END AS T3_4
, CASE WHEN Sum(CASE WHEN TimeText>='04:00:00' And TimeText<='04:59:59' THEN Cost ELSE 0 END) IS Null THEN 0 ELSE Sum(CASE WHEN TimeText>='04:00:00' And TimeText<='04:59:59' THEN Cost ELSE 0 END) END AS T4_5
, CASE WHEN Sum(CASE WHEN TimeText>='05:00:00' And TimeText<='05:59:59' THEN Cost ELSE 0 END) IS Null THEN 0 ELSE Sum(CASE WHEN TimeText>='05:00:00' And TimeText<='05:59:59' THEN Cost ELSE 0 END) END AS T5_6
, CASE WHEN Sum(CASE WHEN TimeText>='06:00:00' And TimeText<='06:59:59' THEN Cost ELSE 0 END) IS Null THEN 0 ELSE Sum(CASE WHEN TimeText>='06:00:00' And TimeText<='06:59:59' THEN Cost ELSE 0 END) END AS T6_7

For each of all 24 freaking hours. And, BTW, we don't need no steenkin' isnull() function either.

JUST IN: There are 48 of these CASE lines, 24 for incoming calls, and 24 for outgoing calls. Laugh | :laugh:

Last modified: 10mins after originally posted --



GeneralRe: How to group by hour properly. Pin
David Skelly21-Aug-09 0:49
David Skelly21-Aug-09 0:49 
GeneralRe: How to group by hour properly. Pin
Brady Kelly21-Aug-09 0:53
Brady Kelly21-Aug-09 0:53 
GeneralRe: How to group by hour properly. Pin
ClementsDan21-Aug-09 15:22
ClementsDan21-Aug-09 15:22 
GeneralRe: How to group by hour properly. Pin
MaksimP25-Sep-09 10:07
MaksimP25-Sep-09 10:07 
GeneralHow to handle dates _properly_. [modified] Pin
Brady Kelly20-Aug-09 12:31
Brady Kelly20-Aug-09 12:31 
GeneralRe: How to handle dates _properly_. Pin
Keith Barrow20-Aug-09 23:03
professionalKeith Barrow20-Aug-09 23:03 
GeneralRe: How to handle dates _properly_. Pin
supercat921-Aug-09 10:14
supercat921-Aug-09 10:14 
GeneralRe: How to handle dates _properly_. Pin
Dan Neely21-Aug-09 10:41
Dan Neely21-Aug-09 10:41 
GeneralRe: How to handle dates _properly_. Pin
supercat924-Aug-09 11:05
supercat924-Aug-09 11:05 
GeneralRe: How to handle dates _properly_. Pin
ClementsDan21-Aug-09 15:38
ClementsDan21-Aug-09 15:38 
GeneralRe: How to handle dates _properly_. [modified] Pin
Vozzie224-Aug-09 16:15
Vozzie224-Aug-09 16:15 
GeneralPractically The Entire Article Pin
Rick York17-Aug-09 6:19
mveRick York17-Aug-09 6:19 
GeneralHow to get today's date PinPopular
Keith Barrow14-Aug-09 0:26
professionalKeith Barrow14-Aug-09 0:26 
GeneralRe: How to get today's date Pin
Nelson Costa Inácio14-Aug-09 1:49
Nelson Costa Inácio14-Aug-09 1:49 
GeneralRe: How to get today's date Pin
MaksimP25-Sep-09 9:55
MaksimP25-Sep-09 9:55 
GeneralRe: How to get today's date Pin
David Skelly14-Aug-09 2:49
David Skelly14-Aug-09 2:49 
GeneralRe: How to get today's date Pin
Keith Barrow14-Aug-09 3:20
professionalKeith Barrow14-Aug-09 3:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.