- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
select
distinct
P.CART_ID,
sum(P.COST) COST,
cast(P.BUY_DATE as date) BUY_DATE,
'[' || U.ID || '] ' || U.FAM || ' ' || U.NAME || ' ' || U.VATHERNAME UNAME,
list(coalesce((select
USERS.NAME
from
USERS
where
USERS.ID = C.USERID), 'System') || '(' || C.DATETIME || ') - ' || C.comment, ascii_char(10))
from
PRODUCTS_HISTORY P
right join
PARTNERS U on U.ID = P.USERID
join
COMMENTS C on C.PRODUCTID = P.CART_ID
where
-- P.CART_ID is not null and
p.cart_id = 11888
group by 1, 3, 4
Аккуратненький запросик.. Но почему-то он в листе c.comment умножает на p.cart_id.
tucvbif 28.01.2016 20:40 # +11
laMer007 22.08.2016 14:12 # +12
inkanus-gray 22.08.2016 15:20 # +12
SlavaBagru 22.08.2016 16:00 # +11