job_no job_name job_year job_month
1 a 2003 jan
2 b 2002 oct
3 c 2003 jul
4 d 2002 jun
. . . .
. . . .
. . . .
現想得到所有2003/jan前的job_no,job_name,該怎么寫,在ACCESS內!
...全文
12111打赏收藏
求一個SQL語句
job_no job_name job_year job_month 1 a 2003 jan 2 b 2002 oct 3 c 2003 jul 4 d 2002 jun . . . . . . . . . . . . 現想得到所有2003/jan前的job_no,job_name,該怎么寫,在ACCESS內!
job_month字段是字符类型还是时间类型?
如果是字符类型
select a.job_no,a.job_name
from (select job_no,job_name,(job_year+(case job_month when 'jan' then '01' when 'fab' then '02' when 'mar' then '03' when 'apr' then '04' when 'may' then '05' when 'jun' then '06' when 'jul' then '07' when 'aug' then '08' then 'sep' then '09' when 'oct' then '10' when 'nov' then '11' when 'dec' then '12' else '00' end) as job_yearmonth from your_table) a
where a.job_yearmonth < '200301'
其实我觉得一楼的可以的
如果是时间类型
select a.job_no,a.job_name
from your_table a
where (format(a.job_year, 'yyyy') + format(a.job_month, 'mm')) < '200301'