zoukankan      html  css  js  c++  java
  • SQL语句如何更改重复的记录

    更改Table中字段refinv里的内容,有重复的内容在后面加数字,后面的数字是有序的。
    原表:
    id          refinv               price                  date
    ----------- -------------------- ---------------------- -----------------------
    1           060108CS             2                      2006-12-04 15:55:56.680
    2           060109CS             3.5                    2006-12-04 15:55:56.680
    3           060109CS             5                      2006-12-04 15:55:56.680
    4           060110CS             6                      2006-12-04 15:55:56.680
    5           060110CS             9                      2006-12-04 15:55:56.680
    6           060110CS             8                      2006-12-04 15:55:56.680
    更新后的新表:
    id          refinv               price                  date
    ----------- -------------------- ---------------------- -----------------------
    1           060108CS             2                      2006-12-04 15:57:04.290
    2           060109CS-1           3.5                    2006-12-04 15:57:04.290
    3           060109CS-2           5                      2006-12-04 15:57:04.290
    4           060110CS-1           6                      2006-12-04 15:57:04.290
    5           060110CS-2           9                      2006-12-04 15:57:04.290
    6           060110CS-3           8                      2006-12-04 15:57:04.290
    SQL语句:
    create table #tmp(id int identity(1,1) primary key,
    refinv varchar(20),price float,date datetime DEFAULT (getdate())
    )
    insert into #tmp(refinv,price)
    select '060108CS','2'
    union all
    select '060109CS','3.5'
    union all
    select '060109CS','5'
    union all
    select '060110CS','6'
    union all
    select '060110CS','9'
    union all
    select '060110CS','8'

  • 相关阅读:
    20150607-0608
    20150423
    感触
    NSString里面的数字
    Git使用相关
    状态栏的设置
    UI相关问题
    分栏(标签)控制器
    导航控制器
    NSAttributedString 属性
  • 原文地址:https://www.cnblogs.com/martian6125/p/9631279.html
Copyright © 2011-2022 走看看