473,763 Members | 7,611 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ORDER BY ..... in Union Query

Dear reader,

The following code delivers a wild card in the result of the query.

But the ORDER BY is not longer working.

SELECT Dis_ID, [Dis_No]&" "& [Dis_Description] As Discipline

FROM Tgn_Dis

ORDER BY [Dis_No] &" "& [Dis_Description] ;

UNION SELECT

'*' as Dis_ID, '<All> ' as [Dis_Description]

FROM Tgn_Dis;

Without the UNION SELECT part in the Query the ORDER BY is working but with
the UNION SELECT the sort is not longer in the correct order.

Is there any one who knows how to fix this?

Tanks for any help.

Kind regards,

Simon van Beek



Nov 20 '05 #1
2 4603
Just make a new query based on the union collected one.
--
Mvh Benny Andersen
Nov 20 '05 #2
On Mon, 21 Nov 2005 00:06:12 +0100, "S. van Beek" <S.******@HCCne t.nl>
wrote:

Straight from the help file on Union Operation:
You can use an ORDER BY clause at the end of the last query argument
to display the returned data in a specified order.

-Tom.

Dear reader,

The following code delivers a wild card in the result of the query.

But the ORDER BY is not longer working.

SELECT Dis_ID, [Dis_No]&" "& [Dis_Description] As Discipline

FROM Tgn_Dis

ORDER BY [Dis_No] &" "& [Dis_Description] ;

UNION SELECT

'*' as Dis_ID, '<All> ' as [Dis_Description]

FROM Tgn_Dis;

Without the UNION SELECT part in the Query the ORDER BY is working but with
the UNION SELECT the sort is not longer in the correct order.

Is there any one who knows how to fix this?

Tanks for any help.

Kind regards,

Simon van Beek


Nov 20 '05 #3

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

Similar topics

0
2139
by: Neculai Macarie | last post by:
Hi! Using Union and Order By gives strange behaviour in the following test-case: drop table if exists gallery; drop table if exists gallery_categ; # create test tables create table gallery (d_image_small char(100), d_image_big char(100)); create table gallery_categ (d_image char(100)); # insert test data
1
6176
by: Jeff Blee | last post by:
I hope someone can help me get this graph outputing in proper order. After help from Tom, I got a graph to display output from the previous 12 months and include the average of that output all in the one graph. The output was in the order of the months, but after unioning with the averages SQL code, the order is lost. Below is the full sql code that is the data source for the graph: SELECT (Format(.,"mmm"" '""yy")) AS Month,...
104
10894
by: Beowulf | last post by:
I have the view below and if I use vwRouteReference as the rowsource for a combo box in an MS Access form or run "SELECT * FROM vwRouteReference" in SQL Query Analyzer, the rows don't come through sorted by Numb. Everything I've read on the web suggests that including the TOP directive should enable ORDERY BY in views. Does someone have an idea why the sorting is not working correctly for this particular view? thanks. CREATE VIEW...
7
3342
by: Arnold | last post by:
Greetings Gurus, In a mainform's header, I have a combobox named comboStudents. The rowsource for this combobox is: SELECT -999 As StudentID, "<Add New Student>" As FullName, "aaa" As LastName, "x" As FirstName From qryStudents UNION SELECT StudentID, FullName, LastName, FirstName FROM qryStudents ORDER BY LastName;
3
4165
by: beconrad | last post by:
Hi all, I am not sure if what I want to do is possible, and if it is I have not been able to figure out how to do it. This is what I would like: 1. I have a data entry form with a field called Insurance. That field uses a combo box which takes its information from query on the Insurance table. At the moment the drop down list is sorted in alphabetical order.
3
1717
by: Yobbo | last post by:
Hi All My query is as follows: SELECT STRINGTEXT, TOKENID FROM WEBSTRINGS WHERE TOKENID IN (6,20,234,19,32,4,800,177) All I want is my resultset to come back in the order that I have defined in the IN clause, but unfortunately SQL is trying to be too helpful and sorts
6
3586
by: halberd4 | last post by:
Hello. I have an Access2003 db that I need to create a 'combined' query for. This query will then become the source for a listbox. The query needs to combine Query1 (example) SELECT Aa, Bb, Cc, Dd FROM Table1 WHERE Cc=3 ORDER BY Aa, Bb, Dd with Query2 (example) SELECT Aa, Bb, Cc, Dd FROM Table1 WHERE Cc<>3 ORDER BY Cc, Aa, Bb, Dd and produce a combined output similar to this (minus header) Aa Bb Cc Dd
11
9696
by: Israel | last post by:
I've trying to write a query that seems like it should be simple but for some reason my attempts are not working. This is really a general SQL quesion and doesn't pertain to MySQL but I couldn't find a generic database discussion group except on on advancement and theory and this is really a basic query construction question. Just say I have a table with three columns, name, date, score and these represent the test scores for various...
4
9097
by: tkltechy | last post by:
I have a sql query that unions two recordsets. It works when I don't try to adjust the ORDER BY clause using the replace function. However, I want to ensure that a certain item in the list always floats to the top. Can someone help me? Below is the SQL that does not run. Error is "Invalid column name 'name': Select 0 as , 'PRIME' as UNION Select subcontractor.subcontractorID, subcontractor. from subcontractor
0
9564
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9387
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10148
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9823
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8822
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7368
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3528
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2794
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.