need help with the Update statement
HelloI received a question in a course and I tried my best to respond, and now my brain is giving. I would really appreciate help with the update statement. I don't mind if you do not validate a solution, a little nudge in the right direction would be really useful. I'll post that I got.
THE QUESTION
/ * For these agents disabled on more than seven missions, change their date of deactivation of the first date of deactivation of all the agents that have been activated in the same year as the agent that you update currently.
*/
I have it divided into parts, here is my select statement to agents disabled on more than 7 missions, which produces the deactivation_dates in the agents table that I want to update...
SELECT
s.deactivation_date
FROM
(
SELECT
a.deactivation_date,
count(m.mission_id) as nomissions
FROM
agents a
INNER JOIN
missions_agents m
on
a.agent_id=m.agent_id
GROUP BY
a.deactivation_date
) s
WHERE
s.nomissions>7 AND s.deactivation_date IS NOT NULL
.. .and the code for the first date of deactivation for each year of activation agentselect
a2.deactivation_date
from
agents a2
where a2.deactivation_date=
(
select min(a.deactivation_date)
from
agents a
where to_number(to_char(a.activation_date,'YYYY'))=to_number(to_char(a2.activation_date,'YYYY'))
)
..... I am not real to marry these two statements together in the Update statement. I can't extract each date of deactivation produced in the first select statement and their match against the first date of deactivation in the year they have been activated for the second select statement.Any help greatly appreciated... :))
I began to wonder how things would :)
user8695469 wrote:
First of all why he chooses the date the earliest of all agentsUPDATE AGENTS_COPY AC /* (1) */ SET DEACTIVATION_DATE = ( SELECT MIN(AGS.DEACTIVATION_DATE) FROM AGENTS_COPY AGS , AGENTS_COPY AC /* (2) */ WHERE TRUNC(AGS.ACTIVATION_DATE,'YEAR') = TRUNC(AC.ACTIVATION_DATE,'YEAR') /* (3) */ )
He recovers as soon as the subquery has not been correctly set in the SET clause. It seems you are trying to update a correlated, but we are still having a conceptual shift. I have added a few comments to your code above and below will explain.
(1): when you do a correlated update it is useful to the table alias that you did right here.
(2): this table statement is not necessary and is the reason why the FIRST deactivation date is selected. The alias that you use (3) refers to THIS table, not the one defined in the update statement. Remove the line indicated by (2) in the FROM clause and a correlated update will happen.
and secondly why is it to update each row, when I thought that I'm just the lines where the agents are disabled and missions > 7? Pointers on where I'm wrong would be very appreciated. (SQL = stupid query language!) :)
user8695469 wrote: then why is it to update each row, when I thought that I'm just the lines where the agents are disabled and missions > 7? Pointers on where I'm wrong would be very appreciated. (SQL = stupid query language!) :)
WHERE EXISTS ( SELECT a.agent_id, count(m.mission_id) FROM agents a /* INNER JOIN AC ON AC.AGENT_ID = A.AGENT_ID */ INNER JOIN missions_agents m ON a.agent_id=m.agent_id GROUP BY a.agent_id, a.deactivation_date HAVING count(m.mission_id)>7 AND a.deactivation_date IS NOT NULL )
Once again this problem is similar to the question above that a correlation update doesn't work. Test existence of lines in an EXISTS subquery. Since your subquery is not related to the table that you are trying to update, it will be always return a line and, therefore, it returns true for EACH LINE in the AGENTS table. To limit the game to only agents > 7 missions results, you need to add a join condition that references the table in your update statement. I added one above (with comments) as a sample.
I recommend you look over all material that you have associated with correlated subqueries, including documents that I posted above. This seems to be what you're having the problem more with. If you need me to explain the concept of correlated queries any better please let me know.
Thank you!
Tags: Database
Similar Questions
-
Need help with the update with several joins statement
I have the following select statement, which takes 29 records:
SELECT
PAA. PROJECT,
PAA. SEGMENT1,
PEIA.expenditure_item_id,
PEIA.expenditure_type,
PEC.expenditure_comment
OF PA.PA_PROJECTS_ALL APP.
PEIA PA.pa_expenditure_items_all,
PEC PA.pa_expenditure_comments
where PPA.segment1 < '2008' and
PPA.project_id = 52 and - just run for project # 20077119 for the test
PEIA.expenditure_type = 'PAY' and
PEIA.project_id = ppa.project_id and
PEC. EXPENDITURE_ITEM_ID = PEIA. EXPENDITURE_ITEM_ID;
I need to update the pec.expenditure_comments to a static field for 29 records. I guess I should start with the following, but don't know how to fill in the where:
Update
PEC PA.pa_expenditure_comments
Set pec.expenditure_comment = ' REFERENCE HD #728'.
where
???
First time we have ever needed to update, so any help appreciated.Try using are:
update pa.pa_expenditure_comments pec set pec.expenditure_comment = 'REFERENCE HD#728' where exists ( select null from pa.pa_projects_all ppa , pa.pa_expenditure_items_all peia , pa.pa_expenditure_comments pec2 where ppa.segment1 < '' -- not sure what you posted here, so for next time: -- please put your examples between the code tags. and ppa.project_id = 52 -- just run for project # 20077119 for testing and peia.expenditure_type = 'PAYROLL' and peia.project_id = ppa.project_id and pec2.expenditure_item_id = peia.expenditure_item_id and pec2.expenditure_item_id = pec.expenditure_item_id );
-
need help with the Merge statement
I'm on: Oracle Database 11 g Enterprise Edition Release 11.2.0.2.0 - 64 bit Production
I'm currently an UPDATE statement and then it works and is accurate, it takes 30 minutes. I heard that MERGE
can do the same thing and is just as accurate and much faster!
Here's the query I want to convert into a MERGE INTO statement. I tried to do it myself, but I get errors and don't know simply, since it's new for me.
Basically I want to update table your on a corresponding condition in the table tt for 2 columns (GTP and UPDATE_DT), for UPDATE_DT I want to insert the Date current system.
Thank you!UPDATE /*+ PARALLEL (16) */ OLDER_Table ta SET (ta.GTP, ta.UPDATE_DT) = (SELECT /*+ PARALLEL (16) */ tt.GTP, SYSDATE FROM NEWER_Table tt WHERE ta.cust_id = tt.cust_id AND ta.STAMP_DATE = tt.STAMP_DATE AND ROWNUM = 1) WHERE EXISTS (SELECT 1 FROM NEWER_Table tt WHERE ta.cust_id = tt.cust_id AND ta.STAMP_DATE = tt.STAMP_DATE AND (NVL(ta.GTP, 'X') != NVL(tt.GTP, 'X')));
Hello
Whenever you have a problem, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) of all of the tables involved.
Also post the results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.
If you ask on a DML statement, such as UPDATE, CREATE TABLE and INSERT statements need to re - create the tables as they are before the DML, and results will be the content of the or the tables changed when it's all over.
See the FAQ forum {message identifier: = 9360002}MERGE peut be much faster than update; Sometimes, there is no significant difference in speed.
Tables in multiple situations like this, I've never seen a case where the MERGER has been slower than the UPDATE, even if the UPDATE is sometimes easier to code and just as fast.Maybe that's what you want:
MERGE INTO older_table dst USING ( SELECT n.cust_id , n.stamp_date , n.gtp , ROW_NUMBER () OVER ( PARTITION BY n.cust_id , n.stamp_date ORDER BY n.gtp ) AS r_num FROM newer_table n JOIN older_table o ON n.cust_id = o.cust_id AND n.stamp_date = o.stamp_date AND NVL ( n.gtp , 'X' ) != NVL ( o.gtp , 'X' ) ) src ON ( src.cust_id = dst.cust_id AND src.stamp_date = dst.stamp_date AND src.r_num = 1 ) WHEN MATCHED THEN UPDATE SET dst.gtp = src.gtp , dst.update_date = SYSDATE ;
As I can't test it, I can't be sure.
-
Need help with the update of Windows (OS-Windows 7)
Hello world
Recently, I met a problem with Windows update on my laptop (OS-Windows 7). Everything is fine with it, but when I try to install updates (recommended or optional) window says that it downloads the updates, but the progress remains to 0KB and 0% downloaded status. I tried to restart the service of windows update with utility update of windows running, but without success. However, I was able to install updates, most of them associated with Microsoft.NET framework 3.5.1 (I'm not sure of the version of the .NET Framework is installed in my computer). But when I tried to install other updates updated security windows or .NET Framework 4. XX version update, he gave the same answer that I mentioned above.
I can give my specifications and other information required if necessary.
Please help me with this problem about the update of windows.
Thanks for your time and your help.
Try the following: set never 'Find updates' automatic updates and then restart Windows. Download and install KB3161608.
http://support.Microsoft.com/kb/3161608
Best regards, VZ
-
Need help with the update for my 11 elements
I have 11 items and just switch to the Canon 7 d Markii and shooting in RAW for the first time last night and the editor and organizer elements does not files because it does not acknowledge the BRUTE of the 'new '... device information I tried the update and he offered only a 7.4 update, where the 7 5 d Markii must at least a 8.7 update... How can I get the latest update if my program does not by itself? I DON'T like the way Canon program from the disk provided with the camera is set for RAW images, and I don't want to have to change all the RAW files to only align my items... I enjoyed how the older my camera RAW files were brought in Editor with the pop-up window which allow me to make changes to quick for photos before opening them in the editor... Yet once I don't like how the Canon window works for RAW images... Thanks for any help on this... Nicole
Camera Raw 8.7 was introduced in PSE13. If your software is too old to be compatible. Yu have two choices:
- Upgrade to the latest version PSE14
- Converting your CR2 for Adobe (DNG) Raw and DNG files will work with PSE11
The Adobe's DNG Converter is free, and you can batch process all of a file CR2 by selecting a source folder and destination folder.
-
Need help with the update server behaviors and deleting records
I am 'trying' to use the update and delete record server behaviors and I can't get the redirection page to set up correctly. What I'm trying to do, is to have the redirection came up with the right records depending on the CompId page. It seems that it is taking the CompId and agreementId (which are my unique ID) and use them in the url of the redirection page. Also, it updates the table. Here is the url that appears after I have send the update:
http://localhost:8888/dotweb/maintenance/agreement_home.php?CompId= & agreementId = 7
Here is the code for the update page:
Pending patent, trade mark, Tradesecret and straightened to copy recordedCopyright KML designs 2009Can someone tell me why it would show the CompId and agreementId when everything I asked the CompId? Thanks for your help. Just in case, I enclose you an html version of this file. It must be a php file, but is not one of the allowed file types.
CompId is not filled in the URL because you try to use the result of the rsAgree recordset object until the result of the recordset is created. However, you pass the CompId value via array $_POST as a hidden field.
Change this line (52):
$updateGoTo = "agreement_home.php?CompId=" . $row_rsAgree['CompId'] . "";
to do this:
$updateGoTo = "agreement_home.php?CompId=" . $_POST['CompId'];
-
Helps with the UPDATE statement
Hello
I have a table like this:
data in the table:create table test (id number, stat number, id_num number);
I want to update the column id_num with serial number under the same ID.insert into table test (id,stat,id_num) values (1,112,''); insert into table test (id,stat,id_num) values (1,123,''); insert into table test (id,stat,id_num) values (2,134,''); insert into table test (id,stat,id_num) values (2,111,''); insert into table test (id,stat,id_num) values (3,112,''); insert into table test (id,stat,id_num) values (4,111,''); insert into table test (id,stat,id_num) values (4,12,''); insert into table test (id,stat,id_num) values (4,11,'');
Below is the table with coloumn successfully updated.
Can someone give me a hint how to remove this?insert into table test (id,stat,id_num) values (1,112,1); insert into table test (id,stat,id_num) values (1,123,2); insert into table test (id,stat,id_num) values (2,134,1); insert into table test (id,stat,id_num) values (2,111,2); insert into table test (id,stat,id_num) values (3,112,1); insert into table test (id,stat,id_num) values (4,111,1); insert into table test (id,stat,id_num) values (4,12,2); insert into table test (id,stat,id_num) values (4,11,3);
Thank you very much for your help!user13071990 wrote:
Manik which is not a good solution because dat_document can also be duplicated.Alberto is no uniq key in the table, which is the main problem.
It is not a good way to get the table without unique keys.
To work around the problem, I suggest that, despite the fact that I do not use virtual ROWID.
I did a test by inserting a date twice for the same id
insert into test (id,dat_document,id_num) values (4,to_date('01.07.2012','dd.mm.yyyy'),'');
Now, I used:
MERGE INTO test a USING (SELECT rowid , ROW_NUMBER () OVER (PARTITION BY id ORDER BY dat_document) AS val FROM test) b ON (a.rowid = b.rowid) WHEN MATCHED THEN UPDATE SET id_num = val; SELECT * FROM test ORDER BY id, dat_document; ID DAT_DOCUMENT ID_NUM ---------- --------------------- ---------- 1 01-01-2012 00:00:00 1 1 01-02-2012 00:00:00 2 2 01-03-2012 00:00:00 1 2 01-04-2012 00:00:00 2 3 01-05-2012 00:00:00 1 4 01-06-2012 00:00:00 1 4 01-07-2012 00:00:00 2 4 01-07-2012 00:00:00 3 4 01-08-2012 00:00:00 4
Kind regards.
Al -
Need help with the insert statement
Hello
I have a question on how to write a SQL statement.
This is the table of "base":
and it comes to resoult in the target table. SQL statement must take care of the insert in a base of the target table table (example below is already provided with test data).CREATE TABLE TEMP_TBL ( id_nr NUMBER, DATE_DOK DATE, DATE_DUE DATE, DATE_DOK_PAY DATE, DEB NUMBER, KRD NUMBER ); insert into temp_tbl (ID_NR,DATE_DOK,DATE_DUE,DATE_DOK_PAY,DEB,KRD)values('1',TO_DATE('11.01.2011','DD.MM.YYYY'),TO_DATE('25.02.2011','DD.MM.YYYY'),NULL,'423,24','0'); insert into temp_tbl(ID_NR,DATE_DOK,DATE_DUE,DATE_DOK_PAY,DEB,KRD)values('2',TO_DATE('16.12.2011','DD.MM.YYYY'),TO_DATE('13.06.2011','DD.MM.YYYY'),NULL,'91270,15','0'); insert into temp_tbl(ID_NR,DATE_DOK,DATE_DUE,DATE_DOK_PAY,DEB,KRD)values('3',TO_DATE('27.09.2011','DD.MM.YYYY'),TO_DATE('27.09.2011','DD.MM.YYYY'),NULL,'0','2000');
If someone could give me a helping hand how write correct insert statement I would be really gratefull.create table table_sod ( id_nr number ,date_from date ,date_to date ,deb_krd number ); One thing to note here : values in column deb_krd under insert 1 and 4 must be summarized in insert 4. insert into table_sod (id_nr,date_from,date_to,deb_krd) values('1',null,to_date('25.02.2011','dd.mm.yyyy'),'423,24'); insert into table_sod(id_nr,date_from,date_to,deb_krd) values('2',to_date('26.02.2011','dd.mm.yyyy'),to_date('13.06.2011','dd.mm.yyyy'),'423,24'); insert into table_sod(id_nr,date_from,date_to,deb_krd)values('3',null,to_date('13.06.2011','dd.mm.yyyy'),'91270,15'); insert into table_sod(id_nr,date_from,date_to,deb_krd)values('4',to_date('14.06.2011','dd.mm.yyyy')to_date('27.09.2011','dd.mm.yyyy'),'91693,39'); insert into table_sod(id_nr,date_from,date_to,deb_krd)values('5',null,to_date('27.09.2011','dd.mm.yyyy'),'2000');
Thank you for your time!I came here with my own assumptions with this
SQL> select rownum id_nr 2 , date_from 3 , date_to 4 , case when date_from is null then deb 5 else sum(case when date_from is not null then deb else 0end) over(order by id_nr, no) 6 end deb_krd 7 from ( 8 select id_nr 9 , case when lg_dt is null or ld_dt = date_due then null else lg_dt+1 end date_from 10 , ld_dt date_to 11 , case when deb = 0 then krd else deb end deb 12 , no 13 from ( 14 select t1.* 15 , lead(t1.date_due) over(order by t1.id_nr, t2.no) ld_dt 16 , lag(t1.date_due) over(order by t1.id_nr, t2.no) lg_dt 17 , t2.no 18 from temp_tbl t1 19 cross 20 join (select 1 no from dual union all select 2 no from dual) t2 21 order by id_nr, no 22 ) 23 where ld_dt is not null 24 ) 25 / ID_NR DATE_FROM DATE_TO DEB_KRD ---------- --------- --------- ---------- 1 25-FEB-11 42324 2 26-FEB-11 13-JUN-11 42324 3 13-JUN-11 9127015 4 14-JUN-11 27-SEP-11 9169339 5 27-SEP-11 2000
-
Need help with the IF statement.
I am trying to write an IF statement using FormCalc in LiveCycle. I have the "tpe" cell that captures the total number of points. I would attribute levels based on the number of points obtained. For example, level I = 1001-1985; level II = 851-1000; level III = 551-850; level IV = < 551. I want to 'level' of cell to show I, II, III or IV, based on the points in the cell "tpe". How can I do this? I have zero familiarity with FormCalc or scripts in general. Can someone help me with this please? Would appreciate any help! Thank you!
Just put the script in the field calculate level instead:
If (tpe tpe and > 1000<= 1985)="">=>
$ = "I"
ElseIf (tpe > 850 and tpe<= 1000)="">=>
$ = « II »
ElseIf (tpe > 550 and tpe<= 850)="">=>
$ = 'III'
ElseIf (tpe<= 550)="">=>
$ = « IV »
else $ = «»
endif
Also just have a glance to your form - for the next time that you could save yourself a lot of time in your configuration through the use of tables for all of these fields, rather than making each a numeric field separated.
-
I need help with the updates listed below
I tried several times to install updates as follows: KB 2468871 KB 2533523 for my Vista SP2 program with a 32-bit and I get the error message 643 / I use Chrome most of the time, but I also have IE.
You're certainly not alone...
You can try to repair the .NET Framework 4 and if that doesn't work, download updates relevant manually and install the same.
To repair the .NET Framework 4 Client Profile or .NET Framework 4 extended etc. -.
· Click on start/Orb and click on Control Panel.
· Go to the program and features.
· Locate the Microsoft.Net Framework 4 Client Profile or .NET Framework 4 extended, right-click.
· You should have the choice to repair or uninstall/change, click it.
· This will then give you the opportunity to fix it
· Select the repair option.
Manual download of updates (just search for the most relevant to your problem)
1. http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=27017 (KB2539636)
2. http://www.microsoft.com/download/en/details.aspx?id=3556 (KB2468871)
3. http://www.microsoft.com/download/en/details.aspx?id=27014 (KB2533523)Make sure you download the one appropriate for your system.
http://support.Microsoft.com/kb/827218
Install as administrator.
Addition, it is rather a big discussion here:
-
Need help with the conditional statement.
I have a conditional configuration to check the 6 values, and I don't know how to put in place. I know that the way I have it Setup is wrong, but I'm stuck here after several attempts of other variants.
LINE OF CODE IN QUESTION:
If (eventObject.info.name! = "marker2" |) "marker4" | "marker5" | "marker6" | "marker7" | "marker8")
FULL CODE BLOCK:
var listenerObject:Object = new Object();
listenerObject.cuePoint = {function(eventObject:Object):Void}
If (eventObject.info.name! = "marker2" |) "marker4" | "marker5" | "marker6" | "marker7" | {"marker8")}
var listenerObject:Object = new Object();
listenerObject.stateChange = {function(eventObject:Object):Void}
trace (_root.theVideo.State);
If {(_root.theVideo.paused)
mclContinue._visible = true;
var myTween:TweenLite = new TweenLite (mclContinue,.35, {_alpha:100, ease:Back.easeOut, onComplete:contBtn});})
} else {}
var myTween:TweenLite = new TweenLite (mclContinue,.35, {_alpha:0, ease:Back.easeOut, onComplete:contBtn});})
}
}
_root.theVideo.addEventListener ("stateChange", listenerObject)
}
}
_root.theVideo.addEventListener ("cuePoint", listenerObject)
Thank you.You are welcome.
-
I need help with the program of Photos on my macbook pro
I use a Macbook Pro with OS of Yosemite. I really need help with the Photo program. I never really got the hang of IPhoto and now that it's a new program, I'm really confused. Where can I go to learn this without waiting for the next workshop in a local store?
Hi, I'm fighting to open same mine, making a new software update
-
Hi, I need help with installing updates for CS5
Hi, I need help with the installation of the updates of CS5. I get the following message: some updates to installation failure. My product is already registered. Can someone help me, please?
Erkan please download and apply updates directly from updates.
-
Need help with the installation of an adapter of graphics Super Palit GeForce 9500GT - 512 MB - DDR2 SDRAM in a M2N68 motherboard (narra6). Should I disable the onboard graphics in the bios? When the card is installed, no VGA work outs and the PC does not start. Checked and recontroler implementation of the card in the PCI slot. PC is a desktop HP G5200uk PC. Windows 7 operating system.
Hello
The link below is a guige to install a video card in your Pc. In particular, it seems that you will have to perhaps specify the location of the new card in the bios and save this change before you install the new card - see step 4 in the guide on the link below. If your new card fits into the PCI Express x 16 slot, you will need to define PCI Express in the bios and save the changes.
http://support.HP.com/us-en/document/c01700855
Kind regards
DP - K
-
Need help with the launching track pack for forza code 4
Bought new Forza 4 and the lancer Track Pack code does not work, how do I get a code that is generated in the form I've already paid for it. Rank of loads of numbers and sent 10 s of emails but cant seem to get help.
This is the help I get when the cat to an Ambassador xbox on xbox.com
Terry wrote:Need help with the launching track pack for forza code 4The Xbox Ambassador says:Location of Ambassador of the community...The Xbox Ambassador says:Location of Ambassador of the community...The Xbox Ambassador says:Your question will be answered by an Ambassador of the Xbox. You have been connected to the Ambassador as a user Xbox [3]The Xbox Ambassador says:HelloTerry wrote:HelloThe Xbox Ambassador says:HeyTerry wrote:just to be on the phone to xbox live support and was told to come hereThe Xbox Ambassador says:ok\The Xbox Ambassador says:What is your problem?Terry wrote:I bought the 4 for forza ansd 360 new sealed Christmas...Terry wrote:has got 2 codes that accompanies the game but the pack track code does not workThe Xbox Ambassador says:Wow goodTerry wrote:whenever I put in the code it says code redeemedThe Xbox Ambassador says:I think the code is used. You must return to the retailerTerry wrote:I tried to, but since I already opened the case they will not acceptThe Xbox Ambassador says:Oh. No,Terry wrote:the code had been used or defective as I am the only person who has touched the game once opened, tried to enter the code when it is openThe Xbox Ambassador says:Maybe it was auto bought?Terry wrote:so, how do I get another code generated track Pack if defective?The Xbox Ambassador says:I do not know.Terry wrote:bought the game new, so I get the track packThe Xbox Ambassador says:Oh. It's bad.The Xbox Ambassador says:I think that if you Exchange 1 code it will buy itTerry wrote:car pack code worked, starter pack did not workThe Xbox Ambassador says:Oh.The Xbox Ambassador says:It's a badThe Xbox Ambassador says:BTW you have an evolution of the tests?Terry wrote:Yes, I want to? but more anxious to get a code object generated for this packThe Xbox Ambassador says:Hey if I help can u give me this game too?Terry wrote:?????????????????Terry wrote:So is it possible to get a code for that time?The Xbox Ambassador says:HeyThe Xbox Ambassador says:Yes.The Xbox Ambassador says:you need to contact themThe Xbox Ambassador says:and tell them that the code is used.Terry wrote:I was told to come here? where can I go to get the code?Hi Terryg76,
· What version of the operating system is installed on the computer?
I suggest you to contact the game manufacturer for more help and information.
Maybe you are looking for
-
HP 15-r248nf: hdmi port not recognized on HP laptop after windows 10 update
Need help! My laptop HP HDMI port does not work, apparently, that the HDMI is not recognized after the last windows 10 updated.
-
Don't know what to write.
-
Suggestion on the desktop box stay
As you know, when you type in Japanese, there is always a Japanese suggestion pop up under the word we type. This box to disappear when you press on enter to confirm the word. I use Memrise on Safari, the way it works is that: pages give me 10 second
-
Possible sources of internal ArmStartTrigger to 6602
Hello I use a card PCI-6602 in my application and I use all the input channels compared to 8 to count the edges of the PWM signals. Everything works well except for one thing. It is essential that the counting of all 8 channels start at the same time
-
Hello. I have a problem where the best path to a particular destination is removed by BGP. To explain. Site A has 2 links to site B. 1 via a peer eBGP on MPLS, 2 via an iBGP during a backup VPN peer. I configured the ebgp with a higher weight counter