Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
rajasekhar857
Constraint Violating Yak Guru
396 Posts |
Posted - 2010-08-30 : 06:59:14
|
[code] Table: ABCA B C D E F G H50586 152476 Dextromethorphan-Guaifenesin 10-100 mg/5 mL Tussin DM 10 mg-100 mg/5 mL Syrup R89446 433219 Dextromethorphan-Guaifenesin 10-100 mg/5 mL Tussin DM 10 mg-100 mg/5 mL Syrup A165511 433219 Dextromethorphan-Guaifenesin 10-100 mg/5 mL Tussin DM 10 mg-100 mg/5 mL Syrup A i want to update Table ABC COLUMN H as 'I' If all columns matches except AWHAT IS THE UPDATE QUERY IN DOING SO.SOMEWHERE TRIED LIKEUPDATE TABLE ABC SET H='I' WHERE A IN (SELECT MIN(A) FROM ABC GROUP BY C HAVING COUNT(*)>1)I AM HAVING MORE TAHN 1.5 LAKH RECORDS IN MY TABLE.HOW TO UPDATE IF IT MATCHES ABOVE CRITERIA.....[/code] |
|
rajasekhar857
Constraint Violating Yak Guru
396 Posts |
Posted - 2010-08-30 : 07:03:08
|
if 3 or 4 rows are matches over there i want only one row to be as 'A' and rest are all as 'I' |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-08-30 : 07:03:43
|
What are you trying to do? COUNT(*) < 1 can never occur. N 56°04'39.26"E 12°55'05.63" |
 |
|
rajasekhar857
Constraint Violating Yak Guru
396 Posts |
Posted - 2010-08-30 : 07:04:05
|
sorry i.e count(*)>1 |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-08-30 : 07:10:20
|
150 000 records is not much to update.UPDATE t1SET t1.H = 'I'FROM dbo.ABC AS t1INNER JOIN ( SELECT DISTINCT MIN(A) AS A FROM dbo.ABC GROUP BY C HAVING COUNT(*) > 1 ) AS x ON x.A = t1.A N 56°04'39.26"E 12°55'05.63" |
 |
|
rajasekhar857
Constraint Violating Yak Guru
396 Posts |
Posted - 2010-08-30 : 07:18:26
|
Thanks peso any idea for you in doing it in oracle.. |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-08-30 : 07:27:37
|
Yes.Visit www.dbforums.com and let Oracle experts help you.This is a Microsoft SQL Server forum. N 56°04'39.26"E 12°55'05.63" |
 |
|
rajasekhar857
Constraint Violating Yak Guru
396 Posts |
Posted - 2010-08-30 : 07:46:40
|
ok Thanks |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-08-31 : 07:41:24
|
quote: Originally posted by rajasekhar857 Thanks peso any idea for you in doing it in oracle..
Did you know that this forum is for SQL Server?I have told you several times MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|