Gossamer Forum
Home : General : Databases and SQL :

ORDER BY Question

Quote Reply
ORDER BY Question
I have a problem using ORDER BY key word. My company have a SQL database for invoice system. (This database isn't own develop)
Problem is the display result isn't newer invoice. I can do it sorted two field. First field is names "date1" contain add record date. Second field is "invoice_no1" which format is like 01-001/03 (Month-Number of invoice at month/Year). But i can't sorted by date field only because sometime may be add a record at same day. So result is like that:
invoice_no1 date1
12-179/02 12/31/2002
12-178/02 12/31/2002
...............
...............
01-002/03 1/1/2003
01-001/03 1/1/2003

But i want the result is like that:
invoice_no1 date1
01-002/03 1/1/2003
01-001/03 1/1/2003
...............
...............
12-179/02 12/31/2002
12-178/02 12/31/2002

First question : Where can i change the date format to YYYY/MM/DD in SQL datebase? If i change it, my existing database keep on work?
Second question : Can i using ORDER BY for sorting my invoice_no1 field from right to left?
12-179/02
<------
Quote Reply
Re: [ivanlty] ORDER BY Question In reply to
How about you sort by the Primary Key(What ever it is) of the record... it should go in order of entry.[/reply]

Last edited by:

RINGKONG: Jan 8, 2003, 9:51 AM
Quote Reply
Re: [ivanlty] ORDER BY Question In reply to
Quote:
First question : Where can i change the date format to YYYY/MM/DD in SQL datebase? If i change it, my existing database keep on work?
Second question : Can i using ORDER BY for sorting my invoice_no1 field from right to left?
12-179/02

1) Not advised to change date format in the database. You will likely lost all values, and reset all values to default value. But if your invoice system is in Perl or PHP, you can change the format you display the date. You may need a date format converter script or module, like GT::Date or other date module.

2) In SELECT ... WHERE statement you can use (just example, not a correct code):
ORDER BY fielda DESC, fieldb ASC, fieldc DESC

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...