Select A.user_name,
Decode (A.sex, 1, ' Male ', 2, ' female ') as SEX,
A.head_portrait,
TRUNC (Months_between (sysdate, A.birthday)/12) | | ' Old ' as BIRTHDAY,
Z.disease_name
From T_patient_info A
Description: Decode numeric match field, write to SQL will not have to go to the page <c:if> judgment,
Months_between gets the number of months between two time intervals, here is the divisible 12来 gets the age, is very convenient,
The trunc function returns a date value that is partially truncated in the specified element format.
There are also connectors in SQL | |, also note that the use of a lot is also very wide
Below are examples of several functions, which can be consulted
Decode (a.status, 0, ' unfinished ', 1, ' Completed ', 2, ' pending ', 5, ' deleted ') as Status_name,
To_char (A.create_time, ' Yyyy-mm-dd hh:mi:ss ') as Create_time
To_char (A.create_time, ' Yyyy-mm-dd HH24:mi:ss ') as Create_time,
To_char (F.time, ' Yyyy-mm-dd HH24:mi:ss ') as time
Several powerful Oracle self-band functions that can be aged according to date, match fields based on numeric values