有关sql函数问题(30分)

  • 主题发起人 主题发起人 lovelovedelphi
  • 开始时间 开始时间
L

lovelovedelphi

Unregistered / Unconfirmed
GUEST, unregistred user!
比如对日期字段,想按year,month输出。需要用到那种函数来转换
 
你的数据库类型?
用delphi的DateToStr或Format函数
 
year(字段名),month(字段名)即可
 
我的数据格式是db。
SQL Explor操作的话,对month或者year默认不了
 
decodetime
不会用看帮助
 
在SQL Explore中不能用 decodetime 吧~
 
用這個函數:
EXTRACT(month from 日期字段)
EXTRACT(year from 日期字段)
 
var
b_year,b_month,b_day:word;
DecodeDate(DataSource.DataSet.FieldByName('BFRQ').AsDateTime,b_year,b_month,b_day);
 
大家好,问题已经解决了一半了。但最后出错:capability not supported
我的数据表sheet1.db的字段是这样的:
meas_date(测量日期) station(测量站点) 数量
我要统计它们每月每站点的数量平均值。EXTRACT函数是对的。sql语句是这样的:
select station,EXTRACT(YEAR FROM meas_Date) as Meas_Year ,
EXTRACT(month FROM meas_Date) as Meas_month from sheet1
group by EXTRACT(YEAR FROM meas_date),
EXTRACT(month FROM meas_date),station
什么原因呢?

 
多人接受答案了。
 
后退
顶部