我需要编写一个 sql select 语句,但我被卡住了。我正在尝试为复杂的 GRID 编写一个 sql。网格应该用于输入预算值。
这是我的网格应该看起来的样子。可以看到有 MAIN 行,每个主行有 4 个子行。我需要从 select 语句中产生相同的结果
不幸的是,我的选择语句产生如下数据表
SELECT TYPE,
NO,
DESCRIPTION,
ISNULL((SELECT VALUE FROM RN_BUDGET_INVEST_VALUES V WHERE V.BUDGET_ID=40 AND V.FIRMA_ID=2 AND V.DEPARTMENT_ID=200 AND V.MODULE_ID=6 AND V.YEAR=2013 AND V.COLUMN_INDEX=1 AND V.ROW_INDEX=1 AND V.CREATED_USER=1),0) AS 'OCAK',
ISNULL((SELECT VALUE FROM RN_BUDGET_INVEST_VALUES V WHERE V.BUDGET_ID=40 AND V.FIRMA_ID=2 AND V.DEPARTMENT_ID=200 AND V.MODULE_ID=6 AND V.YEAR=2013 AND V.COLUMN_INDEX=1 AND V.ROW_INDEX=1 AND V.CREATED_USER=1),0) AS 'ŞUBAT',
ISNULL((SELECT VALUE FROM RN_BUDGET_INVEST_VALUES V WHERE V.BUDGET_ID=40 AND V.FIRMA_ID=2 AND V.DEPARTMENT_ID=200 AND V.MODULE_ID=6 AND V.YEAR=2013 AND V.COLUMN_INDEX=1 AND V.ROW_INDEX=1 AND V.CREATED_USER=1),0) AS 'MART',
ISNULL((SELECT VALUE FROM RN_BUDGET_INVEST_VALUES V WHERE V.BUDGET_ID=40 AND V.FIRMA_ID=2 AND V.DEPARTMENT_ID=200 AND V.MODULE_ID=6 AND V.YEAR=2013 AND V.COLUMN_INDEX=1 AND V.ROW_INDEX=1 AND V.CREATED_USER=1),0) AS 'NİSAN',
ISNULL((SELECT VALUE FROM RN_BUDGET_INVEST_VALUES V WHERE V.BUDGET_ID=40 AND V.FIRMA_ID=2 AND V.DEPARTMENT_ID=200 AND V.MODULE_ID=6 AND V.YEAR=2013 AND V.COLUMN_INDEX=1 AND V.ROW_INDEX=1 AND V.CREATED_USER=1),0) AS 'MAYIS',
FROM RN_BUDGET_INVESTMENT_VARIABLES VARS
我不知道如何创建子行。你能给我一个 iade 吗?