Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6608063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:34:12+00:00 2026-05-25T19:34:12+00:00

Im using an odbc-jdbc bridge in my project and I need select 2 pieces

  • 0

Im using an odbc-jdbc bridge in my project and I need select 2 pieces of data from the database and save the data to 2 variables on the java side of my application. Here is an example of my table.

SITE_ID ------- DEV_ID ------- SCHEDULE_TIME ------- VALUE_ENUM ------- IDX
---------------------------------------------------------------------------
1               3000           09:30:00              1                    1
1               3000           11:30:00              0                    2
1               3000           12:00:00              1                    3
1               3000           14:00:00              0                    4
1               3000           18:30:00              1                    5
1               3000           20:30:00              0                    6
1               4000           05:00:00              1                    1 
1               4000           13:30:00              0                    2
1               4000           16:30:00              1                    3
1               4000           18:30:00              0                    4

What I want to do is select SCHEDULE_TIME for the last 2 IDX‘s where DEV_ID is 3000, so I would like to save 18:30:00 and 20:30:00 in a variables, some examples of statements Ive tried are:

select SCHEDULE_TIME from ARRAY_BAC_SCH_Schedule order by IDX desc limit 1 where DEV_ID = 3000
select SCHEDULE_TIME from ARRAY_BAC_SCH_Schedule order by IDX desc limit (1,1) where DEV_ID = 3000

SELECT TOP 1 SCHEDULE_TIME FROM ARRAY_BAC_SCH_Schedule WHERE DEV_ID = 3000 ORDER BY IDX DESC

Right now Im just worrying about how to get the select statement to work in Query tool before I implement it in the java side. Thanks, Beef.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:34:12+00:00Added an answer on May 25, 2026 at 7:34 pm

    For SQL Server you should use

    SELECT TOP 2 SCHEDULE_TIME from (select SCHEDULE_TIME FROM ARRAY_BAC_SCH_Schedule WHERE DEV_ID = 3000 ORDER BY IDX DESC) as inner
    

    like Hemal told you.

    Be careful with queries like

    select TOP 2 SCHEDULE_TIME FROM ARRAY_BAC_SCH_Schedule WHERE DEV_ID = 3000 ORDER BY IDX DESC
    

    because that is wrong. SQL Server does the top and then the order.

    In PostgreSQL or MySQL you should use limit and the end of the query. The limit is after the where part.

    In Oracle you should use rownum inside the where part.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using the jdbc-odbc bridge to connect to an MS SQL database. When
I tried to connect my java program to Access DB using jdbc-odbc bridge when
I can access the database either from a .NET program (using ODBC) or through
I am retrieving data from XLS sheet using jdbc sql . Below is my
I have Oracle 11 database to which I connect using both JDBC and ODBC.
i am using ODBC to pull data from active directory to get the email
Using odbc how do I select something from a table and output to a
I'm trying to create a simple connection using the jdbc-odbc bridge: public static Connection
Im using sun.jdbc.odbc.JdbcOdbcDriver to connect to an oracle database.I know I would be probably
I am using odbc to connect mysql database in Java I write a function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.