Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to replace limit amount with zero

Status
Not open for further replies.

ping99

Technical User
Mar 16, 2006
45
CA
Hi all,

I have mytable contains 3 fields

groupe limitamount option

AAAAA 1000 YES
AAAAA 2000 NO
AAAAA 3000 NO
AAAAA 4000 NO

BBBBB 5000 NO
CCCCC 6000 NO

DDDDD 7000 YES
DDDDD 8000 NO

EEEEE 9000 NO
FFFFF 2000 NO

How to do select SQL statments in order to have mynewtable ? IF THE GROUP HAS MORE THAN ONE SINGLE
RECORD LIKE GROUP AAAAA AND GROUP DDDDD.

GROUP BBBBB, CCCCC, EEEEE AND FFFFF WILL STAY THE SAME
in mynewtable.

groupe limitamount option

AAAAA 1000 YES
AAAAA 0 NO
AAAAA 0 NO
AAAAA 0 NO

BBBBB 5000 NO
CCCCC 6000 NO

DDDDD 7000 YES
DDDDD 0 NO

EEEEE 9000 NO
FFFFF 2000 NO

In this above example, we need to replace in group AAAAA 3 records with option = NO and group DDDDD 1 record with option = NO to become zero.

TIA for any help in coding in SQL statments below.

Here is my codes: not work yet , please correct

insert into Tmpgroup
select groupe, count(*) as MyCount
from myTable group by groupe;

** this query is to create mynewtable :

select myTable.Groupe, iif(myTable.Option = "YES" and TmpGroup.MyCount > 1,;
LimitAmount, 0000) as LimitAmount;
from myTable inner join TmpGroup on myTable.Groupe = TmpGroup.Groupe;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top