RESULTSET |
query |
|
ATTR1ID |
ATTR2ID |
CAPACITY |
NON_INVT |
OF8 |
OVERALLQOH |
PICTURE_ID |
REALNAME |
SCALEID |
SKU_ID |
SKU_OF7 |
STYLE |
STYLE_ID |
USEPACKAGE |
WEBSTYLE |
WEBSTYLE_SORT |
1 |
[empty string] |
[empty string] |
#20 |
N |
STK |
0 |
4149 |
Mustad Bronze Treble Hook, 25 Pack |
[empty string] |
7056 |
[empty string] |
3551-BR-20-25 |
7056 |
[empty string] |
355120P24 |
1 |
2 |
[empty string] |
[empty string] |
#18 |
N |
STK |
57 |
4146 |
Mustad Bronze Treble Hook, 25 Pack |
[empty string] |
7053 |
[empty string] |
3551-BR-18-25 |
7053 |
[empty string] |
355120P24 |
2 |
3 |
[empty string] |
[empty string] |
#16 |
N |
STK |
47 |
4144 |
Mustad Bronze Treble Hook, 25 Pack |
[empty string] |
7051 |
[empty string] |
3551-BR-16-25 |
7051 |
[empty string] |
355120P24 |
3 |
4 |
[empty string] |
[empty string] |
#14 |
N |
STK |
27 |
4141 |
Mustad Bronze Treble Hook, 25 Pack |
[empty string] |
7049 |
[empty string] |
3551-BR-14-25 |
7049 |
[empty string] |
355120P24 |
4 |
5 |
[empty string] |
[empty string] |
#12 |
N |
STK |
4 |
4139 |
Mustad Bronze Treble Hook, 25 Pack |
[empty string] |
7047 |
[empty string] |
3551-BR-12-25 |
7047 |
[empty string] |
355120P24 |
5 |
6 |
[empty string] |
[empty string] |
#10 |
N |
STK |
3 |
4138 |
Mustad Bronze Treble Hook, 25 Pack |
[empty string] |
7046 |
[empty string] |
3551-BR-10-25 |
7046 |
[empty string] |
355120P24 |
6 |
7 |
[empty string] |
[empty string] |
#8 |
N |
STK |
0 |
4162 |
Mustad Bronze Treble Hook, 25 Pack |
[empty string] |
7069 |
[empty string] |
3551-BR-8-25 |
7069 |
[empty string] |
355120P24 |
7 |
8 |
[empty string] |
[empty string] |
#6 |
N |
STK |
2 |
4137 |
Mustad Bronze Treble Hook, 25 Pack |
[empty string] |
7044 |
[empty string] |
3551-BR-6-25 |
7044 |
[empty string] |
355120P24 |
8 |
9 |
[empty string] |
[empty string] |
#4 |
N |
STK |
0 |
4150 |
Mustad Bronze Treble Hook, 25 Pack |
[empty string] |
7057 |
[empty string] |
3551254 |
7057 |
[empty string] |
355120P24 |
9 |
10 |
[empty string] |
[empty string] |
#2 |
N |
STK |
0 |
4135 |
Mustad Bronze Treble Hook 25 Pack |
[empty string] |
7043 |
[empty string] |
3551-BR-2-25 |
7043 |
[empty string] |
355120P24 |
10 |
11 |
[empty string] |
[empty string] |
#1 |
N |
STK |
0 |
4134 |
Mustad Bronze Treble Hook 25 Pack |
[empty string] |
7042 |
[empty string] |
3551-1-25 |
7042 |
[empty string] |
355120P24 |
11 |
|
SQL |
SELECT DISTINCT a.style_id,
max(CASE WHEN m.description IS NULL OR RTRIM(LTRIM(m.description)) = '' THEN a.web_desc ELSE m.description END) as realname,
sum(c.qoh+c.qc) as overallqoh,
max(a.picture_id) as picture_id,
max(a.of8) as of8,
max(b.sku_id) as sku_id,
max(b.sku_of7) as sku_of7,
max(b.scale_entry_id) as scaleid,
max(b.attr2_entry_id) as attr2id,
max(b.attr1_entry_id) as attr1id,
max(a.style) as style,
max(r.package_id) as usepackage,
max(a.web_style) as webStyle,
max(m.capacity) as capacity,
max(m.webstyle_sort) as webstyle_sort,
max(a.NON_INVT) as NON_INVT
FROM tb_styles a
LEFT JOIN tb_skus b WITH (NOLOCK) ON (a.style_id = b.style_id)
LEFT JOIN tb_sku_buckets c WITH (NOLOCK) ON (b.sku_id = c.sku_id
AND NOT (c.qoh < 1 AND a.of8 in (?,?,?,?,?,?,?,?)) AND NOT (c.qoh < 1 AND a.of8='INACTIVE')
AND c.store_id in(49,90,4)
)
LEFT JOIN web_product_information m WITH (NOLOCK) ON (a.style_id = m.style_id)
LEFT JOIN dbo.tb_inet_names f WITH (NOLOCK) on (f.orig_text = a.brand and f.field_name='BRAND')
LEFT JOIN tb_package r WITH (NOLOCK) on (r.sku_id=b.sku_id)
INNER JOIN web_all_products wb WITH (NOLOCK) ON (wb.style_id = a.style_id)
WHERE a.web_style = '355120P24'
AND (upper(f.web_text) = 'MUSTAD' or upper(f.orig_text) = 'MUSTAD' or upper(a.brand) = 'MUSTAD')
GROUP BY a.style_id,a.of8
HAVING (sum(c.qoh+c.qc) > 0 OR a.of8='STK')
ORDER BY max(m.webstyle_sort), a.style_id |