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'

  • 相关阅读:
    Java中的Set List HashSet互转
    Java数组如何转为List集合
    Map
    Jave中的日期
    mybatis plus 条件构造器queryWrapper学习
    Error running 'JeecgSystemApplication': Command line is too long. Shorten command line for JeecgSystemApplication or also for Spring Boot default configuration.
    RBAC权限系统分析、设计与实现
    html拼接时onclick事件传递json对象
    PostgreSQL 大小写问题 一键修改表名、字段名为小写 阅读模式
    openssl创建的自签名证书,使用自签发证书--指定使用多域名、泛域名及直接使用IP地址
  • 原文地址:https://www.cnblogs.com/martian6125/p/9631279.html
Copyright © 2011-2022 走看看