14. august 2007 - 10:42Der er
4 kommentarer og 1 løsning
Insert og Select
Den nedenstående SELECT forespørgesel returnere nogle counts værdier. Disse værdier skal indsættes i en temptabel. SELECT:
Select cnt from (Select * from tblsplit where Level = 2) b left join (Select * from split_0 where statisticid = 2 and unitid = 4634 ) a on a.splitid = b.splitid where splitgroup_1 in ( Select splitgroup_1 from (Select * from tblsplit where Level = 2 and splitgroup_2 is null) b inner join (Select * from split_0 where statisticid = 2 and unitid = 4634) a on a.splitid = b.splitid ) AND splitname NOT In ('Andet', 'Danske Bank') AND splitgroup_2 is null Order by cnt desc
INSERT INTO dinTempTabel ( Select cnt from (Select * from tblsplit where Level = 2) b left join (Select * from split_0 where statisticid = 2 and unitid = 4634) a on a.splitid = b.splitid where splitgroup_1 in ( Select splitgroup_1 from (Select * from tblsplit where Level = 2 and splitgroup_2 is null) b inner join (Select * from split_0 where statisticid = 2 and unitid = 4634) a on a.splitid = b.splitid ) AND splitname NOT In ('Andet', 'Danske Bank') AND splitgroup_2 is null Order by cnt desc )
Hvis du vil lave en ny tabel, kan du bruge en select into:
Select cnt Into MinNyeTmpTabel from (Select * from tblsplit where Level = 2) b left join (Select * from split_0 where statisticid = 2 and unitid = 4634 ) a on a.splitid = b.splitid where splitgroup_1 in ( Select splitgroup_1 from (Select * from tblsplit where Level = 2 and splitgroup_2 is null) b inner join (Select * from split_0 where statisticid = 2 and unitid = 4634) a on a.splitid = b.splitid ) AND splitname NOT In ('Andet', 'Danske Bank') AND splitgroup_2 is null Order by cnt desc
Hvis du har en tabel, som kun indeholder feltet cnt, kan du gøre følgende:
INSERT INTO dinTempTabel(cnt) Select cnt from (Select * from tblsplit where Level = 2) b left join (Select * from split_0 where statisticid = 2 and unitid = 4634 ) a on a.splitid = b.splitid where splitgroup_1 in ( Select splitgroup_1 from (Select * from tblsplit where Level = 2 and splitgroup_2 is null) b inner join (Select * from split_0 where statisticid = 2 and unitid = 4634) a on a.splitid = b.splitid ) AND splitname NOT In ('Andet', 'Danske Bank') AND splitgroup_2 is null Order by cnt desc
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.