473,395 Members | 1,677 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,395 software developers and data experts.

Sorting in a query

26
I have the following code in a query to do a sort:
Expand|Select|Wrap|Line Numbers
  1. SELECT Notebook.ID
  2.    , Notebook.[Type]
  3.    , Notebook.[Note Date]
  4.    , Notebook.[Note Time]
  5.    , Notebook.[Contact]
  6.    , Notebook.[Reference]
  7.    , Notebook.[Subject]
  8.    , Notebook.[Note]
  9.    , Notebook.[Documents]
  10. FROM Notebook
  11. ORDER BY Notebook.[Contact];
  12.  
Contact is in a table with the definition of Text (size 50). When executed I it come out like this:

Smith, John
Smith, John
Doe, John
Doe, John
Murphy, Mary

I was expecting it to be:

Doe, John
Doe, John
Murphy, Mary
Smith, John
Smith, John

What am I doing wrong?
Sep 10 '14 #1

✓ answered by twinnyfo

CLSkcab,

Is your [Contact] field referring to another table? If htis is so, then your query is sorting on the index, not on the name. In that case, if you want to sort by name, you will have to have a join query and include the actual contact name in that table, and sort on that field.

I hope this makes sense.

6 1000
zmbd
5,501 Expert Mod 4TB
Add ASC the end of line 11 in your SQL script.

SO: ORDER BY Notebook.[Contact];

Becomes: ORDER BY Notebook.[Contact] ASC;
Sep 10 '14 #2
CLSkcab
26
The result has no effect.
Sep 10 '14 #3
twinnyfo
3,653 Expert Mod 2GB
CLSkcab,

Is your [Contact] field referring to another table? If htis is so, then your query is sorting on the index, not on the name. In that case, if you want to sort by name, you will have to have a join query and include the actual contact name in that table, and sort on that field.

I hope this makes sense.
Sep 10 '14 #4
jimatqsi
1,271 Expert 1GB
CLSkcab,
How are you viewing the result? I mean are you simply running the query and looking at it in Datasheet mode, or are you using the query in a report?

Reports don't pay attention to the query sort order, the sort order must be specified in the report itself.

Jim
Sep 10 '14 #5
CLSkcab
26
Right on. Thank you very much.
Sep 10 '14 #6
twinnyfo
3,653 Expert Mod 2GB
So glad we could help in any way. Hope you have a great day!
Sep 10 '14 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: guitarromantic | last post by:
Hey, I have a 'staff' table with a column 'status', corresponding to a 'statuses' table with the appropriate titles (eg 1 | Editor in Chief). I want to display on the page the headings (the...
7
by: Not Me | last post by:
Hi, Having a table with some duplicate ID's (different data tho), how can I return the list but with only one record from each ID? Would this be using the first() function and grouping? ...
8
by: Mike MacSween | last post by:
tblCourses one to many to tblEvents. A course may have an intro workshop (a type of event), a mid course workshop, a final exam. Or any combination. Or something different in the future. At...
2
by: luca varani | last post by:
I would like to sort the results of a crosstab query by the aggregate function it automatically generates (total of the values in each column of the crosstab). If I simply put "ascending" in the...
34
mkuberski
by: mkuberski | last post by:
I have a database with 3 tables, Mailing_List, All_Seminars and Proximity_Results. The Mailing_List is a list of customers and their address, All_Seminars is a list of seminar locations and the...
6
by: tom_b | last post by:
Hi, I'm using Mysql and PHP,I have a simple table in my DB, looks something like this: id jim bob bill 1 20 30 15 2 20 35 15 etc, what i need to do is get the sums...
2
by: Bob Laubla | last post by:
Hello I have a very complex maketable query with many records and involving multiple VB functions which call other functions. I need this table to be sorted by the first field. But no matter what...
6
by: =?Utf-8?B?RGFu?= | last post by:
I am reposting a question from about 3 weeks ago ("sorting capability"). I have an aspx page in which I get the data from a database dynamically, through C# code, by creating a dynamic table...
0
prabirchoudhury
by: prabirchoudhury | last post by:
CRITERIA; +-------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+--------------+------+-----+---------+-------+...
11
by: michaelperl | last post by:
hi all ! I need some help please I'm using a database tool for developing and driving dynamic content. With the tool I use I make queries based on my tables and I set the sorting order of my...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.