SELECT distinct
(b.siz) as origSiz,
max(CASE WHEN b.siz_alias IS NULL OR RTRIM(LTRIM(b.siz_alias)) = '' THEN b.siz ELSE b.siz_alias END) as siz,
max(b.size_order) as size_order,
max(a.sku_id) as sku_id,
max(a.scale_entry_id) as scale_entry_id,
sum(e.qoh) as qoh,
max(a.style_id) as style_id
FROM tb_skus a WITH (NOLOCK)
LEFT JOIN tb_size_entries b WITH (NOLOCK)
on (b.scale_entry_id = a.scale_entry_id)
INNER JOIN (
SELECT DISTINCT sku_id
, sum(qoh+qc) as qoh
FROM dbo.tb_sku_buckets WITH (NOLOCK)
WHERE store_id in(98,8,9,2,5,7,6,3)
GROUP BY sku_id
) e on (a.sku_id = e.sku_id)
LEFT JOIN tb_attr1_entries d WITH (NOLOCK)
on (d.attr1_entry_id = a.attr1_entry_id)
LEFT JOIN
(
SELECT style_id
FROM tb_styles WITH (NOLOCK)
WHERE web_style = ?
and web_style is not null
) sq
ON(a.style_id = sq.style_id)
WHERE (sq.style_id is not null OR a.style_id = ?)
AND (b.siz_alias is null OR b.siz_alias NOT IN ('NO SHOW','NOSHOW') )
AND isNull(a.sell_web,'Y') = 'Y'
AND e.qoh > 1
GROUP BY b.siz
ORDER BY max(b.size_order), max(a.scale_entry_id)

SQLPARAMETERS

array

1

E55212

2

135175

query

RESULTSET

query

ATTR1

ATTR1_ALIAS

ATTR1_ENTRY_ID

FAM

HEX

ORIGATTR1

QOH

SIZE

SKU_ID

SORT_ORDER

STYLE_ID

1

FIJI

[empty string]

50619

[empty string]

[empty string]

FIJI

26

150185

502828

[empty string]

135175

CACHED

false

EXECUTIONTIME

1

SQL

SELECT distinct (b.attr1) as origAttr1, max(b.attr1_alias) as attr1_alias, max(CASE WHEN b.attr1_alias IS NULL OR RTRIM(LTRIM(b.attr1_alias)) = '' THEN b.attr1 ELSE b.attr1_alias END) as attr1, max(a.sku_id) as sku_id, max(b.attr1_entry_id) as attr1_entry_id, sum(e.qoh) as qoh, max(b.attr1_order) as sort_order, max(c.attr1_hex) as hex,max(d.attr1_fam) as fam, max(a.style_id) as style_id, max(a.SCALE_ENTRY_ID) as size
FROM tb_skus a
LEFT JOIN tb_attr1_entries b WITH (NOLOCK) ON (b.attr1_entry_id = a.attr1_entry_id)
INNER JOIN (
SELECT DISTINCT sku_id
, sum(qoh+qc) as qoh
FROM dbo.tb_sku_buckets WITH (NOLOCK)
WHERE store_id in(98,8,9,2,5,7,6,3)
GROUP BY sku_id
) e on (a.sku_id = e.sku_id)
LEFT JOIN tb_attr1_hexes c WITH (NOLOCK) ON (b.attr1=c.attr1)
LEFT JOIN tb_size_entries k WITH (NOLOCK) on (k.scale_entry_id = a.scale_entry_id)
LEFT JOIN tb_attr1_families d WITH (NOLOCK) ON (c.attr1_fam_id = d.attr1_fam_id)
WHERE
a.style_id =? AND (b.attr1_alias is null OR b.attr1_alias NOT IN ('NO SHOW','NOSHOW') )
AND e.qoh > 1
AND isNull(a.sell_web,'Y') = 'Y'
GROUP BY b.attr1
ORDER BY sum(e.qoh) DESC --max(b.attr1_order), max(b.attr1_entry_id)

Run like the wind in these Feetures Unisex Elite Ultra Light No Show Tab Socks. They're constructed with zone-specific targeted compression for comfort and support. Ultra thin cushioning takes up minimal room inside your shoes and iWick® fibers wick moisture to keep feet cool and dry. The anatomical design conforms to the left and right structure of your feet providing enhanced fit and reduced risk of blisters as you rack up the miles.