Two Laptop Bag*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 3606
    
  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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to select last 6 months (names)
 
Similar Threads
How to search in this forum
I finished in 1.5 months. Is this normal?
Passed SCJD!
load balancing
Security Role