Hi,
I have a table as following
aa Text1 aa, p@xxx.be, 15267
aa Text1 aa, p@xxx.be, 16598
aa Text1 aa, p@xxx.be, 17568
aa Text2 aa, p@xxx.be, 25698
aa Text3 aa, x@zzz.be, 12258
I have to write a query as follows ...
SELECT DISTINCT TOP 500 fldText, fldContact, fldItemid
FROM table
WHERE fldCat = 10 AND CONTAINS (fldText, 'Text1')
In the example you can see the table has rows in which text and contact or
double but with different itemid's. Now my employer wants me to show only 1
row when text and contact or the same. He doesn't mind which itemid I show
.... but I have to show one.
I've an idea of how to do this using a cursor and a temporary table but I
guess that will be fatal for the performance because then I have to loop
through all selected rows, check each row with all other rows and store the
primary key in the temporary table if dedected it isn't double. Afterwards
I can execute ... SELECT ... FROM TABLE where primary key in (select
temp_primarykey from #temptable).
I hoped I could do everything in 1 "easy" SELECT but I should not know how?
Any ideas are much appreciated.
Thanks a lot.
Perre Van Wilrijk. 1 3608
On Tue, 24 Aug 2004 15:18:36 +0200, Perre Van Wilrijk wrote: Hi,
I have a table as following
aa Text1 aa, p@xxx.be, 15267 aa Text1 aa, p@xxx.be, 16598 aa Text1 aa, p@xxx.be, 17568 aa Text2 aa, p@xxx.be, 25698 aa Text3 aa, x@zzz.be, 12258
I have to write a query as follows ...
SELECT DISTINCT TOP 500 fldText, fldContact, fldItemid FROM table WHERE fldCat = 10 AND CONTAINS (fldText, 'Text1')
In the example you can see the table has rows in which text and contact or double but with different itemid's. Now my employer wants me to show only 1 row when text and contact or the same. He doesn't mind which itemid I show ... but I have to show one.
I've an idea of how to do this using a cursor and a temporary table but I guess that will be fatal for the performance because then I have to loop through all selected rows, check each row with all other rows and store the primary key in the temporary table if dedected it isn't double. Afterwards I can execute ... SELECT ... FROM TABLE where primary key in (select temp_primaryke y from #temptable).
I hoped I could do everything in 1 "easy" SELECT but I should not know how? Any ideas are much appreciated.
Thanks a lot. Perre Van Wilrijk.
Hi Perre,
Try it with this instead:
SELECT fldText, fldContact, MIN(fldItemid)
FROM table
WHERE fldCat = 10
AND CONTAINS (fldText, 'Text1')
GROUP BY fldText, fldContact
(untested)
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Robert Brown |
last post by:
suppose I have the following table:
CREATE TABLE (int level, color varchar, length int, width int, height
int)
It has the following rows
1, "RED", 8, 10, 12
2, NULL, NULL, NULL, 20
3, NULL, 9, 82, 25
|
by: Roberto Esposito |
last post by:
HI to All....
i need an help for a Select Query
MYSQL Version 3.23.58
it's all day i try to resolve this problem.... but i don't find SOLUTION!
sigh :-(
This is the simple query.....
|
by: Tcs |
last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't
loaded it yet. I'm still using MS Access. And no, I don't believe this is an
Access question. (But who knows? I COULD be wrong... :) I've tried the
access group...twice...and all I get is "Access doesn't like ".", which I know,
or that my query names are too long, as there's a limit to the length of the SQL
statement(s). But this works when I don't try to...
|
by: Kelvin |
last post by:
Okay so this is baking my noodle. I want to select all the
attritbutes/fields from a table but then to excluded any row in which
a single attributes data has been duplicated.
I.E. Here's my table:-
ID Ref Name DATE
1 AAA Joe 1/2
2 BBB Ken 1/2
3 AAA Len 6/3
|
by: Chris Belcher |
last post by:
I've written a Query that gets info from an Option Group and some combo
boxes that returns the correct data if,in the last "AND" of the "WHERE"
I compare . to "RS"
When I try to compare . to !!, a combo box populated with RS it returns
nothing. I would think that both of the following queries would be
equal. Where is my logic failing?
I've looked at this for 2 days and either haven't found a reference to
the problem or didn't recognize...
| |
by: mathilda |
last post by:
My boss has been adamant that SELECT DISTINCT is a faster query than
SELECT all other factors being equal. I disagree. We are linking an
Access front end to a SQL Server back end and normally are only
returning one record. She states that with disctinct the query stops
as soon as it finds a matching record. Both of us are relative novices
in database theory (obviously).
Can someone help settle this?
|
by: orekinbck |
last post by:
Hi There
Our test database has duplicate data:
COMPANYID COMPANYNAME
1 Grupple Group
2 Grupple Group
5 Grupple Group
3 Yada Inc
4 Yada Inc
|
by: jmartineau |
last post by:
Hello,
Here is a brief summary:
Table 1 = All Accounts
- with fields such as Customer ID and Account #
Table 2 = Deposit Balance Table
- with fields such as Account #, Balance
|
by: Bob Stearns |
last post by:
I am getting unwanted duplicate rows in my result set, so I added the
DISTINCT keyword to my outermost SELECT. My working query then returned
the following message:
DB2 SQL error: SQLCODE: -214, SQLSTATE: 42822, SQLERRMC: CASE...;ORDER BY;2
Message: An expression in the ORDER BY clause in the following
position, or starting with "CASE..." in the "ORDER BY" clause is not
valid. Reason code = "2".
More exceptions ... DB2 SQL error:...
|
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: 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: 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...
|
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: 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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |