473,545 Members | 2,782 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

about UNION query? (very simple to most of you most likely)

1 New Member
very simple i would think to those who would know what to do but having a hard time:
i've addresses. street names and addresses on the streets. so those are the two fields. i want to arrange the whole thing according to how the route should be done. so i've done queries for subsections like A means north, and the way the North should be done, B query, means south area, and the way the streets should be arranged when if someone were to do area B only. problem: when I do a union query A+B, the result gets rearranged. I want the query union to actually "concatanat e" not rearrange the way the table is displayed. to be honest, i don't even know what field the union is using to actually arrange the table records (VERY IMPORTANT: there are no repeated records)
thanks again for the help
Jan 3 '11 #1
2 1510
jimatqsi
1,273 Recognized Expert Top Contributor
You need to know what the sort order is. Apparently you have not specified a sort order, and you need to do that. The first part of the sort order should be the indicator for the area, so all of north sort together, all of south sort together, etc....

I think you need to make another query that uses the union query as input. This query is the one that will do the sorting.

Jim
Jan 3 '11 #2
Oralloy
988 Recognized Expert Contributor
samul,

You have a slight problem, in that a UNION query returns unique records. It has to sort the results in order to remove duplicates.

On the other hand, you can impose an "ORDER BY" clause at the end of your "UNION"s to give you the desired ordering. For example:
Expand|Select|Wrap|Line Numbers
  1. SELECT Count(*) AS [CWR Fail],
  2.              0 AS [H&S Fail],
  3.              0 AS [Liability Fail]
  4.   FROM CompanyData 
  5.   WHERE ([CWR Received]=No) 
  6. UNION
  7. SELECT 0 AS [CWR Fail],
  8.              COUNT(*) AS [H&S Fail],
  9.              0 AS [Liability Fail]
  10.   FROM CompanyData 
  11.   WHERE ([H&S Approved]=No) 
  12. UNION SELECT 0 AS [CWR Fail],
  13.              0 AS [H&S Fail],
  14.              COUNT(*) AS [Liability Fail]
  15.   FROM CompanyData 
  16.   WHERE ([Liability Approved]=No)
  17. ORDER BY [Liability Fail] DESC;
Jan 3 '11 #3

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

Similar topics

1
1998
by: PATGMorris | last post by:
I've got a Union Query that pulls data from two different tables for chemistry and micro testing. The tables containing very similar data but for reasons not necessary here, cannot be put into one table (differing types of results mainly) However, both have date entry fields for varying time stations from an initial, 2 weeks, 1 month, 2...
3
4802
by: Sim Zacks | last post by:
I am using 8.0 beta 1 on an RH 8 Linux server. I have a union query that I am converting from access (where it worked) and it is returning duplicates. The only difference between the two rows is the Row field, which is returned automatically. and an example of a row that it has returned duplicate. I have verified that the row only shows...
22
2532
by: tricard | last post by:
Good evening, I was thinking about making a very simple DOS based (console) menu for a project that i am working on, but I have no idea where to start for something like this. Does anyone have any resources they could point me to or shed some light on what it is that you do exactly. Like I said, I don't want a real complicated menu, just a...
2
1939
by: planetthoughtful | last post by:
Hi All, I'd like to place a subreport onto a report that draws its records from a UNION query. When I design the query and view the records all looks fine. However, when I put the query as the subreport's data source and open it, Access complains that Jet can't find the table, and then when I open up the query itself to look at the SQL,...
5
2271
by: BillCo | last post by:
I'm having a problem with a union query, two simple queries joined with a union statement. It's created in code based on parameters. Users were noticing some inconsistant data and when I analysed the query produced and opened it from a MS Query it started giving strange results. The first query when run alone returns 22 records, some of...
8
2663
by: RJMac | last post by:
I’m using ADO 2.6 in VB6 to read in data from a Union query (qryJoinBalanceData) in Access 2000. The Union query contains 3 sub-queries, each of which joins several tables, but they all generate exactly the same fields containing the same type of data. I’m using qryJoinBalanceData as the source for a Group By and Sum query which compresses 4600...
1
4265
by: catudalg | last post by:
Configuration: Windows 2000 sp3 MS Access 2000 (9.0.4402 SR-1) Visual Foxpro 9.0 detached tables MS VFP Driver 6.01.6830.01 06/19/2003 For example, a simple query like: select * from ddwg1 union all select * from ddwg2
27
13760
by: MLH | last post by:
How can I turn the following into a make-table query? SELECT & " " & AS Recipient FROM tblVehicleJobs INNER JOIN tblAddnlOwnrs ON tblVehicleJobs.VehicleJobID = tblAddnlOwnrs.VehicleJobID WHERE tblVehicleJobs.VehicleJobID=GetCurrentVehicleJobID(); UNION SELECT AS Recipient FROM tblVehicleJobs INNER JOIN tblLienHolders ON...
1
1247
by: runway27 | last post by:
I have a table in mysql which i have defined as date and the values that are inserted have the following format for example : 2007-10-30 08:02:40 My requirement is to run a select query to retrieve a particular column on a specific date ex= "SELECT columnname from tablename where columnname='$dt'"; $sd=mysql_query($selectdate);...
3
3033
emandel
by: emandel | last post by:
Is there any way to allow me to edit information in a union query? In other words can I update information from within this query? For some reason it doesn allow me to change any information in the datasheet view of the query. SELECT , , FROM WHERE is not null UNION SELECT , , FROM WHERE is not null ORDER BY ;
0
7499
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...
0
7432
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...
0
7689
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. ...
0
7943
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7456
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
3490
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1919
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1044
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.