Sql |
SELECT distinct a.style_id,
case a.style_id
when 323148 then 1
when 325061 then 2
when 66385 then 3
when 124566 then 4
when 125153 then 5
when 105260 then 6
when 65749 then 7
when 249890 then 8
when 206257 then 9
when 233224 then 10
when 262447 then 11
when 262483 then 12
when 262481 then 13
when 76387 then 14
when 289680 then 15
when 262484 then 16
when 122063 then 17
when 262480 then 18
when 317052 then 19
when 323515 then 20
when 154937 then 21
when 253266 then 22
when 323723 then 23
when 148580 then 24
when 256609 then 25
when 323680 then 26
when 296355 then 27
when 170026 then 28
when 266183 then 29
when 181682 then 30
when 251723 then 31
when 256288 then 32
when 325022 then 33
when 282130 then 34
when 297050 then 35
when 319967 then 36
when 323147 then 37
when 323149 then 38
when 277765 then 39
when 280768 then 40
when 282131 then 41
when 292247 then 42
when 298566 then 43
when 277359 then 44
when 282629 then 45
when 262482 then 46
when 204945 then 47
when 232436 then 48
when 150206 then 49
when 222329 then 50
when 325230 then 51
when 12768 then 52
when 220136 then 53
when 251543 then 54
when 248795 then 55
when 324872 then 56
when 255981 then 57
when 263196 then 58
when 267101 then 59
when 232434 then 60
when 138250 then 61
when 138671 then 62
when 147655 then 63
when 147657 then 64
when 252699 then 65
when 272194 then 66
when 281361 then 67
when 266182 then 68
when 248793 then 69
when 134564 then 70
when 156445 then 71
when 153305 then 72
when 138670 then 73
when 255984 then 74
when 325020 then 75
when 325021 then 76
when 128935 then 77
when 103205 then 78
when 291503 then 79
when 130879 then 80
when 170576 then 81
when 255655 then 82
when 264819 then 83
when 155347 then 84
when 255985 then 85
when 256542 then 86
when 272181 then 87
when 120926 then 88
when 220135 then 89
when 281582 then 90
when 204946 then 91
when 169408 then 92
when 277357 then 93
when 161993 then 94
when 273530 then 95
when 255983 then 96
when 319966 then 97
when 29589 then 98
when 278340 then 99
when 225851 then 100
when 261709 then 101
when 280597 then 102
when 164579 then 103
when 164580 then 104
when 178644 then 105
when 196895 then 106
when 203792 then 107
when 209951 then 108
when 294702 then 109
when 123171 then 110
when 277788 then 111
when 264149 then 112
when 198993 then 113
when 260448 then 114
when 256763 then 115
when 111282 then 116
when 119047 then 117
when 325057 then 118
when 292731 then 119
when 28048 then 120
when 216180 then 121
when 255269 then 122
when 154938 then 123
when 270872 then 124
when 280350 then 125
when 318164 then 126
when 318163 then 127
when 158832 then 128
when 176233 then 129
when 168552 then 130
when 280295 then 131
when 280296 then 132
when 274000 then 133
when 217715 then 134
when 306882 then 135
when 61028 then 136
when 85671 then 137
when 61029 then 138
when 61060 then 139
when 134685 then 140
when 325228 then 141
when 325056 then 142
when 267464 then 143
when 179660 then 144
when 247562 then 145
when 325092 then 146
when 256285 then 147
when 207043 then 148
when 207047 then 149
when 103058 then 150
when 250023 then 151
when 297540 then 152
when 252297 then 153
when 250106 then 154
when 286960 then 155
when 225334 then 156
when 35132 then 157
when 256021 then 158
when 323376 then 159
when 215112 then 160
when 168261 then 161
when 168776 then 162
when 194099 then 163
when 252296 then 164
when 263554 then 165
when 278323 then 166
when 319968 then 167
when 179540 then 168
when 261466 then 169
when 274083 then 170
when 312431 then 171
when 222246 then 172
when 268721 then 173
when 172668 then 174
when 89176 then 175
when 217393 then 176
when 175962 then 177
when 212947 then 178
when 250036 then 179
when 263990 then 180
when 266451 then 181
when 252294 then 182
when 250105 then 183
when 28053 then 184
when 329544 then 185
when 181436 then 186
when 245020 then 187
when 325049 then 188
when 291861 then 189
when 307680 then 190
when 325058 then 191
when 325048 then 192
when 325053 then 193
when 325055 then 194
when 325060 then 195
when 325047 then 196
when 325054 then 197
when 172739 then 198
when 172356 then 199
when 181683 then 200
when 291841 then 201
when 162575 then 202
when 245350 then 203
when 323613 then 204
when 282129 then 205
when 324387 then 206
when 156523 then 207
when 325051 then 208
when 159569 then 209
when 324422 then 210
when 268510 then 211
when 323512 then 212
when 309551 then 213
when 173850 then 214
when 324384 then 215
when 299343 then 216
when 173852 then 217
when 138057 then 218
when 261835 then 219
when 173845 then 220
when 185558 then 221
when 209836 then 222
when 173851 then 223
when 166595 then 224
when 225961 then 225
when 198537 then 226
when 195751 then 227
when 262444 then 228
when 279887 then 229
when 208201 then 230
when 289058 then 231
when 202739 then 232
when 156358 then 233
when 74715 then 234
when 141291 then 235
when 219950 then 236
when 219951 then 237
when 115864 then 238
when 311581 then 239
when 289439 then 240
when 12710 then 241
when 248794 then 242
when 325023 then 243
when 302793 then 244
when 287908 then 245
when 253987 then 246
when 262486 then 247
when 290481 then 248
when 35126 then 249
when 124238 then 250
when 307232 then 251
when 203483 then 252
when 294956 then 253
when 297363 then 254
when 118297 then 255
when 173705 then 256
when 307231 then 257
when 323396 then 258
when 250587 then 259
when 285924 then 260
when 242416 then 261
when 311944 then 262
when 255699 then 263
when 318713 then 264
when 318714 then 265
when 72245 then 266
when 35123 then 267
when 251473 then 268
when 318711 then 269
when 318716 then 270
when 29546 then 271
when 191971 then 272
when 60302 then 273
when 253609 then 274
when 168305 then 275
when 245055 then 276
when 183986 then 277
when 196646 then 278
when 262487 then 279
when 24157 then 280
when 232868 then 281
when 296794 then 282
when 151488 then 283
when 201778 then 284
when 201210 then 285
when 136410 then 286
when 130301 then 287
when 297732 then 288
when 161793 then 289
when 18774 then 290
when 148157 then 291
when 60162 then 292
when 204584 then 293
when 214647 then 294
when 248442 then 295
when 173428 then 296
when 156076 then 297
when 191362 then 298
when 49459 then 299
when 147831 then 300
when 323754 then 301
when 250845 then 302
when 261476 then 303
when 24175 then 304
when 29547 then 305
when 305557 then 306
when 247737 then 307
when 204104 then 308
when 24579 then 309
when 273946 then 310
when 263923 then 311
when 206445 then 312
when 317589 then 313
when 225836 then 314
when 232435 then 315
when 80635 then 316
when 37283 then 317
when 86422 then 318
when 286012 then 319
when 49458 then 320
when 23568 then 321
when 215052 then 322
when 215412 then 323
when 197019 then 324
when 268514 then 325
when 19273 then 326
when 286909 then 327
when 37278 then 328
when 100424 then 329
when 24382 then 330
when 197952 then 331
when 11770 then 332
when 164643 then 333
when 121106 then 334
when 171897 then 335
when 261534 then 336
when 307186 then 337
when 268511 then 338
when 24454 then 339
when 75351 then 340
when 222284 then 341
when 278470 then 342
when 97434 then 343
when 24446 then 344
when 84421 then 345
when 47861 then 346
when 252434 then 347
when 252171 then 348
when 282424 then 349
when 330917 then 350
when 330910 then 351
when 330885 then 352
when 330916 then 353
when 330919 then 354
when 330913 then 355
when 330921 then 356
when 330914 then 357
when 330920 then 358
when 24652 then 359
when 172654 then 360
when 108798 then 361
when 102194 then 362
when 213590 then 363
when 245526 then 364
when 23576 then 365
when 156530 then 366
when 297205 then 367
when 250598 then 368
when 124300 then 369
when 276303 then 370
when 277984 then 371
when 280958 then 372
when 300863 then 373
when 70588 then 374
when 24720 then 375
when 70810 then 376
when 47912 then 377
when 70612 then 378
when 155581 then 379
when 215682 then 380
when 15176 then 381
when 310500 then 382
when 196413 then 383
when 257259 then 384
when 24729 then 385
when 227477 then 386
when 279987 then 387
when 286903 then 388
when 227476 then 389
when 316489 then 390
when 305561 then 391
when 24745 then 392
when 70587 then 393
when 12701 then 394
when 191365 then 395
when 107418 then 396
when 250597 then 397
when 189602 then 398
when 317535 then 399
when 284685 then 400
when 305562 then 401
when 329747 then 402
when 330922 then 403
when 330911 then 404
when 330915 then 405
when 330883 then 406
when 330909 then 407
when 330918 then 408
when 106559 then 409
when 74138 then 410
when 24731 then 411
when 49805 then 412
when 306679 then 413
when 175749 then 414
when 49800 then 415
when 209337 then 416
when 227478 then 417
when 7062 then 418
when 329746 then 419
when 329745 then 420
when 159428 then 421
when 156111 then 422
when 183799 then 423
when 183798 then 424
when 197550 then 425
when 209336 then 426
when 252795 then 427
when 252888 then 428
when 262183 then 429
when 247054 then 430
when 253397 then 431
when 198214 then 432
when 198213 then 433
when 325059 then 434
when 281165 then 435
when 172058 then 436
when 109273 then 437
when 164609 then 438
when 19080 then 439
when 61459 then 440
when 204090 then 441
when 198059 then 442
when 204266 then 443
when 249932 then 444
when 250066 then 445
when 252916 then 446
when 257075 then 447
when 264527 then 448
when 264221 then 449
when 264632 then 450
when 253406 then 451
when 291141 then 452
when 329233 then 453
when 255656 then 454
when 263713 then 455
when 302939 then 456
when 19191 then 457
when 170066 then 458
when 124559 then 459
when 208532 then 460
when 260875 then 461
when 251140 then 462
when 281857 then 463
when 253440 then 464
when 327068 then 465
when 317731 then 466
when 317681 then 467
when 19102 then 468
when 61451 then 469
when 204307 then 470
when 204306 then 471
when 214625 then 472
when 250044 then 473
when 261189 then 474
when 263096 then 475
when 42296 then 476
when 121206 then 477
when 267158 then 478
when 250490 then 479
when 269098 then 480
when 250498 then 481
when 290101 then 482
when 292873 then 483
when 296427 then 484
when 297791 then 485
when 250657 then 486
when 325982 then 487
when 325983 then 488
when 119138 then 489
when 198058 then 490
when 178931 then 491
when 61458 then 492
when 249704 then 493
when 249469 then 494
when 261077 then 495
when 268906 then 496
when 42297 then 497
when 284677 then 498
when 295085 then 499
when 304324 then 500
when 61975 then 501
when 207828 then 502
when 223151 then 503
when 257226 then 504
when 253410 then 505
when 266745 then 506
when 252764 then 507
when 306886 then 508
when 199072 then 509
when 284144 then 510
when 264012 then 511
when 317671 then 512
when 113118 then 513
when 168320 then 514
when 184163 then 515
when 205576 then 516
when 285008 then 517
when 140024 then 518
when 181254 then 519
when 181257 then 520
when 217650 then 521
when 256913 then 522
when 266218 then 523
when 216179 then 524
when 255584 then 525
when 157896 then 526
when 157897 then 527
when 157898 then 528
when 213490 then 529
when 192153 then 530
when 157895 then 531
when 213492 then 532
when 276798 then 533
when 260458 then 534
when 262254 then 535
when 205392 then 536
when 213491 then 537
when 74636 then 538
when 277860 then 539
when 81903 then 540
when 292979 then 541
when 293039 then 542
when 206459 then 543
when 317307 then 544
when 317297 then 545
when 252432 then 546
when 262439 then 547
when 322360 then 548
when 317244 then 549
when 99633 then 550
when 317237 then 551
when 317245 then 552
when 165113 then 553
when 255986 then 554
when 316968 then 555
when 316967 then 556
when 316965 then 557
when 276069 then 558
when 263480 then 559
when 263483 then 560
when 151603 then 561
when 254377 then 562
when 109828 then 563
when 324826 then 564
when 324828 then 565
when 126626 then 566
when 288771 then 567
when 263478 then 568
when 263764 then 569
when 324837 then 570
when 316966 then 571
when 316969 then 572
when 263476 then 573
when 136885 then 574
when 192565 then 575
when 152187 then 576
when 173934 then 577
when 250024 then 578
when 276721 then 579
when 293485 then 580
when 266386 then 581
when 42180 then 582
when 248699 then 583
when 309879 then 584
when 317290 then 585
when 317242 then 586
when 200021 then 587
when 263993 then 588
when 260755 then 589
when 317241 then 590
when 317289 then 591
when 209920 then 592
when 329536 then 593
when 128325 then 594
when 248344 then 595
when 246380 then 596
when 289543 then 597
when 289541 then 598
when 301227 then 599
when 302933 then 600
when 299129 then 601
when 303745 then 602
when 310433 then 603
when 249450 then 604
when 251036 then 605
when 226012 then 606
when 325896 then 607
when 277240 then 608
when 296690 then 609
when 302931 then 610
when 11029 then 611
when 246555 then 612
when 270054 then 613
when 303985 then 614
when 325962 then 615
when 54035 then 616
when 188175 then 617
when 118424 then 618
when 108302 then 619
when 251882 then 620
when 23959 then 621
when 276862 then 622
when 274419 then 623
when 293567 then 624
when 46409 then 625
when 106982 then 626
when 325952 then 627
when 127967 then 628
when 263386 then 629
when 109896 then 630
when 158371 then 631
when 70471 then 632
when 135099 then 633
when 35160 then 634
when 164625 then 635
when 170365 then 636
when 183933 then 637
when 192395 then 638
when 196699 then 639
when 28299 then 640
when 144002 then 641
when 250584 then 642
when 251653 then 643
when 261830 then 644
when 261541 then 645
when 21876 then 646
when 262286 then 647
when 184014 then 648
when 276863 then 649
when 155702 then 650
when 129740 then 651
when 103865 then 652
when 162556 then 653
when 207971 then 654
when 23961 then 655
when 253969 then 656
when 270223 then 657
when 175670 then 658
when 21909 then 659
when 157891 then 660
when 202628 then 661
when 34627 then 662
when 21899 then 663
when 293568 then 664
when 261604 then 665
when 114177 then 666
when 128907 then 667
when 130660 then 668
when 19983 then 669
when 22002 then 670
when 192910 then 671
when 15127 then 672
when 249692 then 673
when 21894 then 674
when 23928 then 675
when 81093 then 676
when 21846 then 677
when 263388 then 678
when 252484 then 679
when 21847 then 680
when 264571 then 681
when 268947 then 682
when 269101 then 683
when 84399 then 684
when 269920 then 685
when 250128 then 686
when 181439 then 687
when 21848 then 688
when 155701 then 689
when 77578 then 690
when 21949 then 691
when 21997 then 692
when 21999 then 693
when 128960 then 694
when 101422 then 695
when 121030 then 696
when 198559 then 697
when 193918 then 698
when 117110 then 699
when 299127 then 700
when 102327 then 701
when 305486 then 702
when 318055 then 703
when 155333 then 704
when 206301 then 705
when 318071 then 706
when 326160 then 707
when 325953 then 708
when 130659 then 709
when 123996 then 710
when 126892 then 711
when 126893 then 712
when 100276 then 713
when 92720 then 714
when 126894 then 715
when 9170 then 716
when 176040 then 717
when 181440 then 718
when 169651 then 719
when 30098 then 720
when 30094 then 721
when 192385 then 722
when 197573 then 723
when 132147 then 724
when 214225 then 725
when 217977 then 726
when 248473 then 727
when 247899 then 728
when 251954 then 729
when 250176 then 730
when 248202 then 731
when 252485 then 732
when 266529 then 733
when 254088 then 734
when 50974 then 735
when 50968 then 736
when 105451 then 737
when 109579 then 738
when 109275 then 739
when 124567 then 740
when 77560 then 741
when 107896 then 742
when 254038 then 743
when 58398 then 744
when 291754 then 745
when 288974 then 746
when 293450 then 747
when 297789 then 748
when 305222 then 749
when 117169 then 750
when 21939 then 751
when 320553 then 752
when 326161 then 753
when 21981 then 754
when 123497 then 755
when 59736 then 756
when 118787 then 757
when 106970 then 758
when 141672 then 759
when 21984 then 760
when 48941 then 761
when 21995 then 762
when 132297 then 763
when 165019 then 764
when 169786 then 765
when 99863 then 766
when 122866 then 767
when 28034 then 768
when 28046 then 769
when 133172 then 770
when 197368 then 771
when 197372 then 772
when 197374 then 773
when 144873 then 774
when 170367 then 775
when 197375 then 776
when 197376 then 777
when 211234 then 778
when 4772 then 779
when 196057 then 780
when 81596 then 781
when 205699 then 782
when 38441 then 783
when 251118 then 784
when 253465 then 785
when 89117 then 786
when 256513 then 787
when 22051 then 788
when 130336 then 789
when 264653 then 790
when 252191 then 791
when 253986 then 792
when 251640 then 793
when 262289 then 794
when 264126 then 795
when 263989 then 796
when 273164 then 797
when 276864 then 798
when 270447 then 799
when 279549 then 800
when 21979 then 801
when 64686 then 802
when 99457 then 803
when 150760 then 804
when 126543 then 805
when 121915 then 806
when 117111 then 807
when 306887 then 808
when 28019 then 809
when 155332 then 810
when 325070 then 811
when 200393 then 812
when 21987 then 813
when 21988 then 814
when 147670 then 815
when 158307 then 816
when 46423 then 817
when 61031 then 818
when 123670 then 819
when 100606 then 820
when 155664 then 821
when 54043 then 822
when 48930 then 823
when 120748 then 824
when 4774 then 825
when 181443 then 826
when 4771 then 827
when 30093 then 828
when 192388 then 829
when 88923 then 830
when 198746 then 831
when 144446 then 832
when 205887 then 833
when 209921 then 834
when 210318 then 835
when 186809 then 836
when 105492 then 837
when 200072 then 838
when 28114 then 839
when 250977 then 840
when 247008 then 841
when 266350 then 842
when 95359 then 843
when 252343 then 844
when 253970 then 845
when 269451 then 846
when 263392 then 847
when 50978 then 848
when 38928 then 849
when 269921 then 850
when 121874 then 851
when 178933 then 852
when 147192 then 853
when 23962 then 854
when 44932 then 855
when 65807 then 856
when 178874 then 857
when 276052 then 858
when 4711 then 859
when 28031 then 860
when 137914 then 861
when 157892 then 862
when 9150 then 863
when 292862 then 864
when 297788 then 865
when 56388 then 866
when 113970 then 867
when 302002 then 868
when 4779 then 869
when 255306 then 870
when 74993 then 871
when 73109 then 872
when 56380 then 873
when 21991 then 874
when 159255 then 875
when 150827 then 876
when 48935 then 877
when 4773 then 878
when 192363 then 879
when 193227 then 880
when 192391 then 881
when 200045 then 882
when 204027 then 883
when 204030 then 884
when 213258 then 885
when 108022 then 886
when 214623 then 887
when 115028 then 888
when 128793 then 889
when 151955 then 890
when 220991 then 891
when 217978 then 892
when 132099 then 893
when 250515 then 894
when 248751 then 895
when 251230 then 896
when 252148 then 897
when 253505 then 898
when 255439 then 899
when 256068 then 900
when 44925 then 901
when 262351 then 902
when 68130 then 903
when 262966 then 904
when 266640 then 905
when 264273 then 906
when 267392 then 907
when 267393 then 908
when 118076 then 909
when 262967 then 910
when 44776 then 911
when 273335 then 912
when 248908 then 913
when 273523 then 914
when 254063 then 915
when 48932 then 916
when 205742 then 917
when 40254 then 918
when 196395 then 919
when 99505 then 920
when 158158 then 921
when 4743 then 922
when 125119 then 923
when 95789 then 924
when 292718 then 925
when 56403 then 926
when 46411 then 927
when 318057 then 928
when 318061 then 929
when 318062 then 930
when 155334 then 931
when 319659 then 932
when 329808 then 933
when 208564 then 934
when 124924 then 935
when 125678 then 936
when 124925 then 937
when 21990 then 938
when 137831 then 939
when 4567 then 940
when 168834 then 941
when 168832 then 942
when 104613 then 943
when 170252 then 944
when 176054 then 945
when 22825 then 946
when 15139 then 947
when 4712 then 948
when 69611 then 949
when 104772 then 950
when 84398 then 951
when 206701 then 952
when 206703 then 953
when 144017 then 954
when 215653 then 955
when 216506 then 956
when 225287 then 957
when 225339 then 958
when 222658 then 959
when 251533 then 960
when 252053 then 961
when 254302 then 962
when 255627 then 963
when 256948 then 964
when 261213 then 965
when 263788 then 966
when 115169 then 967
when 264141 then 968
when 267033 then 969
when 261831 then 970
when 264913 then 971
when 274368 then 972
when 155548 then 973
when 128857 then 974
when 93121 then 975
when 28020 then 976
when 28035 then 977
when 28022 then 978
when 28032 then 979
when 75297 then 980
when 120761 then 981
when 168793 then 982
when 205195 then 983
when 108860 then 984
when 137848 then 985
when 196059 then 986
when 291217 then 987
when 71050 then 988
when 70217 then 989
when 128798 then 990
when 170765 then 991
when 40247 then 992
when 119401 then 993
when 181572 then 994
when 183583 then 995
when 4546 then 996
when 185609 then 997
when 206288 then 998
when 211317 then 999
when 217333 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 (323148,325061,66385,124566,125153,105260,65749,249890,206257,233224,262447,262483,262481,76387,289680,262484,122063,262480,317052,323515,154937,253266,323723,148580,256609,323680,296355,170026,266183,181682,251723,256288,325022,282130,297050,319967,323147,323149,277765,280768,282131,292247,298566,277359,282629,262482,204945,232436,150206,222329,325230,12768,220136,251543,248795,324872,255981,263196,267101,232434,138250,138671,147655,147657,252699,272194,281361,266182,248793,134564,156445,153305,138670,255984,325020,325021,128935,103205,291503,130879,170576,255655,264819,155347,255985,256542,272181,120926,220135,281582,204946,169408,277357,161993,273530,255983,319966,29589,278340,225851,261709,280597,164579,164580,178644,196895,203792,209951,294702,123171,277788,264149,198993,260448,256763,111282,119047,325057,292731,28048,216180,255269,154938,270872,280350,318164,318163,158832,176233,168552,280295,280296,274000,217715,306882,61028,85671,61029,61060,134685,325228,325056,267464,179660,247562,325092,256285,207043,207047,103058,250023,297540,252297,250106,286960,225334,35132,256021,323376,215112,168261,168776,194099,252296,263554,278323,319968,179540,261466,274083,312431,222246,268721,172668,89176,217393,175962,212947,250036,263990,266451,252294,250105,28053,329544,181436,245020,325049,291861,307680,325058,325048,325053,325055,325060,325047,325054,172739,172356,181683,291841,162575,245350,323613,282129,324387,156523,325051,159569,324422,268510,323512,309551,173850,324384,299343,173852,138057,261835,173845,185558,209836,173851,166595,225961,198537,195751,262444,279887,208201,289058,202739,156358,74715,141291,219950,219951,115864,311581,289439,12710,248794,325023,302793,287908,253987,262486,290481,35126,124238,307232,203483,294956,297363,118297,173705,307231,323396,250587,285924,242416,311944,255699,318713,318714,72245,35123,251473,318711,318716,29546,191971,60302,253609,168305,245055,183986,196646,262487,24157,232868,296794,151488,201778,201210,136410,130301,297732,161793,18774,148157,60162,204584,214647,248442,173428,156076,191362,49459,147831,323754,250845,261476,24175,29547,305557,247737,204104,24579,273946,263923,206445,317589,225836,232435,80635,37283,86422,286012,49458,23568,215052,215412,197019,268514,19273,286909,37278,100424,24382,197952,11770,164643,121106,171897,261534,307186,268511,24454,75351,222284,278470,97434,24446,84421,47861,252434,252171,282424,330917,330910,330885,330916,330919,330913,330921,330914,330920,24652,172654,108798,102194,213590,245526,23576,156530,297205,250598,124300,276303,277984,280958,300863,70588,24720,70810,47912,70612,155581,215682,15176,310500,196413,257259,24729,227477,279987,286903,227476,316489,305561,24745,70587,12701,191365,107418,250597,189602,317535,284685,305562,329747,330922,330911,330915,330883,330909,330918,106559,74138,24731,49805,306679,175749,49800,209337,227478,7062,329746,329745,159428,156111,183799,183798,197550,209336,252795,252888,262183,247054,253397,198214,198213,325059,281165,172058,109273,164609,19080,61459,204090,198059,204266,249932,250066,252916,257075,264527,264221,264632,253406,291141,329233,255656,263713,302939,19191,170066,124559,208532,260875,251140,281857,253440,327068,317731,317681,19102,61451,204307,204306,214625,250044,261189,263096,42296,121206,267158,250490,269098,250498,290101,292873,296427,297791,250657,325982,325983,119138,198058,178931,61458,249704,249469,261077,268906,42297,284677,295085,304324,61975,207828,223151,257226,253410,266745,252764,306886,199072,284144,264012,317671,113118,168320,184163,205576,285008,140024,181254,181257,217650,256913,266218,216179,255584,157896,157897,157898,213490,192153,157895,213492,276798,260458,262254,205392,213491,74636,277860,81903,292979,293039,206459,317307,317297,252432,262439,322360,317244,99633,317237,317245,165113,255986,316968,316967,316965,276069,263480,263483,151603,254377,109828,324826,324828,126626,288771,263478,263764,324837,316966,316969,263476,136885,192565,152187,173934,250024,276721,293485,266386,42180,248699,309879,317290,317242,200021,263993,260755,317241,317289,209920,329536,128325,248344,246380,289543,289541,301227,302933,299129,303745,310433,249450,251036,226012,325896,277240,296690,302931,11029,246555,270054,303985,325962,54035,188175,118424,108302,251882,23959,276862,274419,293567,46409,106982,325952,127967,263386,109896,158371,70471,135099,35160,164625,170365,183933,192395,196699,28299,144002,250584,251653,261830,261541,21876,262286,184014,276863,155702,129740,103865,162556,207971,23961,253969,270223,175670,21909,157891,202628,34627,21899,293568,261604,114177,128907,130660,19983,22002,192910,15127,249692,21894,23928,81093,21846,263388,252484,21847,264571,268947,269101,84399,269920,250128,181439,21848,155701,77578,21949,21997,21999,128960,101422,121030,198559,193918,117110,299127,102327,305486,318055,155333,206301,318071,326160,325953,130659,123996,126892,126893,100276,92720,126894,9170,176040,181440,169651,30098,30094,192385,197573,132147,214225,217977,248473,247899,251954,250176,248202,252485,266529,254088,50974,50968,105451,109579,109275,124567,77560,107896,254038,58398,291754,288974,293450,297789,305222,117169,21939,320553,326161,21981,123497,59736,118787,106970,141672,21984,48941,21995,132297,165019,169786,99863,122866,28034,28046,133172,197368,197372,197374,144873,170367,197375,197376,211234,4772,196057,81596,205699,38441,251118,253465,89117,256513,22051,130336,264653,252191,253986,251640,262289,264126,263989,273164,276864,270447,279549,21979,64686,99457,150760,126543,121915,117111,306887,28019,155332,325070,200393,21987,21988,147670,158307,46423,61031,123670,100606,155664,54043,48930,120748,4774,181443,4771,30093,192388,88923,198746,144446,205887,209921,210318,186809,105492,200072,28114,250977,247008,266350,95359,252343,253970,269451,263392,50978,38928,269921,121874,178933,147192,23962,44932,65807,178874,276052,4711,28031,137914,157892,9150,292862,297788,56388,113970,302002,4779,255306,74993,73109,56380,21991,159255,150827,48935,4773,192363,193227,192391,200045,204027,204030,213258,108022,214623,115028,128793,151955,220991,217978,132099,250515,248751,251230,252148,253505,255439,256068,44925,262351,68130,262966,266640,264273,267392,267393,118076,262967,44776,273335,248908,273523,254063,48932,205742,40254,196395,99505,158158,4743,125119,95789,292718,56403,46411,318057,318061,318062,155334,319659,329808,208564,124924,125678,124925,21990,137831,4567,168834,168832,104613,170252,176054,22825,15139,4712,69611,104772,84398,206701,206703,144017,215653,216506,225287,225339,222658,251533,252053,254302,255627,256948,261213,263788,115169,264141,267033,261831,264913,274368,155548,128857,93121,28020,28035,28022,28032,75297,120761,168793,205195,108860,137848,196059,291217,71050,70217,128798,170765,40247,119401,181572,183583,4546,185609,206288,211317,217333)
and ltrim(rtrim(lower(a.dept))) = 'firearm accessories'
and (a.of3='22 LR' or a.of3='22' or a.of3='22/410' or a.of3='22LR/22WMR' or a.of3='22S/L/LR')
group by a.style_id
order by instock desc, ranking asc
|