on ‎2012 Nov 09 3:11 PM
Hi,
I have no Sybase SQL experience at all but occasionally use MS SQL. I have a query that works fine but I need to ensure the output is ordered correctly.
The query is to select a list of customers from a database that have their birthday in a given month. Their actual date of birth is not relevant and I just want to order the list by the day of the month. The day of the month is being returned correctly by the string(datepart(day,[Date_Of_Birth])) element but no matter where I put an Order By statement it gets rejected. Any help gratefully received by this newbie 🙂
SELECT 'Equip_ID', 'Title', 'Last_Name', 'Auth_name','Date_of_birth' UNION SELECT string (Equip_id),Title, Last_Name, Auth_Name, string(datepart(day,[Date_Of_Birth])) FROM resident INNER JOIN EPEC_LOCATION ON LOCATION_DEF = LOCATION_REF JOIN authority WHERE datepart (month, [Date_Of_Birth]) ='12' AND auth_name like 'Wtc%';
Request clarification before answering.
Be careful with union and order by construction.
look at topic: http://sqlanywhere-forum.sap.com/questions/6778/order-by-and-union-all-compatibility
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 8 | |
| 5 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.