473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

ordering records with blank fields last

Hi. I'm a sorta novice ASP programmer, so I sure could use some help
from of you more experienced gurus....

I've written an ASP page that pulls all records from a table. My query
is 'SELECT * FROM teacher ORDER by Class'

It is working fine... sorta. The table has about 20 records, but only
5 have an entry in the 'Class' field. The 15 records with the blank
class field show up first, then the other 5 records. Is it possible to
have the blank one show after the ones with an entry. Here's how my
results look, IOW.

The 15 blank
3A
3B
5B
6A
7D

I would like it to show as:

3A
3B
5B
6A
7D
The 15 blank

I tried using the DESC keyword, but as I imagined, the results were:

7D
6A
5B
3B
3A
The 15 blank

So, can anyone help me out here? I hope I've made everything clear
enough.

Nov 3 '05 #1
3 1382
fe******************@yahoo.com wrote:
Hi. I'm a sorta novice ASP programmer, so I sure could use some help
from of you more experienced gurus....

I've written an ASP page that pulls all records from a table.


Never, never, never (have I made it clear that this should never be done?
<grin>) ask a database-related question without telling us what type and
version of database you are using. It is almost always relevant, and
definitely IS relevant for this question

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Nov 3 '05 #2
Bob Barrows [MVP] wrote:
fe******************@yahoo.com wrote:
Hi. I'm a sorta novice ASP programmer, so I sure could use some help
from of you more experienced gurus....

I've written an ASP page that pulls all records from a table.


Never, never, never (have I made it clear that this should never be
done? <grin>) ask a database-related question without telling us what
type and version of database you are using. It is almost always
relevant, and definitely IS relevant for this question


Oops, I meant to provide an answer. My bad. For Access you would do this:

"select ... order by iif([Class] > '',0,1), Class"

For SQL Server, you would use CASE instead of the VBA Iif function:
"select ... order by CASE WHEN Class>'' THEN 0 ELSE 1 END,Class"

HTH,
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Nov 3 '05 #3
I am using Access 2000, and your suggestion worked perfectly! Much
thanks.

Nov 3 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Ken Fine | last post by:
(originally posted to one of macromedia's groups; no help, so hopefully someone here can help me out. I'm using VBScript ASP.) When designing administrative interfaces to websites, we often need...
5
by: Marnie Parker | last post by:
I am adding a drop down comb box to an existing database I wrote about a year ago. This combo box list names where the user can select which record to go to. Sigh. Last, First Name and a...
9
by: Catherine Jo Morgan | last post by:
Can I set it up so that a certain combination of fields can't contain the same entries, on another record? e.g. a combination of FirstName/LastName/address? Or FirstName/LastName/phone? Or...
28
by: Lee Rouse | last post by:
Hello all, This is going to be a rather lengthy "question". I have an Access 2k database, separated front end/back end. Front end copies are on about 30 workstations and used frequently during...
1
by: Robert Marshall | last post by:
Hi all, Hoping someone can help me with an issue I'm having. I'm using AccessXP to create a database of U.S. Census records. After keying the data in, I decided to run a query to create a...
1
by: KC | last post by:
Hello, I am using Access 2002. WinXP, Template from MS called Orders Mgmt DB. I have tweaked this DB to work for our small co. It has worked pretty well up until I made the mistake of deleting...
3
by: wvmbark | last post by:
First time poster... I just found this forum and it appears there's plenty of people here that could make short work of problem that's been driving me absolutely bonkers for months. Every day we...
4
by: oduamy | last post by:
Before I ask my question - I have to say THANKS for all of the wonderful information and help this forum has provided me!!! You are all invaluable. Also, I posted this on the Microsoft forum as well...
36
by: beebelbrox | last post by:
Hi, I am new VB programming in Access and I am requesting help with the following code. WIndows OS MSaccess 2003 This code is attached to an unbound form that will display a specific recordset...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.