gpt4 book ai didi

sql - 这个声明是如何运作的?

转载 作者:行者123 更新时间:2023-12-01 16:55:17 27 4
gpt4 key购买 nike

SQL select Statement

这是一个基本的选择语句,它从“选择”开始,然后是来自一个表的所有行。为什么会有 '' 以及它的作用是什么?我知道如何使用列和表别名,或者用不同的名称命名列“AS something”。我已经看过好几次了,但从来不知道它试图执行什么。

SELECT '' AS prSkipCustomInfo
, '' AS WBS1
, '' AS WBS2
, '' AS WBS3
, '' AS SubLevel1
, '' AS SubLevel2
, '' AS SubLevel3
, '' AS WBS1Name
, '' AS ProjectManager
, '' AS Principal
, '' AS Supervisor
, '' AS ClientID
, '' AS ContactID
, '' AS ChargeType
, '' AS revType
, '' AS currencyCodeProj
, '' AS currencyCodeBill
, '' AS currencyCodeFunct
, '' AS currencyCodePres
, 0 AS currencyCodeProjCount
, 0 AS currencyCodeBillCount
, 0 AS currencyCodeFunctCount
, 0 AS currencyCodePresCount
, '' AS Account
, '' AS TransType
, '' AS SubType
, '' AS Transfer
, '' AS rectype
, '' AS rectypelabel
, '' AS rectypesub
, '' AS rectypesublabel
, 0 AS Period
, 0 AS PostSeq
, TransDate
, '' AS RefNo
, '' AS Desc1
, '' AS Desc2
, 0.00 AS Amount
, '' AS Invoice
, 0 AS Line
, '' AS VendOrg
, '' AS XferWBS1
, '' AS XferWBS2
, '' AS XferWBS3
, '' AS BillStatus
, '' AS AcctName
, '' AS AcctClass
, '' AS AcctSubClass
, '' AS Org
, '' AS Vendor
, '' AS VendName
, '' AS VendUnit
, '' AS Voucher
, '' AS Documents
, '' AS PKey
, 0 AS UnitQuantity
, 0.00 AS UnitBillRate
, 0.00 AS UnitCostRate
FROM dbo.LedgerAP

最佳答案

当您需要表中的某些列而其余只是占位符以匹配所需结果集时,这是常见的模式。

您将获得与表 dbo.LEDGERAP 中一样多的行。

SELECT
'' AS prSkipCustomInfo,
-- ...
TransDate, --here goes actual value from source table
--...
FROM dbo.LedgerAP

关于sql - 这个声明是如何运作的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50236285/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com