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] |
10 Lb |
N |
STK |
18 |
17335 |
Seaguar Smackdown Braid, Stealth Gray 150 Yards |
[empty string] |
511076 |
[empty string] |
10SDSG150 |
705069 |
[empty string] |
10sdsg150 |
1 |
2 |
[empty string] |
[empty string] |
15 Lb |
N |
STK |
16 |
17336 |
Seaguar Smackdown Braid, Stealth Gray 150 Yards |
[empty string] |
511077 |
[empty string] |
15SDSG150 |
705070 |
[empty string] |
10sdsg150 |
2 |
3 |
[empty string] |
[empty string] |
20 Lb |
N |
STK |
20 |
17338 |
Seaguar Smackdown Braid, Stealth Gray 150 Yards |
[empty string] |
511078 |
[empty string] |
20SDSG150 |
705071 |
[empty string] |
10sdsg150 |
3 |
4 |
[empty string] |
[empty string] |
30 Lb |
N |
STK |
0 |
18294 |
Seaguar Smackdown Braid, Stealth Gray 150 Yards |
[empty string] |
511079 |
[empty string] |
30SDSG150 |
705072 |
[empty string] |
10sdsg150 |
4 |
5 |
[empty string] |
[empty string] |
40 Lb |
N |
STK |
18 |
18295 |
Seaguar Smackdown Braid, Stealth Gray 150 Yards |
[empty string] |
511080 |
[empty string] |
40SDSG150 |
705073 |
[empty string] |
10sdsg150 |
5 |
6 |
[empty string] |
[empty string] |
50 Lb |
N |
STK |
22 |
18296 |
Seaguar Smackdown Braid, Stealth Gray 150 Yards |
[empty string] |
511081 |
[empty string] |
50SDSG150 |
705074 |
[empty string] |
10sdsg150 |
6 |
7 |
[empty string] |
[empty string] |
60 Lb |
N |
STK |
5 |
18297 |
Seaguar Smackdown Braid, Stealth Gray 150 Yards |
[empty string] |
511082 |
[empty string] |
65SDSG150 |
705075 |
[empty string] |
10sdsg150 |
7 |
|
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)
)
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 = '10sdsg150'
AND (upper(f.web_text) = 'SEAGUAR' or upper(f.orig_text) = 'SEAGUAR' or upper(a.brand) = 'SEAGUAR')
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 |