Sql |
SELECT distinct a.style_id,
case a.style_id
when 301784 then 1
when 301785 then 2
when 292578 then 3
when 247549 then 4
when 277330 then 5
when 285285 then 6
when 203045 then 7
when 247060 then 8
when 212075 then 9
when 155549 then 10
when 182055 then 11
when 297064 then 12
when 277331 then 13
when 280594 then 14
when 289167 then 15
when 293221 then 16
when 295067 then 17
when 287657 then 18
when 293192 then 19
when 325366 then 20
when 306977 then 21
when 306853 then 22
when 316898 then 23
when 256944 then 24
when 161707 then 25
when 251679 then 26
when 250908 then 27
when 196855 then 28
when 251130 then 29
when 256114 then 30
when 260614 then 31
when 207533 then 32
when 250105 then 33
when 330773 then 34
when 196853 then 35
when 252077 then 36
when 272135 then 37
when 277306 then 38
when 176013 then 39
when 208510 then 40
when 250414 then 41
when 250417 then 42
when 250412 then 43
when 248738 then 44
when 249148 then 45
when 263976 then 46
when 264560 then 47
when 279006 then 48
when 250413 then 49
when 250416 then 50
when 263977 then 51
when 330776 then 52
when 85313 then 53
when 290507 then 54
when 290493 then 55
when 255249 then 56
when 250015 then 57
when 176014 then 58
when 253625 then 59
when 257093 then 60
when 141436 then 61
when 181910 then 62
when 254188 then 63
when 269823 then 64
when 304902 then 65
when 251016 then 66
when 261648 then 67
when 324738 then 68
when 275842 then 69
when 272113 then 70
when 326866 then 71
when 42319 then 72
when 250278 then 73
when 251013 then 74
when 251014 then 75
when 251015 then 76
when 262805 then 77
when 42153 then 78
when 267726 then 79
when 255305 then 80
when 13224 then 81
when 42215 then 82
when 147480 then 83
when 42351 then 84
when 87810 then 85
when 144013 then 86
when 212081 then 87
when 212080 then 88
when 250279 then 89
when 250280 then 90
when 252145 then 91
when 42149 then 92
when 264990 then 93
when 285976 then 94
when 329592 then 95
when 61988 then 96
when 203703 then 97
when 249821 then 98
when 267543 then 99
when 270725 then 100
when 42329 then 101
when 42352 then 102
when 61268 then 103
when 42320 then 104
when 61492 then 105
when 191929 then 106
when 246411 then 107
when 252615 then 108
when 252526 then 109
when 42147 then 110
when 276021 then 111
when 276869 then 112
when 50966 then 113
when 252143 then 114
when 260521 then 115
when 264561 then 116
when 270230 then 117
when 309477 then 118
when 61382 then 119
when 88295 then 120
when 88286 then 121
when 61987 then 122
when 61874 then 123
when 129292 then 124
when 61328 then 125
when 249820 then 126
when 277788 then 127
when 247948 then 128
when 247945 then 129
when 42216 then 130
when 61267 then 131
when 117958 then 132
when 213549 then 133
when 90478 then 134
when 252616 then 135
when 263527 then 136
when 267988 then 137
when 275754 then 138
when 278329 then 139
when 42190 then 140
when 322161 then 141
when 197019 then 142
when 220437 then 143
when 252140 then 144
when 249146 then 145
when 256278 then 146
when 260520 then 147
when 247947 then 148
when 307708 then 149
when 319213 then 150
when 207971 then 151
when 312379 then 152
when 144914 then 153
when 61178 then 154
when 204163 then 155
when 208344 then 156
when 209602 then 157
when 213176 then 158
when 255250 then 159
when 256089 then 160
when 204277 then 161
when 73347 then 162
when 261715 then 163
when 133499 then 164
when 263643 then 165
when 278987 then 166
when 282567 then 167
when 286956 then 168
when 283480 then 169
when 247789 then 170
when 285215 then 171
when 169896 then 172
when 192359 then 173
when 128528 then 174
when 220446 then 175
when 220439 then 176
when 248732 then 177
when 256279 then 178
when 262597 then 179
when 264556 then 180
when 297219 then 181
when 318141 then 182
when 318139 then 183
when 318142 then 184
when 136755 then 185
when 255606 then 186
when 260519 then 187
when 303447 then 188
when 61139 then 189
when 102202 then 190
when 117700 then 191
when 117771 then 192
when 147963 then 193
when 132672 then 194
when 207503 then 195
when 137068 then 196
when 252864 then 197
when 254361 then 198
when 254534 then 199
when 124790 then 200
when 257313 then 201
when 260873 then 202
when 279003 then 203
when 292448 then 204
when 196646 then 205
when 78588 then 206
when 254101 then 207
when 42146 then 208
when 220438 then 209
when 248731 then 210
when 261957 then 211
when 282681 then 212
when 297220 then 213
when 297221 then 214
when 75311 then 215
when 61385 then 216
when 116695 then 217
when 204162 then 218
when 137071 then 219
when 250076 then 220
when 251090 then 221
when 251216 then 222
when 253049 then 223
when 255170 then 224
when 130944 then 225
when 272532 then 226
when 273460 then 227
when 273996 then 228
when 276571 then 229
when 270351 then 230
when 279404 then 231
when 42360 then 232
when 281591 then 233
when 286923 then 234
when 232166 then 235
when 40333 then 236
when 276462 then 237
when 318135 then 238
when 75326 then 239
when 135279 then 240
when 105795 then 241
when 75310 then 242
when 61497 then 243
when 61498 then 244
when 61908 then 245
when 61909 then 246
when 61384 then 247
when 61496 then 248
when 111548 then 249
when 61140 then 250
when 209598 then 251
when 209604 then 252
when 207501 then 253
when 61910 then 254
when 114866 then 255
when 162514 then 256
when 74010 then 257
when 61829 then 258
when 248323 then 259
when 252020 then 260
when 251884 then 261
when 262135 then 262
when 266382 then 263
when 266938 then 264
when 267162 then 265
when 267626 then 266
when 267627 then 267
when 250230 then 268
when 74999 then 269
when 273961 then 270
when 276022 then 271
when 276570 then 272
when 270353 then 273
when 274650 then 274
when 279895 then 275
when 42356 then 276
when 281278 then 277
when 281280 then 278
when 281279 then 279
when 281592 then 280
when 283474 then 281
when 269995 then 282
when 284324 then 283
when 285027 then 284
when 287624 then 285
when 61912 then 286
when 61873 then 287
when 126905 then 288
when 250231 then 289
when 310025 then 290
when 188871 then 291
when 254102 then 292
when 319705 then 293
when 33161 then 294
when 272998 then 295
when 122053 then 296
when 149008 then 297
when 253623 then 298
when 264673 then 299
when 111282 then 300
when 252123 then 301
when 264271 then 302
when 40264 then 303
when 319729 then 304
when 178639 then 305
when 145809 then 306
when 198565 then 307
when 198566 then 308
when 232343 then 309
when 248750 then 310
when 253191 then 311
when 253156 then 312
when 256204 then 313
when 260634 then 314
when 264827 then 315
when 264511 then 316
when 293039 then 317
when 319702 then 318
when 319707 then 319
when 319214 then 320
when 318140 then 321
when 307629 then 322
when 109120 then 323
when 90618 then 324
when 105797 then 325
when 98896 then 326
when 163772 then 327
when 186774 then 328
when 209186 then 329
when 210124 then 330
when 219787 then 331
when 219788 then 332
when 61871 then 333
when 250474 then 334
when 75328 then 335
when 198057 then 336
when 263368 then 337
when 272920 then 338
when 136213 then 339
when 72613 then 340
when 61383 then 341
when 272161 then 342
when 203932 then 343
when 281277 then 344
when 61911 then 345
when 72640 then 346
when 269073 then 347
when 283687 then 348
when 283613 then 349
when 61875 then 350
when 296828 then 351
when 316807 then 352
when 38446 then 353
when 253296 then 354
when 272136 then 355
when 272086 then 356
when 319706 then 357
when 19311 then 358
when 19199 then 359
when 293114 then 360
when 191521 then 361
when 222857 then 362
when 302798 then 363
when 329450 then 364
when 329456 then 365
when 173663 then 366
when 206955 then 367
when 216724 then 368
when 227535 then 369
when 254346 then 370
when 266208 then 371
when 268633 then 372
when 268520 then 373
when 289423 then 374
when 289544 then 375
when 319703 then 376
when 110290 then 377
when 137066 then 378
when 322158 then 379
when 24020 then 380
when 270300 then 381
when 262263 then 382
when 75323 then 383
when 90922 then 384
when 209185 then 385
when 210126 then 386
when 219789 then 387
when 276029 then 388
when 277297 then 389
when 61872 then 390
when 305086 then 391
when 108647 then 392
when 198563 then 393
when 251544 then 394
when 301430 then 395
when 319730 then 396
when 319731 then 397
when 323645 then 398
when 24205 then 399
when 248028 then 400
when 1728 then 401
when 7063 then 402
when 262123 then 403
when 248736 then 404
when 248737 then 405
when 261119 then 406
when 277867 then 407
when 285104 then 408
when 303791 then 409
when 319631 then 410
when 262056 then 411
when 260610 then 412
when 276030 then 413
when 281316 then 414
when 81347 then 415
when 1729 then 416
when 15174 then 417
when 7002 then 418
when 7050 then 419
when 247955 then 420
when 86560 then 421
when 208343 then 422
when 283596 then 423
when 289545 then 424
when 304601 then 425
when 304607 then 426
when 317899 then 427
when 319220 then 428
when 264667 then 429
when 24204 then 430
when 56034 then 431
when 7400 then 432
when 208555 then 433
when 326845 then 434
when 200393 then 435
when 269451 then 436
when 264665 then 437
when 58312 then 438
when 247937 then 439
when 299367 then 440
when 193589 then 441
when 277400 then 442
when 255306 then 443
when 281318 then 444
when 267923 then 445
when 126635 then 446
when 113965 then 447
when 102206 then 448
when 74026 then 449
when 263640 then 450
when 252728 then 451
when 264831 then 452
when 120899 then 453
when 262928 then 454
when 208564 then 455
when 323030 then 456
when 138672 then 457
when 249572 then 458
when 248733 then 459
when 147699 then 460
when 256948 then 461
when 247950 then 462
when 304907 then 463
when 302807 then 464
when 70168 then 465
when 74032 then 466
when 279307 then 467
when 326822 then 468
when 122001 then 469
when 109425 then 470
when 183830 then 471
when 270726 then 472
when 12865 then 473
when 317227 then 474
when 317226 then 475
when 303252 then 476
when 46339 then 477
when 46208 then 478
when 132670 then 479
when 113203 then 480
when 147375 then 481
when 147380 then 482
when 74052 then 483
when 264846 then 484
when 262129 then 485
when 262122 then 486
when 252726 then 487
when 97644 then 488
when 113026 then 489
when 24690 then 490
when 112954 then 491
when 131457 then 492
when 86559 then 493
when 249308 then 494
when 256916 then 495
when 40265 then 496
when 40270 then 497
when 153026 then 498
when 247939 then 499
when 247168 then 500
when 309542 then 501
when 319207 then 502
when 46340 then 503
when 122002 then 504
when 99708 then 505
when 147932 then 506
when 249834 then 507
when 250103 then 508
when 121998 then 509
when 250780 then 510
when 262050 then 511
when 268645 then 512
when 252227 then 513
when 287233 then 514
when 40384 then 515
when 247943 then 516
when 319206 then 517
when 319294 then 518
when 322368 then 519
when 322370 then 520
when 305113 then 521
when 202674 then 522
when 202673 then 523
when 202672 then 524
when 145797 then 525
when 51481 then 526
when 134374 then 527
when 225976 then 528
when 74643 then 529
when 46362 then 530
when 46346 then 531
when 4478 then 532
when 202658 then 533
when 202678 then 534
when 202667 then 535
when 320418 then 536
when 99673 then 537
when 69692 then 538
when 80634 then 539
when 61269 then 540
when 133815 then 541
when 54041 then 542
when 181823 then 543
when 165535 then 544
when 202782 then 545
when 246187 then 546
when 144632 then 547
when 277308 then 548
when 280057 then 549
when 263401 then 550
when 203785 then 551
when 294918 then 552
when 319204 then 553
when 305111 then 554
when 121956 then 555
when 4436 then 556
when 188897 then 557
when 51493 then 558
when 203829 then 559
when 141471 then 560
when 42767 then 561
when 220918 then 562
when 247791 then 563
when 142866 then 564
when 267633 then 565
when 271061 then 566
when 289357 then 567
when 326337 then 568
when 42588 then 569
when 34591 then 570
when 125169 then 571
when 4489 then 572
when 198341 then 573
when 103403 then 574
when 207223 then 575
when 51471 then 576
when 209852 then 577
when 223106 then 578
when 262051 then 579
when 285534 then 580
when 285451 then 581
when 286247 then 582
when 293014 then 583
when 46361 then 584
when 46209 then 585
when 46341 then 586
when 46342 then 587
when 262582 then 588
when 322169 then 589
when 331053 then 590
when 331048 then 591
when 122000 then 592
when 61799 then 593
when 204283 then 594
when 213550 then 595
when 225434 then 596
when 251061 then 597
when 262998 then 598
when 270968 then 599
when 273571 then 600
when 276023 then 601
when 264833 then 602
when 88308 then 603
when 297541 then 604
when 247926 then 605
when 310068 then 606
when 325406 then 607
when 325407 then 608
when 305114 then 609
when 325092 then 610
when 68598 then 611
when 34533 then 612
when 133911 then 613
when 173676 then 614
when 51464 then 615
when 51460 then 616
when 42647 then 617
when 173060 then 618
when 203788 then 619
when 51499 then 620
when 208033 then 621
when 98806 then 622
when 219887 then 623
when 220916 then 624
when 226058 then 625
when 228033 then 626
when 255311 then 627
when 114673 then 628
when 34530 then 629
when 276011 then 630
when 285216 then 631
when 289347 then 632
when 135745 then 633
when 289192 then 634
when 69778 then 635
when 219839 then 636
when 310596 then 637
when 330763 then 638
when 61132 then 639
when 162546 then 640
when 165119 then 641
when 184300 then 642
when 147943 then 643
when 192437 then 644
when 61986 then 645
when 209443 then 646
when 8950 then 647
when 191230 then 648
when 214580 then 649
when 216501 then 650
when 74062 then 651
when 215945 then 652
when 219960 then 653
when 202685 then 654
when 188699 then 655
when 61495 then 656
when 61493 then 657
when 250125 then 658
when 263620 then 659
when 263584 then 660
when 42176 then 661
when 42175 then 662
when 267159 then 663
when 277787 then 664
when 277332 then 665
when 277333 then 666
when 280403 then 667
when 144630 then 668
when 287332 then 669
when 287331 then 670
when 198959 then 671
when 287622 then 672
when 297830 then 673
when 247928 then 674
when 310056 then 675
when 325404 then 676
when 93027 then 677
when 138591 then 678
when 4487 then 679
when 170047 then 680
when 158273 then 681
when 173976 then 682
when 117177 then 683
when 189940 then 684
when 42656 then 685
when 197983 then 686
when 197144 then 687
when 200324 then 688
when 196819 then 689
when 206062 then 690
when 208114 then 691
when 42590 then 692
when 144547 then 693
when 242376 then 694
when 221017 then 695
when 239379 then 696
when 247025 then 697
when 211333 then 698
when 247579 then 699
when 247642 then 700
when 249101 then 701
when 253320 then 702
when 249100 then 703
when 254490 then 704
when 247597 then 705
when 256197 then 706
when 227227 then 707
when 113776 then 708
when 80785 then 709
when 267743 then 710
when 268634 then 711
when 271985 then 712
when 277925 then 713
when 71922 then 714
when 283307 then 715
when 283236 then 716
when 285446 then 717
when 73156 then 718
when 289436 then 719
when 289448 then 720
when 289381 then 721
when 289029 then 722
when 289833 then 723
when 290613 then 724
when 298050 then 725
when 304926 then 726
when 305565 then 727
when 310268 then 728
when 310336 then 729
when 326171 then 730
when 322167 then 731
when 322240 then 732
when 322176 then 733
when 34461 then 734
when 105735 then 735
when 118285 then 736
when 161572 then 737
when 156359 then 738
when 169178 then 739
when 4490 then 740
when 118482 then 741
when 149009 then 742
when 10066 then 743
when 189941 then 744
when 195587 then 745
when 181810 then 746
when 42650 then 747
when 189944 then 748
when 196312 then 749
when 110581 then 750
when 196324 then 751
when 205614 then 752
when 206135 then 753
when 191505 then 754
when 207652 then 755
when 206642 then 756
when 76572 then 757
when 216452 then 758
when 207007 then 759
when 115864 then 760
when 218234 then 761
when 163593 then 762
when 217353 then 763
when 246239 then 764
when 207158 then 765
when 247213 then 766
when 250106 then 767
when 249078 then 768
when 249097 then 769
when 250775 then 770
when 225241 then 771
when 253381 then 772
when 254110 then 773
when 255058 then 774
when 149010 then 775
when 264677 then 776
when 151627 then 777
when 261223 then 778
when 260500 then 779
when 268426 then 780
when 260499 then 781
when 267731 then 782
when 267716 then 783
when 262695 then 784
when 268564 then 785
when 268533 then 786
when 268547 then 787
when 283253 then 788
when 112354 then 789
when 285228 then 790
when 103058 then 791
when 289376 then 792
when 289028 then 793
when 289069 then 794
when 289704 then 795
when 289821 then 796
when 290642 then 797
when 290473 then 798
when 290597 then 799
when 290644 then 800
when 293030 then 801
when 293021 then 802
when 293024 then 803
when 299169 then 804
when 247167 then 805
when 307436 then 806
when 322427 then 807
when 326277 then 808
when 326833 then 809
when 326343 then 810
when 126513 then 811
when 129606 then 812
when 126729 then 813
when 137062 then 814
when 61113 then 815
when 19195 then 816
when 126733 then 817
when 70751 then 818
when 137064 then 819
when 142844 then 820
when 168852 then 821
when 147942 then 822
when 19204 then 823
when 196862 then 824
when 202343 then 825
when 61985 then 826
when 207110 then 827
when 204261 then 828
when 61812 then 829
when 61489 then 830
when 74038 then 831
when 74060 then 832
when 221122 then 833
when 74034 then 834
when 221120 then 835
when 221121 then 836
when 245025 then 837
when 61494 then 838
when 115826 then 839
when 193213 then 840
when 252556 then 841
when 253050 then 842
when 68431 then 843
when 95558 then 844
when 261351 then 845
when 261506 then 846
when 264971 then 847
when 267148 then 848
when 264840 then 849
when 274003 then 850
when 277253 then 851
when 279925 then 852
when 42321 then 853
when 247927 then 854
when 19436 then 855
when 310070 then 856
when 323786 then 857
when 323785 then 858
when 323789 then 859
when 323788 then 860
when 330739 then 861
when 34493 then 862
when 78952 then 863
when 130355 then 864
when 114245 then 865
when 164016 then 866
when 34504 then 867
when 121871 then 868
when 105786 then 869
when 92044 then 870
when 129644 then 871
when 163595 then 872
when 164054 then 873
when 42584 then 874
when 4455 then 875
when 107230 then 876
when 4499 then 877
when 116951 then 878
when 193474 then 879
when 105440 then 880
when 154939 then 881
when 200016 then 882
when 197153 then 883
when 203474 then 884
when 205874 then 885
when 34498 then 886
when 209754 then 887
when 196625 then 888
when 64005 then 889
when 115241 then 890
when 214879 then 891
when 214880 then 892
when 198278 then 893
when 145772 then 894
when 223107 then 895
when 72668 then 896
when 108731 then 897
when 242135 then 898
when 117842 then 899
when 251275 then 900
when 247662 then 901
when 201696 then 902
when 260537 then 903
when 4454 then 904
when 4456 then 905
when 92035 then 906
when 4500 then 907
when 262731 then 908
when 266826 then 909
when 260671 then 910
when 251530 then 911
when 267698 then 912
when 267723 then 913
when 281157 then 914
when 282192 then 915
when 282193 then 916
when 279911 then 917
when 283333 then 918
when 283293 then 919
when 283324 then 920
when 219975 then 921
when 285223 then 922
when 286239 then 923
when 285982 then 924
when 257309 then 925
when 4447 then 926
when 276908 then 927
when 289078 then 928
when 289439 then 929
when 289043 then 930
when 289392 then 931
when 289822 then 932
when 285903 then 933
when 291872 then 934
when 293115 then 935
when 300773 then 936
when 300769 then 937
when 300776 then 938
when 300775 then 939
when 300762 then 940
when 304920 then 941
when 46363 then 942
when 322481 then 943
when 324734 then 944
when 327065 then 945
when 276889 then 946
when 302503 then 947
when 317428 then 948
when 19437 then 949
when 61177 then 950
when 120236 then 951
when 124868 then 952
when 147374 then 953
when 19202 then 954
when 42322 then 955
when 42343 then 956
when 42344 then 957
when 89606 then 958
when 75451 then 959
when 19315 then 960
when 168775 then 961
when 198008 then 962
when 61490 then 963
when 204260 then 964
when 74046 then 965
when 74074 then 966
when 61808 then 967
when 210614 then 968
when 74036 then 969
when 215946 then 970
when 74054 then 971
when 202687 then 972
when 216818 then 973
when 19305 then 974
when 217905 then 975
when 185565 then 976
when 185568 then 977
when 202682 then 978
when 202688 then 979
when 202691 then 980
when 202689 then 981
when 202690 then 982
when 185566 then 983
when 225438 then 984
when 202686 then 985
when 19292 then 986
when 252620 then 987
when 263244 then 988
when 264013 then 989
when 266869 then 990
when 267145 then 991
when 267146 then 992
when 276152 then 993
when 136214 then 994
when 61810 then 995
when 281014 then 996
when 272141 then 997
when 252733 then 998
when 300928 then 999
when 271323 then 1000
else 1000
end as ranking,
max(a.non_invt) as non_invt,sum(qoh + qc) as available,max(a.dept) as dept,max(a.brand) as brand,max(a.of3) as of3,case when sum(qoh + qc) > 0 then 1 else 0 end as instock
FROM web_all_products a WITH (NOLOCK)
INNER JOIN dbo.tb_skus b WITH (NOLOCK) ON (a.style_id = b.style_id)
INNER JOIN dbo.tb_sku_buckets c WITH (NOLOCK) ON (b.sku_id = c.sku_id and c.store_id in (10,32))
INNER JOIN dbo.tb_styles_web_taxonomy d WITH (NOLOCK) ON (a.style_id = d.style)
INNER JOIN dbo.tb_styles qq WITH (NOLOCK) ON (qq.style_id = a.style_id)
where a.style_id in (301784,301785,292578,247549,277330,285285,203045,247060,212075,155549,182055,297064,277331,280594,289167,293221,295067,287657,293192,325366,306977,306853,316898,256944,161707,251679,250908,196855,251130,256114,260614,207533,250105,330773,196853,252077,272135,277306,176013,208510,250414,250417,250412,248738,249148,263976,264560,279006,250413,250416,263977,330776,85313,290507,290493,255249,250015,176014,253625,257093,141436,181910,254188,269823,304902,251016,261648,324738,275842,272113,326866,42319,250278,251013,251014,251015,262805,42153,267726,255305,13224,42215,147480,42351,87810,144013,212081,212080,250279,250280,252145,42149,264990,285976,329592,61988,203703,249821,267543,270725,42329,42352,61268,42320,61492,191929,246411,252615,252526,42147,276021,276869,50966,252143,260521,264561,270230,309477,61382,88295,88286,61987,61874,129292,61328,249820,277788,247948,247945,42216,61267,117958,213549,90478,252616,263527,267988,275754,278329,42190,322161,197019,220437,252140,249146,256278,260520,247947,307708,319213,207971,312379,144914,61178,204163,208344,209602,213176,255250,256089,204277,73347,261715,133499,263643,278987,282567,286956,283480,247789,285215,169896,192359,128528,220446,220439,248732,256279,262597,264556,297219,318141,318139,318142,136755,255606,260519,303447,61139,102202,117700,117771,147963,132672,207503,137068,252864,254361,254534,124790,257313,260873,279003,292448,196646,78588,254101,42146,220438,248731,261957,282681,297220,297221,75311,61385,116695,204162,137071,250076,251090,251216,253049,255170,130944,272532,273460,273996,276571,270351,279404,42360,281591,286923,232166,40333,276462,318135,75326,135279,105795,75310,61497,61498,61908,61909,61384,61496,111548,61140,209598,209604,207501,61910,114866,162514,74010,61829,248323,252020,251884,262135,266382,266938,267162,267626,267627,250230,74999,273961,276022,276570,270353,274650,279895,42356,281278,281280,281279,281592,283474,269995,284324,285027,287624,61912,61873,126905,250231,310025,188871,254102,319705,33161,272998,122053,149008,253623,264673,111282,252123,264271,40264,319729,178639,145809,198565,198566,232343,248750,253191,253156,256204,260634,264827,264511,293039,319702,319707,319214,318140,307629,109120,90618,105797,98896,163772,186774,209186,210124,219787,219788,61871,250474,75328,198057,263368,272920,136213,72613,61383,272161,203932,281277,61911,72640,269073,283687,283613,61875,296828,316807,38446,253296,272136,272086,319706,19311,19199,293114,191521,222857,302798,329450,329456,173663,206955,216724,227535,254346,266208,268633,268520,289423,289544,319703,110290,137066,322158,24020,270300,262263,75323,90922,209185,210126,219789,276029,277297,61872,305086,108647,198563,251544,301430,319730,319731,323645,24205,248028,1728,7063,262123,248736,248737,261119,277867,285104,303791,319631,262056,260610,276030,281316,81347,1729,15174,7002,7050,247955,86560,208343,283596,289545,304601,304607,317899,319220,264667,24204,56034,7400,208555,326845,200393,269451,264665,58312,247937,299367,193589,277400,255306,281318,267923,126635,113965,102206,74026,263640,252728,264831,120899,262928,208564,323030,138672,249572,248733,147699,256948,247950,304907,302807,70168,74032,279307,326822,122001,109425,183830,270726,12865,317227,317226,303252,46339,46208,132670,113203,147375,147380,74052,264846,262129,262122,252726,97644,113026,24690,112954,131457,86559,249308,256916,40265,40270,153026,247939,247168,309542,319207,46340,122002,99708,147932,249834,250103,121998,250780,262050,268645,252227,287233,40384,247943,319206,319294,322368,322370,305113,202674,202673,202672,145797,51481,134374,225976,74643,46362,46346,4478,202658,202678,202667,320418,99673,69692,80634,61269,133815,54041,181823,165535,202782,246187,144632,277308,280057,263401,203785,294918,319204,305111,121956,4436,188897,51493,203829,141471,42767,220918,247791,142866,267633,271061,289357,326337,42588,34591,125169,4489,198341,103403,207223,51471,209852,223106,262051,285534,285451,286247,293014,46361,46209,46341,46342,262582,322169,331053,331048,122000,61799,204283,213550,225434,251061,262998,270968,273571,276023,264833,88308,297541,247926,310068,325406,325407,305114,325092,68598,34533,133911,173676,51464,51460,42647,173060,203788,51499,208033,98806,219887,220916,226058,228033,255311,114673,34530,276011,285216,289347,135745,289192,69778,219839,310596,330763,61132,162546,165119,184300,147943,192437,61986,209443,8950,191230,214580,216501,74062,215945,219960,202685,188699,61495,61493,250125,263620,263584,42176,42175,267159,277787,277332,277333,280403,144630,287332,287331,198959,287622,297830,247928,310056,325404,93027,138591,4487,170047,158273,173976,117177,189940,42656,197983,197144,200324,196819,206062,208114,42590,144547,242376,221017,239379,247025,211333,247579,247642,249101,253320,249100,254490,247597,256197,227227,113776,80785,267743,268634,271985,277925,71922,283307,283236,285446,73156,289436,289448,289381,289029,289833,290613,298050,304926,305565,310268,310336,326171,322167,322240,322176,34461,105735,118285,161572,156359,169178,4490,118482,149009,10066,189941,195587,181810,42650,189944,196312,110581,196324,205614,206135,191505,207652,206642,76572,216452,207007,115864,218234,163593,217353,246239,207158,247213,250106,249078,249097,250775,225241,253381,254110,255058,149010,264677,151627,261223,260500,268426,260499,267731,267716,262695,268564,268533,268547,283253,112354,285228,103058,289376,289028,289069,289704,289821,290642,290473,290597,290644,293030,293021,293024,299169,247167,307436,322427,326277,326833,326343,126513,129606,126729,137062,61113,19195,126733,70751,137064,142844,168852,147942,19204,196862,202343,61985,207110,204261,61812,61489,74038,74060,221122,74034,221120,221121,245025,61494,115826,193213,252556,253050,68431,95558,261351,261506,264971,267148,264840,274003,277253,279925,42321,247927,19436,310070,323786,323785,323789,323788,330739,34493,78952,130355,114245,164016,34504,121871,105786,92044,129644,163595,164054,42584,4455,107230,4499,116951,193474,105440,154939,200016,197153,203474,205874,34498,209754,196625,64005,115241,214879,214880,198278,145772,223107,72668,108731,242135,117842,251275,247662,201696,260537,4454,4456,92035,4500,262731,266826,260671,251530,267698,267723,281157,282192,282193,279911,283333,283293,283324,219975,285223,286239,285982,257309,4447,276908,289078,289439,289043,289392,289822,285903,291872,293115,300773,300769,300776,300775,300762,304920,46363,322481,324734,327065,276889,302503,317428,19437,61177,120236,124868,147374,19202,42322,42343,42344,89606,75451,19315,168775,198008,61490,204260,74046,74074,61808,210614,74036,215946,74054,202687,216818,19305,217905,185565,185568,202682,202688,202691,202689,202690,185566,225438,202686,19292,252620,263244,264013,266869,267145,267146,276152,136214,61810,281014,272141,252733,300928,271323)
and ltrim(rtrim(lower(a.dept))) = 'firearms'
and ltrim(rtrim(lower(a.brand))) = 'mossberg'
group by a.style_id
order by instock desc, ranking asc
|