Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 23rd, 2005, 10:41 PM
Friend of Wrox
 
Join Date: Oct 2004
Location: , , .
Posts: 198
Thanks: 2
Thanked 0 Times in 0 Posts
Send a message via MSN to itHighway
Default Anyone Expert in SQL Queries

Hi,

My Question is related to SQL Query. Let me explain it using an example.



Suppose an access table having records 001,002,003,004,005

Now what I want to do is using Select Query sort the records in such a way that it first display 004 and then the remaining records
So the list will display something like this

004
001
002
004
005


I can only use ONE sql query to sort and display the records in above mentioned format


Thank you,
Zeeshan Ahmed

Reply With Quote
  #2 (permalink)  
Old May 23rd, 2005, 11:15 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Me expert? no. For an SQL expert I would place this post in the proper area (P2P Forum > Database > SQL Language)

What data type are these numbers?


Wind is your friend
Matt
Reply With Quote
  #3 (permalink)  
Old May 24th, 2005, 03:37 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

It will depend on the db you are using, but if your db supports case statements, you could do something like this (I have assumed the fields you mention are strings as they all have leading zeroes in their values)...
Code:
SELECT myFieldVal, CASE WHEN myFieldVal = '004' THEN -1 ELSE 0 END AS myOrder 
FROM myTable ORDER BY myOrder, myFieldVal;
HTH,

Chris

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combine sql queries snufse SQL Server 2005 16 June 17th, 2008 03:47 PM
Sql Query Expert! itHighway Classic ASP Basics 1 June 5th, 2005 11:00 PM
Anyone Expert in SQL Queries? itHighway HTML Code Clinic 3 June 3rd, 2005 09:57 AM
pls help SQL Queries sush_blr SQL Server 2000 2 February 1st, 2005 01:56 AM
pls help me to write sql queries sush_blr SQL Language 1 January 28th, 2005 10:20 AM



All times are GMT -4. The time now is 03:14 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.