473,659 Members | 2,662 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQL Delete prob.

Hi
my prob is like this..
-----------------------------
create table ax(
i int ,
j int
)

create table ay(
i int ,
j int
)

insert into ax values(1,100)
insert into ax values(1,101)
insert into ax values(2,103)

insert into ay values(1,200)
insert into ay values(1,201)
insert into ay values(1,202)
insert into ay values(2,203)
insert into ay values(2,204)
insert into ay values(2,205)

select * from ax
select * from ay
--------------------

I want to delete
2 records(count of ax.i = 1) from ay.i = 1 and
1 record(count of ax.i = 2) from ay.i = 2

expected result :
select * from ay
i , j
-----
1 , any data
2 , any data
2 , any data
note: j is the temporary column in both table.

thanks
dishan

Jul 23 '05 #1
2 1414
On 12 Jan 2005 23:02:17 -0800, Dishan Fernando wrote:

(snip)
I want to delete
2 records(count of ax.i = 1) from ay.i = 1 and
1 record(count of ax.i = 2) from ay.i = 2

expected result :
select * from ay
i , j
-----
1 , any data
2 , any data
2 , any data
note: j is the temporary column in both table.


Hi Dishan,

DELETE FROM ay
WHERE (SELECT COUNT(*)
FROM ay AS ay2
WHERE ay2.i = ay.i
AND ay2.j < ay.j) <
(SELECT COUNT(*)
FROM ax
WHERE ax.i = ay.i)

SELECT i, j
FROM ay

i j
----------- -----------
1 202
2 204
2 205

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Jul 23 '05 #2
Thanks.. It works !!!!

Jul 23 '05 #3

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

Similar topics

4
1256
by: David B | last post by:
I am trying to delete the data from 4 fields from a record but leaving the ScheduleDetailsID untouched. Even if I take out the .ScheduleDetailsID from the delete line it comes back DELETE .CustomerID, .Numberofusers, .Priceuser, .Activitydetail, .ScheduleDetailsID
2
1692
by: Jason Shohet | last post by:
I don't know what this folder does, but in c, winnt, microsoft.net, framework, v1.1.4322, its there. I'm getting an error on one of my web sites saying that 'art.global' is defined in multiple places, using definition from c:... Temporary ASP.NET Files \ ... \artbargains.dll. (Artbargains is the name of the site). My site compiles fine, but I'm getting this error at runtime when i browse to the site. I've tried to delete ...
0
1400
Savage
by: Savage | last post by:
I'm making for fun a simple program which format a input file.Input file sustain of person name,lastname and date of birth.Output file si supposed to be forammted as following: NAME LASTNAME DATE OF BIRTH And i finished it but there is little prob: it don't output date of birth! I thinkt about the prob and can't figure out why is that happening. To output data i used function: void output(void),i have...
2
1517
by: mnacw | last post by:
Can anybody help me to resolve this prob. i have installed Visual Studio 2005 Professional edition. I am working in VB.Net. When I tried to connect to database it is connected but when i make some changes in table and try to update it does not work. It does not give any error. It seems like all fine. but when I retrieve the data via application menas data grid control on form. shows only previous data. no updates. i am using acess...
0
8427
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
8330
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
8746
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7355
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
6178
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
5649
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();...
0
4175
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...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1975
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.