Home > database >  ORACLE SQL statement questions beg god for help
ORACLE SQL statement questions beg god for help

Time:09-29

Select a from alarm a
Have a date type field in the table, I want to take out the alarm watch all of the fields at the same time, take the date a value type fields hour, can you tell me how to write a great god?

CodePudding user response:

A fool writing
Select a date alarm a where clause date_col in (select min (date_col) from alarm)

CodePudding user response:

 select a. *, to_char (a. d. ate_col, 'hh24) hh from alarm a; 

I understand is that, in all the fields in the table, then add a single hour field?

CodePudding user response:

SQL> The select to_char (sysdate, 'hh24), sysdate from dual;

The TO SYSDATE
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
14 the 2016-11-29 14:40:07

SQL> The select to_char (sysdate, 'hh), sysdate from dual;

The TO SYSDATE
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
02 2016-11-29 14:40:27

CodePudding user response:

There is a stupid question - date if normal to bring back local, how only for hours, in Java

CodePudding user response:

Forgot to say the first question, because I am using hibernate, entity class involved too much because it is over, I don't want to change the type of entity class, so I want to ask is whether I can take in alarm list of all the data at the same time to take a single date and only take hours,


Now I want to do is to date type directly retrieve the local don't do processing, want to separate for hours in a Java background, I consult a great god,

CodePudding user response:

refer to the second floor js14982 response:
 select a. *, to_char (a. d. ate_col, 'hh24) hh from alarm a; 

I understand is that, in all the fields in the table, then add a single hour field?



Thank you, help to see my next question a great god

CodePudding user response:

I don't know the big brothers, this is a Java problem, don't know anything about Java

CodePudding user response:

Java with the Calendar class ah

CodePudding user response:

refer to the eighth floor u012557814 response:
Java's words with the Calendar class.


If not asked to do, but if the application server and database server is not a machine, may result in different times, the need to see the details in which server time shall prevail

CodePudding user response:

Hundreds of thousands of data in Java traversal good slow, egg pain,

Database table is a list (date) (month) (year) hours and minutes of the date is the user Settings of filtering hours a day in the corresponding database fields are var can't checked in SQL

CodePudding user response:

I think this question is very simple
The select to_char (date field name, 'hh) from your table name

CodePudding user response:

The select to_char (sysdate, 'hh24), sysdate from dual;

CodePudding user response:

Can be used to extract function
 
SELECT the EXTRACT (HOUR FROM to_timestamp (to_char (SYSDATE, 'yyyy - mm - dd hh24: mi: ss'), '- dd yyyy - mm hh24: mi: ss')) FROM dual

CodePudding user response:

Select t. *, to_char (t.d ate, 'hh24) from alarm t
  • Related