Home » SQL & PL/SQL » SQL & PL/SQL » SQL Query
SQL Query [message #6873] Fri, 09 May 2003 07:20 Go to next message
Nazma Bepat
Messages: 34
Registered: May 2003
Member
How to write a query using the enrollment table to display the student number, section number, enroll date and final grade for all students with a created date of 14 December 1999.

This is what I think:

Select student_id, section_id, TO-CHAR(enroll_date, “dd-mon-yyyy hh24:mi;ss”)
FROM enrollment
Where trunc (create_date) = To_date (‘14-December-1999’, ‘dd-mon-yyyy’)

It does not work for me. Can someone assist me.

Thanks

Nazma
Re: SQL Query [message #6889 is a reply to message #6873] Sat, 10 May 2003 02:00 Go to previous message
Barbara Boehmer
Messages: 9090
Registered: November 2002
Location: California, USA
Senior Member
Your date formats should be in single quotes. Also, the data and the date format must match. So, either use December and Month or use dec and mon or use Dec and Mon. As well as specifying either the full or partial month name, both must also be upper case or lower case or initcap. See corrected code below:

SELECT student_id, 
       section_id, 
       TO-CHAR (enroll_date, 'dd-mon-yyyy hh24:mi:ss')
FROM   enrollment
WHERE  TRUNC (create_date) = TO_DATE ('14-Dec-1999', 'dd-Mon-yyyy')
/


In the future, please provide your table structure. For example, do this:

SQL> DESCRIBE enrollment

and copy the results onto your post. It would also help if you would provide the error message that you are receiving. It is important for you to start learning to figure out what the problem is, based on the error message, so that you can correct it yourself.
Previous Topic: How to know which table is used by whcih procedure
Next Topic: SQL Query Help
Goto Forum:
  


Current Time: Wed Apr 24 18:24:13 CDT 2024