SQL help urgent

一間學校以資料表STUD儲存學生個人資料,其中欄DOB儲存學生之出生日期:

(a) 寫一句SQL語句,以列出所有學生之日, 月(英文格式,例如AUGUST),年及英文格式之週日(例如ONDAY)於四個欄位內。

(b) 試解釋下列SQL語旨句為何不正確:

SELECT * FROM STUD ORDER BY YEAR(DOB)

Update:

correction

(a) 寫一句SQL語句,以列出所有學生之日, 月(英文格式,例如AUGUST),年及英文格式之週日(例如MONDAY)於四個欄位內。

1 Answer

Rating
  • ?
    Lv 5
    1 decade ago
    Favorite Answer

    Also in VFP?

    (a) SELECT DAY( dob ), CMONTH( dob ), YEAR( dob ), CDOW( dob ) FROM stud

    (b) You cannot use any function in ORDER BY clause in VFP. Please change the SQL to

    SELECT * FROM STUD ORDER BY DOB

    or

    You can select a new column ( or field ) to order it

    SELECT a.*, YEAR( dob ) as yr_dob FROM stud a ORDER BY yr_dob

Still have questions? Get your answers by asking now.