aspose file tools*
The moose likes JDBC and the fly likes how to select last 6 months (names) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "how to select last 6 months (names)" Watch "how to select last 6 months (names)" New topic
Author

how to select last 6 months (names)

Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 590

how to select last 6 months (names)

select 'VIP' as type, strftime('%m', 'now') AS month


If this month is October,
I want to select
VIP 10
VIP 9
VIP 8
VIP 7
VIP 6
VIP 5
how do I do that?
Thanks
Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 590
I have created a subtable called month
but it can't wrap around for 10-12 months before when this month is 10 etc
if I do
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3610
    
  60

This looks like an operation I'd rather do in Java (or other client language) instead of SQL (if possible, of course).

Perhaps combining the month.month field with current year to obtain an absolute date, and comparing it against a date range computed from the current date would help you manage the wrap-around problem.
 
 
subject: how to select last 6 months (names)