祝各位道友念头通达
GitHub Gitee 语雀 打赏

sql select查询动态添加列,标识列

1. 使用单引号, 默认值(标识列)

  select 
      'good' as "ELable",
    "DGHashId" as "EHashId",
    "DHashId" as "DHashId",
    "PHashId" as "PHashId",
    "DSNames" as "EContent",    
    "DGDiagnosisTime" as "EDateTime",
    "DGStatus" as "EStatus",
    "DGUpdateTime" as "ECreateTime"
    from "Diagnosis" where
        "DHashId" ='4444444444444444'
        and "PHashId" = 'c61b362b1c9dcd09'
        and "DGStatus" = 1

效果图如下:

 

 1. 使用ROW_NUMBER() ;(优点,主要用排序功能)

 select 
      row_number() over(order by "DHashId") as "ELable",
    "DGHashId" as "EHashId",
    "DHashId" as "DHashId",
    "PHashId" as "PHashId",
    "DSNames" as "EContent",    
    "DGDiagnosisTime" as "EDateTime",
    "DGStatus" as "EStatus",
    "DGUpdateTime" as "ECreateTime"
    from "Diagnosis" where
        "DHashId" ='4444444444444444'
        and "PHashId" = 'c61b362b1c9dcd09'
        and "DGStatus" = 1

效果如下图:

 

posted @ 2019-10-29 16:18  韩若明瞳  阅读(3334)  评论(0编辑  收藏  举报