Re: Week number of the year CASE statement query

2011-08-21 Thread John English
On 20/08/2011 20:44, Morten Mikkelsen wrote: Could you elaborate on your initial suggestion about using Calendar.WEEK_OF_YEAR instead of the ugly case-thing to make up for my temp_week_counts? Create a Java method: public static final int weekNumber (java.sql.Date date) { Calendar c =

Re: Week number of the year CASE statement query

2011-08-21 Thread Morten Mikkelsen
On Sun, Aug 21, 2011 at 12:41 PM, John English john.fore...@gmail.comwrote: Create a Java method: public static final int weekNumber (java.sql.Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); return c.get(Calendar.WEEK_OF_YEAR); } Now create a function in

Re: Week number of the year CASE statement query

2011-08-21 Thread John English
On 21/08/2011 13:51, Morten Mikkelsen wrote: Thanks! If I understand correctly (doesn't get clearer from http://db.apache.org/derby/docs/10.7/ref/rrefcreatefunctionstatement.html) the java code must be compiled and present on the classpath of derby - or is it possible to just feed the uncompiled

Re: Week number of the year CASE statement query

2011-08-20 Thread John English
On 18/08/2011 13:59, Morten Mikkelsen wrote: SELECT wkno, COUNT(wkno) - 1 AS WeekCount from ( SELECT R as wkno, 0 as asset, 0 as priority FROM ( SELECT ROW_NUMBER() OVER () AS R, RULE.* FROM insert name of table with at least 53 rows in it ) AS TR WHERE R = 53 /* some years have 53 */ UNION

Re: Week number of the year CASE statement query

2011-08-20 Thread Morten Mikkelsen
That's a great idea! There is no need for a CASE because he's interested in a count in the end, so declare global temporary table SESSION.all_weeknos(wkno int) ON COMMIT PRESERVE ROWS not logged; declare global temporary table SESSION.temp_week_counts (wkno int, asset int, priority int) ON COMMIT

Re: Week number of the year CASE statement query

2011-08-18 Thread Morten Mikkelsen
Hi. On Tue, Aug 16, 2011 at 9:01 PM, Conor66 conor21e...@yahoo.ie wrote: I understand the concept of the union and the row_number but how do i union a temp table? Attached is my SQL file. Thanks for any help you can provide me with. http://old.nabble.com/file/p32274318/Main%2Bcode.sql

Re: Week number of the year CASE statement query

2011-08-16 Thread Conor66
-in function to calculate week numbers (so they continue to be correct in the future years, also) -- /Morten -- View this message in context: http://old.nabble.com/Week-number-of-the-year-CASE-statement-query-tp32230409p32274318.html Sent from the Apache Derby Users mailing list archive

Re: Week number of the year CASE statement query

2011-08-12 Thread John English
On 10/08/2011 17:12, Conor66 wrote: Thanks for your reply. Yes I looked into Calendar.WEEK_OF_YEAR, I came across it after I wrote that CASE statement and it would definitely be a better way to do this. But Im wondering how to get the weeks where nothing happens, so that I can have zero values

Re: Week number of the year CASE statement query

2011-08-12 Thread Morten Mikkelsen
On Wed, Aug 10, 2011 at 1:24 AM, Conor66 conor21e...@yahoo.ie wrote: The problem lies in... I want to also include in my output the weeks where nothing happens, so in my case the output should read like strName intWeekNum Count Closed, Completed 1

Re: Week number of the year CASE statement query

2011-08-10 Thread John English
On 10/08/2011 02:24, Conor66 wrote: Hi guys, firstly Id just like to say thank to everyone that has already responded to my questions, People on here are very helpful. What I am trying to do here is get the week number in the year that something happens and then count the amount of times this

Re: Week number of the year CASE statement query

2011-08-10 Thread Conor66
-- View this message in context: http://old.nabble.com/Week-number-of-the-year-CASE-statement-query-tp32230409p32234338.html Sent from the Apache Derby Users mailing list archive at Nabble.com.

Week number of the year CASE statement query

2011-08-09 Thread Conor66
: http://old.nabble.com/Week-number-of-the-year-CASE-statement-query-tp32230409p32230409.html Sent from the Apache Derby Users mailing list archive at Nabble.com.