久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<i id='YXaAA'><tr id='YXaAA'><dt id='YXaAA'><q id='YXaAA'><span id='YXaAA'><b id='YXaAA'><form id='YXaAA'><ins id='YXaAA'></ins><ul id='YXaAA'></ul><sub id='YXaAA'></sub></form><legend id='YXaAA'></legend><bdo id='YXaAA'><pre id='YXaAA'><center id='YXaAA'></center></pre></bdo></b><th id='YXaAA'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='YXaAA'><tfoot id='YXaAA'></tfoot><dl id='YXaAA'><fieldset id='YXaAA'></fieldset></dl></div>
    • <bdo id='YXaAA'></bdo><ul id='YXaAA'></ul>
    <legend id='YXaAA'><style id='YXaAA'><dir id='YXaAA'><q id='YXaAA'></q></dir></style></legend>

    1. <small id='YXaAA'></small><noframes id='YXaAA'>

    2. <tfoot id='YXaAA'></tfoot>

      1. 嵌套計(jì)算列“無(wú)效的列名"錯(cuò)誤(T-SQL 列別名

        Nested computed column quot;Invalid column namequot; error (T-SQL Column alias)(嵌套計(jì)算列“無(wú)效的列名錯(cuò)誤(T-SQL 列別名))
      2. <tfoot id='dv5P9'></tfoot>
        • <i id='dv5P9'><tr id='dv5P9'><dt id='dv5P9'><q id='dv5P9'><span id='dv5P9'><b id='dv5P9'><form id='dv5P9'><ins id='dv5P9'></ins><ul id='dv5P9'></ul><sub id='dv5P9'></sub></form><legend id='dv5P9'></legend><bdo id='dv5P9'><pre id='dv5P9'><center id='dv5P9'></center></pre></bdo></b><th id='dv5P9'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='dv5P9'><tfoot id='dv5P9'></tfoot><dl id='dv5P9'><fieldset id='dv5P9'></fieldset></dl></div>

          • <bdo id='dv5P9'></bdo><ul id='dv5P9'></ul>
                <tbody id='dv5P9'></tbody>
            • <legend id='dv5P9'><style id='dv5P9'><dir id='dv5P9'><q id='dv5P9'></q></dir></style></legend>

                <small id='dv5P9'></small><noframes id='dv5P9'>

                  本文介紹了嵌套計(jì)算列“無(wú)效的列名"錯(cuò)誤(T-SQL 列別名)的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  限時(shí)送ChatGPT賬號(hào)..

                  我創(chuàng)建了 3 個(gè)計(jì)算列作為別名,然后使用別名列來(lái)計(jì)算總成本.這是查詢:

                  I've create 3 computed columns as alias and then used the aliased columns to calculate the total cost. This is the query:

                  SELECT TOP 1000 [Id]
                        ,[QuantityOfProduct]
                        ,[Redundant_ProductName]
                        ,[Order_Id]
                        ,(CASE 
                              WHEN [PriceForUnitOverride] is NULL 
                                  THEN [Redundant_PriceForUnit]
                              ELSE
                                  [PriceForUnitOverride]
                          END
                          ) AS [FinalPriceForUnit]
                  
                        ,(CASE 
                              WHEN [QuantityUnit_Override] is NULL 
                                  THEN [Redundant_QuantityUnit]
                              ELSE
                                  [QuantityUnit_Override]
                          END
                          ) AS [FinalQuantityUnit]
                  
                        ,(CASE 
                              WHEN [QuantityAtomic_Override] is NULL 
                                  THEN [Redundant_QuantityAtomic]
                              ELSE
                                  [QuantityAtomic_Override]
                          END
                          ) AS [Final_QuantityAtomic]
                  
                           --***THIS IS WHERE THE QUERY CREATES AN ERROR***--
                          ,([QuantityOfProduct]*[FinalPriceForUnit]*
                    ([Final_QuantityAtomic]/[FinalQuantityUnit])) AS [Final_TotalPrice]
                  
                  
                    FROM [dbo].[ItemInOrder]
                  
                    WHERE [IsSoftDeleted] = 0
                    ORDER BY [Order_Id] 
                  

                  控制臺(tái)返回此錯(cuò)誤消息:

                  The console returns this ERROR message:

                  Msg 207, Level 16, State 1, Line 55
                  Invalid column name 'FinalPriceForUnit'.
                  Msg 207, Level 16, State 1, Line 55
                  Invalid column name 'Final_QuantityAtomic'.
                  Msg 207, Level 16, State 1, Line 55
                  Invalid column name 'FinalQuantityUnit'.
                  

                  如果我刪除AS [Final_TotalPrice]"別名計(jì)算列,則不會(huì)發(fā)生錯(cuò)誤,但我需要總價(jià).我該如何解決這個(gè)問(wèn)題?似乎在達(dá)到 Final_TotalPrice 時(shí)還沒(méi)有創(chuàng)建其他別名.

                  If I remove the "AS [Final_TotalPrice]" alias computed column, no error occurs, but I need the total price. How can I solve this issue? It seems as the other aliases have not been created when the Final_TotalPrice is reached.

                  推薦答案

                  不能在同一個(gè)選擇中使用表別名.正常的解決方案是 CTE 或子查詢.但是,SQL Server 也提供 APPLY.(Oracle 還支持 APPLY,其他數(shù)據(jù)庫(kù)(例如 Postgres)支持使用 LATERAL 關(guān)鍵字進(jìn)行橫向連接.)

                  You can't use table aliases in the same select. The normal solution is CTEs or subqueries. But, SQL Server also offers APPLY. (Oracle also supports APPLY and other databases such as Postgres support lateral joins using the LATERAL keyword.)

                  我喜歡這個(gè)解決方案,因?yàn)槟憧梢詣?chuàng)建任意嵌套的表達(dá)式而不必?fù)?dān)心縮進(jìn):

                  I like this solution, because you can create arbitrarily nested expressions and don't have to worry about indenting:

                  SELECT TOP 1000 io.Id, io.QuantityOfProduct, io.Redundant_ProductName,
                         io.Order_Id,
                         x.FinalPriceForUnit, x.FinalQuantityUnit, x.Final_QuantityAtomic,
                         (x.QuantityOfProduct * x.FinalPriceForUnit * x.Final_QuantityAtomic / x.FinalQuantityUnit
                         ) as Final_TotalPrice
                  FROM dbo.ItemInOrder io OUTER APPLY
                       (SELECT COALESCE(PriceForUnitOverride, Redundant_PriceForUnit) as FinalPriceForUnit,
                               COALESCE(QuantityUnit_Override, Redundant_QuantityUnit) as FinalQuantityUnit
                               COALESCE(QuantityAtomic_Override, Redundant_QuantityAtomic) as Final_QuantityAtomic
                       ) x
                  WHERE io.IsSoftDeleted = 0
                  ORDER BY io.Order_Id ;
                  

                  注意事項(xiàng):

                  • 我發(fā)現(xiàn) [] 根本無(wú)法幫助我閱讀或編寫(xiě)查詢.
                  • COALESCE() 比您的 CASE 語(yǔ)句簡(jiǎn)單得多.
                  • 使用 COALESCE(),您可能會(huì)考慮只將 COALESCE() 表達(dá)式放入最終計(jì)算中.
                  • I don't find that [ and ] help me read or write queries at all.
                  • COALESCE() is much simpler than your CASE statements.
                  • With COALESCE() you might consider just putting the COALESCE() expression in the final calculation.

                  這篇關(guān)于嵌套計(jì)算列“無(wú)效的列名"錯(cuò)誤(T-SQL 列別名)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Can I figure out a list of databases and the space used by SQL Server instances without writing SQL queries?(我可以在不編寫(xiě) SQL 查詢的情況下找出數(shù)據(jù)庫(kù)列表和 SQL Server 實(shí)例使用的空間嗎?) - IT屋-程序員軟件開(kāi)發(fā)
                  How to create a login to a SQL Server instance?(如何創(chuàng)建對(duì) SQL Server 實(shí)例的登錄?)
                  How to know the version and edition of SQL Server through registry search(如何通過(guò)注冊(cè)表搜索知道SQL Server的版本和版本)
                  Why do I get a quot;data type conversion errorquot; with ExecuteNonQuery()?(為什么會(huì)出現(xiàn)“數(shù)據(jù)類型轉(zhuǎn)換錯(cuò)誤?使用 ExecuteNonQuery()?)
                  How to show an image from a DataGridView to a PictureBox?(如何將 DataGridView 中的圖像顯示到 PictureBox?)
                  WinForms application design - moving documents from SQL Server to file storage(WinForms 應(yīng)用程序設(shè)計(jì)——將文檔從 SQL Server 移動(dòng)到文件存儲(chǔ))

                  <small id='3Vzuf'></small><noframes id='3Vzuf'>

                      <tfoot id='3Vzuf'></tfoot>
                        <bdo id='3Vzuf'></bdo><ul id='3Vzuf'></ul>

                        <i id='3Vzuf'><tr id='3Vzuf'><dt id='3Vzuf'><q id='3Vzuf'><span id='3Vzuf'><b id='3Vzuf'><form id='3Vzuf'><ins id='3Vzuf'></ins><ul id='3Vzuf'></ul><sub id='3Vzuf'></sub></form><legend id='3Vzuf'></legend><bdo id='3Vzuf'><pre id='3Vzuf'><center id='3Vzuf'></center></pre></bdo></b><th id='3Vzuf'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='3Vzuf'><tfoot id='3Vzuf'></tfoot><dl id='3Vzuf'><fieldset id='3Vzuf'></fieldset></dl></div>

                              <tbody id='3Vzuf'></tbody>
                            <legend id='3Vzuf'><style id='3Vzuf'><dir id='3Vzuf'><q id='3Vzuf'></q></dir></style></legend>
                            主站蜘蛛池模板: 国产精品亚洲精品久久 | 国产亚洲精品美女久久久久久久久久 | 国产精品日产欧美久久久久 | 福利视频三区 | 亚洲激情在线观看 | 欧美在线一级 | 久久久久久九九九九九九 | 欧美日韩在线免费 | 欧美乱码精品一区二区三区 | 色综合网站 | 91久久精品一区二区二区 | 久久国产精品99久久久久 | 天天弄天天操 | 久久精品性视频 | 欧美a在线观看 | 欧美日韩国产中文 | 99成人免费视频 | 69堂永久69tangcom | 久久久久久免费毛片精品 | 成人免费影院 | 人人做人人澡人人爽欧美 | 国产精品久久国产精品 | 色婷婷一区 | 草久久 | 啪一啪在线视频 | 日韩一区二区三区av | 欧美日韩成人在线观看 | 欧美久久不卡 | 国产免国产免费 | 久久综合久久久 | 特级毛片 | 免费色网址 | 亚洲91精品 | 中文字幕在线视频观看 | 亚洲福利视频网 | 欧美在线一区二区三区四区 | 精品网| 久久天堂| 精品视频在线观看 | 四虎成人精品永久免费av九九 | 国产精品毛片一区二区三区 |