Hallo zusammen,
ich bin neu mit SQL, jetzt versuche ich eine Hierarchie im SQL aufzubauen. aber das geht leider noch nicht. Könntest du bitte mir helfen? Vielen Dank.
i have 3 tables: structures, account range and accountvalueUSD. From the hierarchy of parent and child ID in table structure, i want to create a hierarchy like this :
Level 1 .. Level 2.. Level 3 ..Level 4 .. account .. valueusd
.... 111 ....... 112.......... 113....... 114......... 100........ 1000
.....111 ........ 112......... 113....... 114.......... 101....... 2000
The table structure links with table account range with key: financialitem
The table acountrange links with table account value with key: accountfrom and accountto with accountnumber
Thanks
structure:
CREATE TABLE [dbo].[structure](
[Financialitem] [nvarchar](3) NULL,
[ID] [int] NULL,
[ParentID] [int] NULL,
[ChildID] [int] NULL,
[NextID] [int] NULL,
[Level] [int] NULL
) ON [PRIMARY]
INSERT INTO [dbo].[structure]
VALUES
(111,1,null,2,null,1),
(112,2,1,3,null,2),
(113,3,2,4,null,3),
(114,4,3,null,null,4),
(221,5,2,6,null,3),
(222,6,5,null,7,4),
(223,7,5,null,null,4)
Table Accountrange:
CREATE TABLE [dbo].[accountrange](
[Financialitem] [nvarchar](3) NULL,
[Accountfrom] [int] NULL,
[Accountto] [int] NULL
) ON [PRIMARY]
INSERT INTO [dbo].[accountrange]
VALUES
(114,100,105),
(222,200,205),
(223,300,305)
Table Account Value:
CREATE TABLE [dbo].[accountvalue](
[accountnumber] [int] NULL,
[valuesUSD] [int] NULL,
) ON [PRIMARY]
INSERT INTO [dbo].[accountvalue]
VALUES
(100,1000),
(101,2000),
(301,1500),
(201,1400)
ich bin neu mit SQL, jetzt versuche ich eine Hierarchie im SQL aufzubauen. aber das geht leider noch nicht. Könntest du bitte mir helfen? Vielen Dank.
i have 3 tables: structures, account range and accountvalueUSD. From the hierarchy of parent and child ID in table structure, i want to create a hierarchy like this :
Level 1 .. Level 2.. Level 3 ..Level 4 .. account .. valueusd
.... 111 ....... 112.......... 113....... 114......... 100........ 1000
.....111 ........ 112......... 113....... 114.......... 101....... 2000
The table acountrange links with table account value with key: accountfrom and accountto with accountnumber
Thanks
structure:
CREATE TABLE [dbo].[structure](
[Financialitem] [nvarchar](3) NULL,
[ID] [int] NULL,
[ParentID] [int] NULL,
[ChildID] [int] NULL,
[NextID] [int] NULL,
[Level] [int] NULL
) ON [PRIMARY]
INSERT INTO [dbo].[structure]
VALUES
(111,1,null,2,null,1),
(112,2,1,3,null,2),
(113,3,2,4,null,3),
(114,4,3,null,null,4),
(221,5,2,6,null,3),
(222,6,5,null,7,4),
(223,7,5,null,null,4)
Table Accountrange:
CREATE TABLE [dbo].[accountrange](
[Financialitem] [nvarchar](3) NULL,
[Accountfrom] [int] NULL,
[Accountto] [int] NULL
) ON [PRIMARY]
INSERT INTO [dbo].[accountrange]
VALUES
(114,100,105),
(222,200,205),
(223,300,305)
Table Account Value:
CREATE TABLE [dbo].[accountvalue](
[accountnumber] [int] NULL,
[valuesUSD] [int] NULL,
) ON [PRIMARY]
INSERT INTO [dbo].[accountvalue]
VALUES
(100,1000),
(101,2000),
(301,1500),
(201,1400)