cvbmn
asked on
Database problem
Database problem
Here are two database problems :
->1st.
--------------------------
CustField DateField
--------------------------
1 Cust1 01/01/01
2 Cust2 02/01/01
3 Cust3 03/01/01
4 Cust4 04/01/01
5 05/01/01 Cust5
6 06/01/01 Cust6
7 07/01/01 Cust7
8 08/01/01 Cust8
--------------------------
CustField and DateField are string type. How with SQL to sort (order) it by Date and Cust using CustField and DateField as one ? Or You know some beter solutions (not SQL).
->2nd.
-------------------------- -
Date1Field Date2Field
-------------------------- -
1 01/01/01
2 02/01/01
3 03/01/01
4 04/01/01
5 05/01/01
6 06/01/01
7 07/01/01
8 08/01/01
-------------------------- -
Date1Field and Date2Field are date type. How with SQL to sort (order) it as one ? Or You know some beter solutions (not SQL).
Thanks.
Here are two database problems :
->1st.
--------------------------
CustField DateField
--------------------------
1 Cust1 01/01/01
2 Cust2 02/01/01
3 Cust3 03/01/01
4 Cust4 04/01/01
5 05/01/01 Cust5
6 06/01/01 Cust6
7 07/01/01 Cust7
8 08/01/01 Cust8
--------------------------
CustField and DateField are string type. How with SQL to sort (order) it by Date and Cust using CustField and DateField as one ? Or You know some beter solutions (not SQL).
->2nd.
--------------------------
Date1Field Date2Field
--------------------------
1 01/01/01
2 02/01/01
3 03/01/01
4 04/01/01
5 05/01/01
6 06/01/01
7 07/01/01
8 08/01/01
--------------------------
Date1Field and Date2Field are date type. How with SQL to sort (order) it as one ? Or You know some beter solutions (not SQL).
Thanks.
what did you mean by (as one)???
ASKER
That datas in 1. field and 2. field are as one field. Tanks.
For part 1:
If you mean you want to concatenate (combine) the two fields, the following would work:
Select (CustField+DateField) as CustDate from TABLE order by (CustField+DateField)
From what I've seen, you can't use the alias name of a calculated field in an Order By
I have no idea what you mean by "Date1Field and Date2Field are date type. How with SQL to sort (order) it as one ? "
What are you attempting to accomplish?
If you mean you want to concatenate (combine) the two fields, the following would work:
Select (CustField+DateField) as CustDate from TABLE order by (CustField+DateField)
From what I've seen, you can't use the alias name of a calculated field in an Order By
I have no idea what you mean by "Date1Field and Date2Field are date type. How with SQL to sort (order) it as one ? "
What are you attempting to accomplish?
you meen to merge them in one filed like this
NewField
------------
Cust1
01/01/01
Cust2
02/01/01
Cust3
03/01/01
Cust4
04/01/01
05/01/01
Cust5
06/01/01
Cust6
07/01/01
Cust7
08/01/01
Cust8
NewField
------------
Cust1
01/01/01
Cust2
02/01/01
Cust3
03/01/01
Cust4
04/01/01
05/01/01
Cust5
06/01/01
Cust6
07/01/01
Cust7
08/01/01
Cust8
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have just one question more about this.
So there is no some regular way to do this problem ?
And I have to find some my own as you comment TAZI ?
Thanks.
So there is no some regular way to do this problem ?
And I have to find some my own as you comment TAZI ?
Thanks.
Hi,
Thanks for the points ?? I have to ask why do you allow capturing of dates in two different columns. Enforce date capturing to one column only. This will be so much easier as you do not need to add a 3rd column and update it with all the date values. You can just do the last statement, Select and Sort
Select DateFinal from TableName order by DateFinal
I don't know of any other way that this can be done.
Thanks again for the point
Hope this helps
Regards
TAZI
Thanks for the points ?? I have to ask why do you allow capturing of dates in two different columns. Enforce date capturing to one column only. This will be so much easier as you do not need to add a 3rd column and update it with all the date values. You can just do the last statement, Select and Sort
Select DateFinal from TableName order by DateFinal
I don't know of any other way that this can be done.
Thanks again for the point
Hope this helps
Regards
TAZI