This is a discussion on Several SQL questions within the SQL Server forums, part of the Microsoft SQL Server category; --> Hi all, I'd like to know if it's possible to sort twice in a same SQL query. I use ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi all, I'd like to know if it's possible to sort twice in a same SQL query. I use SQL for retrieving Data into an Excel Spreadsheet. (Excel 2000 or XP) and to paste the queries results into an Excel spreadsheet. 1. I tried to sort by date and the only way was to use the serail number instead of the litteral name I tried SELECT * FROM [Sheet1$] Where [Date] <= 07/20/2003" but this does not work. I then tried SELECT * FROM [Sheet1$] Where [Date] <= 37822" and it works. Do you know a way to use 07/20/2003? 2. I need to sort my data twice, first by name and second by date. Is it possible to sort twice in one query? Something like: "SELECT * FROM [Sheet1$] Where [Date] <= 07/20/2003 ORDER BY [NAME] ASC, ORDER BY [DATE] DESC" 3. Even if the first row of my Excel sheet includes the headers, I can not perform a query other than SELECT * FROM, for exemple, SELECT [NAME] FROM, does not work. do you know how to do that? Thanks in advance for sharing your experience, Phil *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
| ||||
| John Bell (jbellnewsposts@hotmail.com) writes: > SELECT * FROM [Sheet1$] Where [Date] <= '07/20/2003' > > Usually it is better to use a safe date format e.g. '20030720' '20030720' is the safe format in SQL Server, but it appears that we're talking Excel here. What is a good format for Excel, I have no idea. '2003-07-20' appears to be a good bet, but I don't know. (It surely will work on my computer - because that is my regional setting.) -- Erland Sommarskog, SQL Server MVP, sommar@algonet.se Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinf...2000/books.asp |
| Thread Tools | |
| Display Modes | |
|
|