Unix Technical Forum

Several SQL questions

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 ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 06:12 PM
SuperPhil
 
Posts: n/a
Default Several SQL questions

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!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 06:12 PM
Erland Sommarskog
 
Posts: n/a
Default Re: Several SQL questions

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:32 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com