Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Regenerate sno
Message
De
13/07/2017 15:23:27
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
13/07/2017 03:50:57
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows 7
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01652643
Message ID:
01652648
Vues:
49
>Dear Experts
>
>Sir, I am SQLSERVER 2008 R2.
>Table has smalldatetime column and data looks like image1
>
>
>
>In original table, I want to regenerate sno column on date+party index like image2
>(sorted on date+party)
>
>
>
>Please help


sno is persistent or imaginary? If so you would need to an update query else a simple select would do.

sno doesn't exist as a column and generate on the fly:
   select [date], row_number() over (partition by cast([date] as date) order by cast([date] as date), party) as sno, party
   from myTable
   order by cast([date] as date), party
sno exists, update and return with updated values:
with mySort (date, sno, party) as 
(
   select [date], row_number() over (partition by cast([date] as date) order by cast([date] as date), party) as sno, party
   from myTable
)
update myTable
set sno = mySort.sno
from mySort 
where mySort.date = myTable.date and mySort.party = myTable.party;

select [date], sno, party
   from myTable
  order by cast([date] as date), sno
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform