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 - 2009-07-08 : 09:30:22
|
| Hi this is my oracle query can anyone help me out in giving it in sql server.Update EMRPATIENTSMASTER_bak a Set Race_id = (Select Race_Ethnicity_id From (Select Patient_id, Min(Race_Ethnicity_id) as Race_Ethnicity_id from EMRPATIENTRACEETHNICITY_bakGroup by Patient_id Order by Patient_id) bWhere b.Patient_id = a.Patient_id) |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-07-08 : 09:49:05
|
| try thisUpdate a Set Race_id = b.Race_Ethnicity_idfrom EMRPATIENTSMASTER_bak as a inner join ( Select Patient_id, Min(Race_Ethnicity_id) as Race_Ethnicity_id from EMRPATIENTRACEETHNICITY_bak Group by Patient_id Order by Patient_id) bon b.Patient_id = a.Patient_idMadhivananFailing to plan is Planning to fail |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-07-08 : 09:50:04
|
Try this:update aset Race_id = b.Race_Ethnicity_id from EMRPATIENTSMASTER_bak ajoin(Select Patient_id, Min(Race_Ethnicity_id) as Race_Ethnicity_id from EMRPATIENTRACEETHNICITY_bak Group by Patient_id) bon b.Patient_id = a.Patient_id No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-07-08 : 09:51:22
|
Oh no!Again toooooooooooo late!But mine is without that ORDER BY  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
rohitkumar
Constraint Violating Yak Guru
472 Posts |
Posted - 2009-07-08 : 09:52:08
|
| seperated at birth? word to word same query :) |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-07-08 : 09:58:31
|
Yes - seems like we are akind of twins but madhi is a bit faster  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-07-08 : 10:06:13
|
quote: Originally posted by webfred Oh no!Again toooooooooooo late!But mine is without that ORDER BY  No, you're never too old to Yak'n'Roll if you're too young to die.
Order by is not needed. It was due to copy/paste MadhivananFailing to plan is Planning to fail |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-07-08 : 10:06:42
|
quote: Originally posted by rohitkumar seperated at birth? word to word same query :)
It happens sometimes MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|