sql >> Database teknologi >  >> RDS >> Sqlserver

Retur Vælg erklæring som formateret HTML (SQL 2005)

declare @T table
(
  Gender varchar(10),
  Age int,
  Name varchar(10)
)

insert into @T values ('Male',   30,   'Bill')
insert into @T values ('Female', 27,   'Jenny')
insert into @T values ('Female', 27,   'Debby') 
insert into @T values ('Male',   44,   'Frank')

select Gender as 'li',
       (select T2.Age as 'li',
               (select T3.Name as 'li'
                from @T as T3
                where T2.Age = T3.Age and
                      T1.Gender = T3.Gender
                for xml path(''), root('ul'), type) as 'li'
        from @T as T2
        where T1.Gender = T2.Gender
        group by T2.Age
        for xml path(''), root('ul'), type) as 'li'
from @T as T1
group by Gender
for xml path('ul')


  1. Udvidede arrangementer for SSAS

  2. Sådan installeres MySQL 8 på Windows

  3. Oracle SqlPlus - gemmer output i en fil, men vises ikke på skærmen

  4. Fejl:R kan ikke oprette forbindelse til MySQL