Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 23rd, 2005, 10:41 PM
Friend of Wrox
 
Join Date: Oct 2004
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

 
Old May 23rd, 2005, 11:15 PM
Friend of Wrox
 
Join Date: Jan 2004
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
 
Old May 24th, 2005, 03:37 AM
Friend of Wrox
 
Join Date: Jul 2003
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






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





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