Am rezolvat asta: pentru cele mai banoase orase (suma banilor pe orase) se aduce lista clientilor care au cotizat. Dca n-am inteles corect, ghinion.
Ca veni vorba: ce daca e BL pe stocatura? e rapid....
select
top 3
t1
.oras,
(
select replace(replace(replace(replace(replace(replace(replace(
(
select myTable.x
from
(
select distinct client x
from tab
where oras = t1.oras
) mytable
for xml auto
),
'x="', ''), '<mytable ' , '<'), '"', ''), '/><', ','), '<', ''), ' ', ''), '/>', '')
)
t2,
sum
(t1.total)
from
tab t1
group
by t1.oras
order
by 3 desc
smecheria cu aducerea clientilor cu virgula se face fortand un xml.
Mama, chiar ca m-am plictisit...