![](/img/trans.png)
[英]How can I turn SQL query that joins two columns and groups by count of one column and a column of each joined table into LINQ?
[英]How to make a SQL query to display two columns values to one column?
我有一個如下所示的表結構。 我想在名稱的父項下顯示名稱(父項是分類帳組)
DECLARE @t1 TABLE
(
ParentGroup varchar(20),
LedgerName varchar(20),
TotalDebit float,
credit float
)
INSERT INTO @t1
SELECT *
FROM Table1
INSERT INTO @t1
SELECT Distinct ParentGroup, ParentGroup, NULL, NULL
FROM Table1
Select LedgerName, TotalDebit, credit from @t1
group by LedgerName, TotalDebit, credit
ORDER BY (CASE WHEN TotalDebit IS NULL THEN 0 ELSE TotalDebit END)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.