473,854 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need Query without Union and minus.


We need a query which retrieves option_code, for a plan from OPTION
table which are unique in (market, "ALL").
I have an example below
PLAN1 TEXAS 1000 1
PLAN1 TEXAS 2000 2
PLAN1 ALL 1000 3
PLAN1 ALL 3000 4

When we ran the SQL, for PLAN1, we need to get
1000 1
2000 2
3000 4

Currently we are using union and minus to retrieve unique options in
both markets.
select option_code, rate from OPTION
where plan = 'PLAN1'
and market= 'TEXAS'
select option_code, rate from OPTION
where plan = 'PLAN1'
and market= 'ALL'
select option_code, rate from OPTION
where plan = 'PLAN1'
and market= 'TEXAS'

Is there any way to do without using union and minus. We tried to use
NOT EXISTS, but it is slowing the query...

Thanks in advance for the help......
Jul 19 '05 #1
1 5858
union and minus are the best (most efficient) way to do it. You shouldn't be
trying to avoid them.

Jul 19 '05 #2

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

Similar topics

by: krystoffff | last post by:
Hi all For speed reasons, I would like to rewrite the following query without the subquery : SELECT * FROM table1 WHERE field1 NOT IN (SELECT field1 FROM table2 where field2=X); I thought something like this would work fine : SELECT table1.* FROM table1 LEFT JOIN table2 ON
by: sumit.sharma | last post by:
Hi, I have some experience in C prog language. I have small doubt abt using unions in C language. I have the foll. union union MyUnion { char name ;
by: Peter Dunker | last post by:
Hi, I will write ANSI C89. Is the following struct defenition correct ? I wrote it with VC6(Windows IDE) and at first no Problem. As I changed a compiler switch to 'no language extension', the compiler said that the union has no name. Is it right that in ANSI C the union must be named inside this kind of structure ?
by: Anna | last post by:
I have a simple DataGrid that displays a list of characteristics and allows you to edit a description for each characteristic. The query that feeds this involves a join, as the characteristics and their descriptions are in separate tables. The DataKeyField of the DataGrid is set to the description ID, but I also need to be able to access the characteristic ID in my update query (without displaying it in the DataGrid). I haven't had much...
by: ilikebirds | last post by:
Is it possible to create a union query that contains criteria from another union query? I would like the query to only display the order numbers from TeamUnions that are either contained in FromMortASA and FromMortO. Is that possible? --- SELECT , , , , , FROM WHERE =.
by: ticktack | last post by:
Hi there, I am trying to do a UNION with slightly different queries, it appears to work but it now bring in another problem. The second part of the UNION need to have a an extra field value ("NULL") added thus to match the number of fields between the two select queries. The problem comes that I some have duplicate records and want to condense them down so that "Table_Form_Element_ID" has a single record against it but I want the record to be...
by: Rama S | last post by:
Hi, We need a query which retrieves option_code, for a plan from OPTION table which are unique in (market, "ALL"). I have an example below PLAN MARKET OPTION_CODE RATE PLAN1 TEXAS 1000 1 PLAN1 TEXAS 2000 2 PLAN1 ALL 1000 3 PLAN1 ALL 3000 4
by: karuppiah | last post by:
Hi All, i need query,how to select last 3 month ,last 3wek,last 3 days , this last 3 month and 3 week should be friday, using sysdate from dual table, there is no exsting table, pls any one help me. Regards, karuppiah.
by: baburmm | last post by:
Hi all, Can any one tell me, Export datas to a Excel file using query without openrowset method is there any other methods are posible for creating an Excel file to export it Thanks, Babu.K
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...
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...
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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 most users, this new feature is actually very convenient. If you want to control the update process,...
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...
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...
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();...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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.