| Author |
Topic |
|
elkhanssaa
Starting Member
5 Posts |
Posted - 2008-05-09 : 07:24:56
|
| je voulais une requette ou une procedure qui calcule en faisant un update pour faire la chose suivante (sqlserver2005):date objet leg12/02/2002 X leg112/02/2002 X leg212/02/2002 X leg312/02/2002 Y leg112/02/2002 Y leg2Merci |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-05-09 : 07:29:49
|
UPDATE fSET f.Leg = 'Leg' + f.RecIDFROM (SELECT Leg, ROW_NUMBER() OVER (PARTITION BY Date, Objet ORDER BY Date) AS RecID) AS f E 12°55'05.25"N 56°04'39.16" |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-05-09 : 07:30:30
|
Google gave me this translation: quote: I wanted a requette or a procedure by which calculates an update to the next thing
Please post expected output and your request in plain english please.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-05-09 : 07:31:35
|
quote: Originally posted by Peso UPDATE fSET f.Leg = 'Leg' + f.RecIDFROM (SELECT Leg, ROW_NUMBER() OVER (PARTITION BY Date, Objet ORDER BY Date) AS RecID) AS f E 12°55'05.25"N 56°04'39.16"
So, you have cross-language mind reading capabilities as well, Peter?Cool! Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-05-09 : 07:33:29
|
Je parle francais...Requette is misspelled, should say requete and means "query"."I want a query or a procedure which updates to do the following thing" would be a fairly proper translation.Und ich spreche Deutsches auch! E 12°55'05.25"N 56°04'39.16" |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-05-09 : 07:42:31
|
quote: Originally posted by Peso Je parle francais...Requette is misspelled, should say requete and means "query"."I want a query or a procedure which updates to do the following thing" would be a fairly proper translation.Und ich spreche Deutsches auch! E 12°55'05.25"N 56°04'39.16"
Das ist interessant!Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
elkhanssaa
Starting Member
5 Posts |
Posted - 2008-05-09 : 07:44:27
|
| Merci pour votre réponseLa table est fact:Date :scheduled_departureobjet :plane_skmais il me donne des erreurs de compilation Msg 207, Niveau 16, État 1, Ligne 4Nom de colonne non valide : 'leg'.Msg 207, Niveau 16, État 1, Ligne 4Nom de colonne non valide : 'Scheduled_Departure'.Msg 207, Niveau 16, État 1, Ligne 4Nom de colonne non valide : 'Plane_sk'.Msg 207, Niveau 16, État 1, Ligne 4Nom de colonne non valide : 'Scheduled_Departure'. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-05-09 : 07:46:00
|
My mistake. Try thisUPDATE fSET f.Leg = 'Leg' + f.RecIDFROM (SELECT Leg, ROW_NUMBER() OVER (PARTITION BY Date, Objet ORDER BY Date) AS RecIDFROM YourOriginalTableNameHere) AS f E 12°55'05.25"N 56°04'39.16" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-05-09 : 07:47:31
|
Si vous voulez l'aide appropriee, vous devriez signaler votre definition de table de sorte que nous puissions voir que quelle colonne existe et quelle colonnes pas existe. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-05-09 : 07:47:43
|
quote: Originally posted by Peso My mistake. Try thisUPDATE fSET f.Leg = 'Leg' + CAST(f.RecID AS VARCHAR(10))FROM (SELECT Leg, ROW_NUMBER() OVER (PARTITION BY Date, Objet ORDER BY Date) AS RecIDFROM YourOriginalTableNameHere) AS f E 12°55'05.25"N 56°04'39.16"
Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
elkhanssaa
Starting Member
5 Posts |
Posted - 2008-05-09 : 08:06:16
|
| merci bcpen fait ça marchait avec :UPDATE fSET f.Leg =f.RecIDFROM (SELECT Leg, ROW_NUMBER() OVER (partition by scheduled_departure order by scheduled_departure,plane_sk) AS RecIDFROM fact) AS fmais il trie pa les date en executant ta requette initiale il donne12/05/2009 00:00:00 222 2 111/05/2009 00:00:00 88 1 2211/05/2009 00:00:00 88 2 7719/08/2006 00:00:00 44 1 4411/05/2009 00:00:00 222 1 77712/05/2009 00:00:00 222 1 66NULL NULL NULL NULL |
 |
|
|
elkhanssaa
Starting Member
5 Posts |
Posted - 2008-05-09 : 08:11:47
|
| En fait stp comment on peut ajouter une condition :scheduled_departure>=11/05/2009merci bcp |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-05-09 : 08:13:07
|
Which columns do you want the Leg number to be partitioned by?In you initial example I thought it was obvious that Date should be included.You have to specify your business rules more clearly.Scheduled_Departure was not even mentioned in your orignal post. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
elkhanssaa
Starting Member
5 Posts |
Posted - 2008-05-09 : 08:23:22
|
| en fait je voulais pour chaque date(departure scheduled) et plane_sk(objet) un leg qui s'incrémente et par ordre croissant de dateexp: 12/02/2002 A leg112/2/2002 A leg213/02/2002 A leg114/02/2002 B leg114/02/2002 B leg214/02/2002 X leg1avec 1 condition date> 13/02/2002(par exemple)Merci |
 |
|
|
|