Sql |
SELECT distinct a.style_id,
case a.style_id
when 143100 then 1
when 155356 then 2
when 207047 then 3
when 225677 then 4
when 61302 then 5
when 247536 then 6
when 261358 then 7
when 265014 then 8
when 268728 then 9
when 43620 then 10
when 268373 then 11
when 61303 then 12
when 43025 then 13
when 213857 then 14
when 250127 then 15
when 121210 then 16
when 254547 then 17
when 245026 then 18
when 126805 then 19
when 272506 then 20
when 143315 then 21
when 288346 then 22
when 298540 then 23
when 298396 then 24
when 212129 then 25
when 213858 then 26
when 254313 then 27
when 268723 then 28
when 277175 then 29
when 316545 then 30
when 211811 then 31
when 222406 then 32
when 245028 then 33
when 245027 then 34
when 268731 then 35
when 257285 then 36
when 39530 then 37
when 184310 then 38
when 184311 then 39
when 254186 then 40
when 268724 then 41
when 298711 then 42
when 306703 then 43
when 202302 then 44
when 39340 then 45
when 195463 then 46
when 249990 then 47
when 207700 then 48
when 170314 then 49
when 252444 then 50
when 73378 then 51
when 254223 then 52
when 184357 then 53
when 255591 then 54
when 228153 then 55
when 291725 then 56
when 322836 then 57
when 124789 then 58
when 202798 then 59
when 249935 then 60
when 125018 then 61
when 181487 then 62
when 202527 then 63
when 217965 then 64
when 282963 then 65
when 151558 then 66
when 23539 then 67
when 248264 then 68
when 28114 then 69
when 251682 then 70
when 312306 then 71
when 247671 then 72
when 144880 then 73
when 327004 then 74
when 270732 then 75
when 248751 then 76
when 317901 then 77
when 204442 then 78
when 19181 then 79
when 19180 then 80
when 137597 then 81
when 161825 then 82
when 204311 then 83
when 216552 then 84
when 216527 then 85
when 249937 then 86
when 254848 then 87
when 260841 then 88
when 141562 then 89
when 267981 then 90
when 128312 then 91
when 79096 then 92
when 99665 then 93
when 24534 then 94
when 169843 then 95
when 169846 then 96
when 213297 then 97
when 245695 then 98
when 253465 then 99
when 264889 then 100
when 248955 then 101
when 200029 then 102
when 247658 then 103
when 263909 then 104
when 256020 then 105
when 285501 then 106
when 307781 then 107
when 292040 then 108
when 105889 then 109
when 23529 then 110
when 139955 then 111
when 207854 then 112
when 199244 then 113
when 200342 then 114
when 205382 then 115
when 269967 then 116
when 44908 then 117
when 130331 then 118
when 205679 then 119
when 214097 then 120
when 280390 then 121
when 312307 then 122
when 211810 then 123
when 178667 then 124
when 13392 then 125
when 248752 then 126
when 249311 then 127
when 249312 then 128
when 251863 then 129
when 292979 then 130
when 203790 then 131
when 232220 then 132
when 247679 then 133
when 247680 then 134
when 247673 then 135
when 247783 then 136
when 267843 then 137
when 267845 then 138
when 267846 then 139
when 267844 then 140
when 269101 then 141
when 277916 then 142
when 277918 then 143
when 285507 then 144
when 285771 then 145
when 287937 then 146
when 287933 then 147
when 289385 then 148
when 290483 then 149
when 299262 then 150
when 299253 then 151
when 307696 then 152
when 318055 then 153
when 319852 then 154
when 331020 then 155
when 330978 then 156
when 69675 then 157
when 136927 then 158
when 141800 then 159
when 202739 then 160
when 202511 then 161
when 206256 then 162
when 210145 then 163
when 248328 then 164
when 249754 then 165
when 254592 then 166
when 255251 then 167
when 207424 then 168
when 89930 then 169
when 284851 then 170
when 304633 then 171
when 128311 then 172
when 256903 then 173
when 145134 then 174
when 195748 then 175
when 245694 then 176
when 264586 then 177
when 118076 then 178
when 178666 then 179
when 251738 then 180
when 281331 then 181
when 291113 then 182
when 321263 then 183
when 200339 then 184
when 153387 then 185
when 89241 then 186
when 181482 then 187
when 188870 then 188
when 225344 then 189
when 227233 then 190
when 285943 then 191
when 285839 then 192
when 291109 then 193
when 291754 then 194
when 305222 then 195
when 307890 then 196
when 309625 then 197
when 326292 then 198
when 330957 then 199
when 110675 then 200
when 257287 then 201
when 124924 then 202
when 206284 then 203
when 254256 then 204
when 283972 then 205
when 205195 then 206
when 175546 then 207
when 175547 then 208
when 111562 then 209
when 202131 then 210
when 205643 then 211
when 173493 then 212
when 117161 then 213
when 228155 then 214
when 228156 then 215
when 228154 then 216
when 152910 then 217
when 255661 then 218
when 263549 then 219
when 293404 then 220
when 296548 then 221
when 158388 then 222
when 89028 then 223
when 61175 then 224
when 61170 then 225
when 103831 then 226
when 101905 then 227
when 61300 then 228
when 159424 then 229
when 164832 then 230
when 168324 then 231
when 165522 then 232
when 202771 then 233
when 214611 then 234
when 249934 then 235
when 252398 then 236
when 254572 then 237
when 255252 then 238
when 276723 then 239
when 257257 then 240
when 97871 then 241
when 153388 then 242
when 197602 then 243
when 198802 then 244
when 205379 then 245
when 213726 then 246
when 121174 then 247
when 112595 then 248
when 163704 then 249
when 171941 then 250
when 251295 then 251
when 267818 then 252
when 268271 then 253
when 268413 then 254
when 269277 then 255
when 280182 then 256
when 280843 then 257
when 285187 then 258
when 285166 then 259
when 285146 then 260
when 285156 then 261
when 285155 then 262
when 285185 then 263
when 285514 then 264
when 285803 then 265
when 285886 then 266
when 287925 then 267
when 287899 then 268
when 290551 then 269
when 290584 then 270
when 291077 then 271
when 294930 then 272
when 299054 then 273
when 299205 then 274
when 301551 then 275
when 305568 then 276
when 305103 then 277
when 307695 then 278
when 309311 then 279
when 319851 then 280
when 326318 then 281
when 326566 then 282
when 330767 then 283
when 330955 then 284
when 41531 then 285
when 248659 then 286
when 256899 then 287
when 128639 then 288
when 110298 then 289
when 48944 then 290
when 181572 then 291
when 196049 then 292
when 202481 then 293
when 213298 then 294
when 213299 then 295
when 225270 then 296
when 263666 then 297
when 278149 then 298
when 272200 then 299
when 169480 then 300
when 169845 then 301
when 183951 then 302
when 13393 then 303
when 150211 then 304
when 209921 then 305
when 210318 then 306
when 171944 then 307
when 218079 then 308
when 218326 then 309
when 117818 then 310
when 247676 then 311
when 247826 then 312
when 267838 then 313
when 267841 then 314
when 267774 then 315
when 268265 then 316
when 268770 then 317
when 269080 then 318
when 269081 then 319
when 269451 then 320
when 277907 then 321
when 277909 then 322
when 279963 then 323
when 280845 then 324
when 280830 then 325
when 281657 then 326
when 281736 then 327
when 281416 then 328
when 285508 then 329
when 285522 then 330
when 285379 then 331
when 285347 then 332
when 285428 then 333
when 285346 then 334
when 285794 then 335
when 285840 then 336
when 287930 then 337
when 287910 then 338
when 289745 then 339
when 287013 then 340
when 292997 then 341
when 294876 then 342
when 294960 then 343
when 296575 then 344
when 248952 then 345
when 298986 then 346
when 298993 then 347
when 305507 then 348
when 310291 then 349
when 316663 then 350
when 312284 then 351
when 331001 then 352
when 164345 then 353
when 202628 then 354
when 293151 then 355
when 61169 then 356
when 61301 then 357
when 61487 then 358
when 179676 then 359
when 204919 then 360
when 202738 then 361
when 72688 then 362
when 204312 then 363
when 204587 then 364
when 201196 then 365
when 218016 then 366
when 219610 then 367
when 159149 then 368
when 247445 then 369
when 245350 then 370
when 248327 then 371
when 250052 then 372
when 126694 then 373
when 250055 then 374
when 254118 then 375
when 256793 then 376
when 253439 then 377
when 277298 then 378
when 290187 then 379
when 293164 then 380
when 293364 then 381
when 154689 then 382
when 205191 then 383
when 209840 then 384
when 220974 then 385
when 220976 then 386
when 220975 then 387
when 209475 then 388
when 251862 then 389
when 251860 then 390
when 253108 then 391
when 261340 then 392
when 266935 then 393
when 193439 then 394
when 295107 then 395
when 301285 then 396
when 206744 then 397
when 172710 then 398
when 203616 then 399
when 122517 then 400
when 122327 then 401
when 141242 then 402
when 142968 then 403
when 169265 then 404
when 202158 then 405
when 208654 then 406
when 245849 then 407
when 248959 then 408
when 248956 then 409
when 151676 then 410
when 252346 then 411
when 272916 then 412
when 283970 then 413
when 323328 then 414
when 248661 then 415
when 256900 then 416
when 148326 then 417
when 157927 then 418
when 156356 then 419
when 171961 then 420
when 169875 then 421
when 193227 then 422
when 202808 then 423
when 221035 then 424
when 215235 then 425
when 242412 then 426
when 61374 then 427
when 246760 then 428
when 250165 then 429
when 250445 then 430
when 67720 then 431
when 252148 then 432
when 256068 then 433
when 97196 then 434
when 267419 then 435
when 267886 then 436
when 268284 then 437
when 268239 then 438
when 277878 then 439
when 280181 then 440
when 285143 then 441
when 285423 then 442
when 285493 then 443
when 285510 then 444
when 285779 then 445
when 288151 then 446
when 288098 then 447
when 288033 then 448
when 289744 then 449
when 289770 then 450
when 290843 then 451
when 290536 then 452
when 290594 then 453
when 293059 then 454
when 294899 then 455
when 297394 then 456
when 301150 then 457
when 305107 then 458
when 309610 then 459
when 311775 then 460
when 318057 then 461
when 318061 then 462
when 319846 then 463
when 324842 then 464
when 322977 then 465
when 330990 then 466
when 68634 then 467
when 75668 then 468
when 24386 then 469
when 99095 then 470
when 264449 then 471
when 191512 then 472
when 28308 then 473
when 182367 then 474
when 221038 then 475
when 123907 then 476
when 111463 then 477
when 122834 then 478
when 139993 then 479
when 48945 then 480
when 151211 then 481
when 151774 then 482
when 161406 then 483
when 48981 then 484
when 65289 then 485
when 115101 then 486
when 181484 then 487
when 198514 then 488
when 202530 then 489
when 202528 then 490
when 202529 then 491
when 151650 then 492
when 205603 then 493
when 247363 then 494
when 126572 then 495
when 252448 then 496
when 256646 then 497
when 264887 then 498
when 264888 then 499
when 317862 then 500
when 317863 then 501
when 317864 then 502
when 255290 then 503
when 317892 then 504
when 317891 then 505
when 130488 then 506
when 28043 then 507
when 172953 then 508
when 196379 then 509
when 197599 then 510
when 204867 then 511
when 225339 then 512
when 228588 then 513
when 242415 then 514
when 245427 then 515
when 253303 then 516
when 266766 then 517
when 267839 then 518
when 267835 then 519
when 267821 then 520
when 267825 then 521
when 267828 then 522
when 267824 then 523
when 267814 then 524
when 267832 then 525
when 267819 then 526
when 267836 then 527
when 267831 then 528
when 267826 then 529
when 267829 then 530
when 267833 then 531
when 267816 then 532
when 267817 then 533
when 267820 then 534
when 267882 then 535
when 276782 then 536
when 278382 then 537
when 279984 then 538
when 281159 then 539
when 281730 then 540
when 285412 then 541
when 285415 then 542
when 285516 then 543
when 285506 then 544
when 285426 then 545
when 286308 then 546
when 285783 then 547
when 285819 then 548
when 285855 then 549
when 277379 then 550
when 290506 then 551
when 290502 then 552
when 291112 then 553
when 290565 then 554
when 290497 then 555
when 291256 then 556
when 293003 then 557
when 294871 then 558
when 294877 then 559
when 297379 then 560
when 297414 then 561
when 297373 then 562
when 299254 then 563
when 300610 then 564
when 300594 then 565
when 303655 then 566
when 307702 then 567
when 307777 then 568
when 312395 then 569
when 323587 then 570
when 325234 then 571
when 326308 then 572
when 326306 then 573
when 329044 then 574
when 329558 then 575
when 330244 then 576
when 330972 then 577
when 61173 then 578
when 61172 then 579
when 179496 then 580
when 72689 then 581
when 204061 then 582
when 204062 then 583
when 185604 then 584
when 250053 then 585
when 126762 then 586
when 254571 then 587
when 256417 then 588
when 193652 then 589
when 250485 then 590
when 266745 then 591
when 291607 then 592
when 298172 then 593
when 324009 then 594
when 24385 then 595
when 24387 then 596
when 47886 then 597
when 183979 then 598
when 254377 then 599
when 255615 then 600
when 261337 then 601
when 262405 then 602
when 286588 then 603
when 292850 then 604
when 292827 then 605
when 295109 then 606
when 159528 then 607
when 277843 then 608
when 285206 then 609
when 44726 then 610
when 13397 then 611
when 13396 then 612
when 210666 then 613
when 217333 then 614
when 118777 then 615
when 158335 then 616
when 222563 then 617
when 217253 then 618
when 223087 then 619
when 228599 then 620
when 228613 then 621
when 228603 then 622
when 242398 then 623
when 249115 then 624
when 72185 then 625
when 49007 then 626
when 168856 then 627
when 170677 then 628
when 252303 then 629
when 263956 then 630
when 267412 then 631
when 267791 then 632
when 267795 then 633
when 267797 then 634
when 267793 then 635
when 268778 then 636
when 272203 then 637
when 280844 then 638
when 281296 then 639
when 281746 then 640
when 281377 then 641
when 281365 then 642
when 285387 then 643
when 285937 then 644
when 285873 then 645
when 285843 then 646
when 287922 then 647
when 288115 then 648
when 290010 then 649
when 290660 then 650
when 291254 then 651
when 291255 then 652
when 292162 then 653
when 292996 then 654
when 292986 then 655
when 294950 then 656
when 294897 then 657
when 296471 then 658
when 299002 then 659
when 300588 then 660
when 305596 then 661
when 305070 then 662
when 305061 then 663
when 307691 then 664
when 307703 then 665
when 309652 then 666
when 309587 then 667
when 309591 then 668
when 310293 then 669
when 310284 then 670
when 317853 then 671
when 322500 then 672
when 322523 then 673
when 325223 then 674
when 319930 then 675
when 330977 then 676
when 331030 then 677
when 318079 then 678
when 77223 then 679
when 167824 then 680
when 267976 then 681
when 279112 then 682
when 157974 then 683
when 148141 then 684
when 170303 then 685
when 189066 then 686
when 188882 then 687
when 189306 then 688
when 192097 then 689
when 205601 then 690
when 214583 then 691
when 216708 then 692
when 266130 then 693
when 250944 then 694
when 323327 then 695
when 212275 then 696
when 122101 then 697
when 251118 then 698
when 264425 then 699
when 264440 then 700
when 285153 then 701
when 76867 then 702
when 287923 then 703
when 305594 then 704
when 324594 then 705
when 316672 then 706
when 61176 then 707
when 19430 then 708
when 19432 then 709
when 158312 then 710
when 209594 then 711
when 215040 then 712
when 221175 then 713
when 252622 then 714
when 262137 then 715
when 252759 then 716
when 290167 then 717
when 256902 then 718
when 175734 then 719
when 205193 then 720
when 253325 then 721
when 261338 then 722
when 263787 then 723
when 281537 then 724
when 289114 then 725
when 292849 then 726
when 292848 then 727
when 292853 then 728
when 292828 then 729
when 118863 then 730
when 103550 then 731
when 125792 then 732
when 163874 then 733
when 85564 then 734
when 108216 then 735
when 209923 then 736
when 220135 then 737
when 115803 then 738
when 225692 then 739
when 249308 then 740
when 167958 then 741
when 161359 then 742
when 143260 then 743
when 249167 then 744
when 266522 then 745
when 268240 then 746
when 268605 then 747
when 271473 then 748
when 277895 then 749
when 278389 then 750
when 279954 then 751
when 280859 then 752
when 285410 then 753
when 207386 then 754
when 285786 then 755
when 285813 then 756
when 285930 then 757
when 288135 then 758
when 297365 then 759
when 297392 then 760
when 298954 then 761
when 298971 then 762
when 298944 then 763
when 299329 then 764
when 301552 then 765
when 292647 then 766
when 305627 then 767
when 304994 then 768
when 307687 then 769
when 310289 then 770
when 312387 then 771
when 322585 then 772
when 324877 then 773
when 325293 then 774
when 324787 then 775
when 324757 then 776
when 322160 then 777
when 322162 then 778
when 211271 then 779
when 70403 then 780
when 79655 then 781
when 12689 then 782
when 24384 then 783
when 37245 then 784
when 101928 then 785
when 213316 then 786
when 273523 then 787
when 273524 then 788
when 49870 then 789
when 307721 then 790
when 171942 then 791
when 175979 then 792
when 205375 then 793
when 299027 then 794
when 305472 then 795
when 324593 then 796
when 321321 then 797
when 282186 then 798
when 326646 then 799
when 101487 then 800
when 267480 then 801
when 28018 then 802
when 116856 then 803
when 85413 then 804
when 111694 then 805
when 134647 then 806
when 137832 then 807
when 137833 then 808
when 138408 then 809
when 144915 then 810
when 144256 then 811
when 155027 then 812
when 151767 then 813
when 168032 then 814
when 169719 then 815
when 90415 then 816
when 178735 then 817
when 181485 then 818
when 189752 then 819
when 201014 then 820
when 202148 then 821
when 204122 then 822
when 203850 then 823
when 202526 then 824
when 215614 then 825
when 216915 then 826
when 216916 then 827
when 168583 then 828
when 216905 then 829
when 84397 then 830
when 225346 then 831
when 225284 then 832
when 245865 then 833
when 248221 then 834
when 216904 then 835
when 117476 then 836
when 252447 then 837
when 48986 then 838
when 117394 then 839
when 185645 then 840
when 252445 then 841
when 252306 then 842
when 254368 then 843
when 256783 then 844
when 256069 then 845
when 263547 then 846
when 264311 then 847
when 262439 then 848
when 263957 then 849
when 256070 then 850
when 263764 then 851
when 266475 then 852
when 267126 then 853
when 267306 then 854
when 267235 then 855
when 267830 then 856
when 267837 then 857
when 267784 then 858
when 268299 then 859
when 268457 then 860
when 271764 then 861
when 271472 then 862
when 274316 then 863
when 278347 then 864
when 280493 then 865
when 282167 then 866
when 248957 then 867
when 279974 then 868
when 283366 then 869
when 283351 then 870
when 283347 then 871
when 285416 then 872
when 285380 then 873
when 285381 then 874
when 285492 then 875
when 285949 then 876
when 285832 then 877
when 287924 then 878
when 290590 then 879
when 290516 then 880
when 291971 then 881
when 293105 then 882
when 292993 then 883
when 293200 then 884
when 292856 then 885
when 292855 then 886
when 294910 then 887
when 294940 then 888
when 294653 then 889
when 298054 then 890
when 298326 then 891
when 299060 then 892
when 298994 then 893
when 299006 then 894
when 299308 then 895
when 299208 then 896
when 299256 then 897
when 299223 then 898
when 301334 then 899
when 299004 then 900
when 304694 then 901
when 305223 then 902
when 305624 then 903
when 306881 then 904
when 307892 then 905
when 307689 then 906
when 309650 then 907
when 309516 then 908
when 309344 then 909
when 309490 then 910
when 309299 then 911
when 309330 then 912
when 309296 then 913
when 309351 then 914
when 310282 then 915
when 305509 then 916
when 317889 then 917
when 323345 then 918
when 324878 then 919
when 324854 then 920
when 325290 then 921
when 324880 then 922
when 325296 then 923
when 328377 then 924
when 330970 then 925
when 284329 then 926
when 111301 then 927
when 73345 then 928
when 48963 then 929
when 48976 then 930
when 148697 then 931
when 148355 then 932
when 151775 then 933
when 170109 then 934
when 198238 then 935
when 201756 then 936
when 227953 then 937
when 253878 then 938
when 264002 then 939
when 271871 then 940
when 270215 then 941
when 274039 then 942
when 122230 then 943
when 19434 then 944
when 179487 then 945
when 191741 then 946
when 185603 then 947
when 207438 then 948
when 221114 then 949
when 260894 then 950
when 267071 then 951
when 126615 then 952
when 79544 then 953
when 170304 then 954
when 227469 then 955
when 252009 then 956
when 49868 then 957
when 255514 then 958
when 184301 then 959
when 192164 then 960
when 200047 then 961
when 264492 then 962
when 263988 then 963
when 266584 then 964
when 301158 then 965
when 305505 then 966
when 317857 then 967
when 277025 then 968
when 167897 then 969
when 115914 then 970
when 207110 then 971
when 208050 then 972
when 228177 then 973
when 256507 then 974
when 257302 then 975
when 256765 then 976
when 290225 then 977
when 292851 then 978
when 292852 then 979
when 292826 then 980
when 199026 then 981
when 211273 then 982
when 211940 then 983
when 285181 then 984
when 126590 then 985
when 109422 then 986
when 61124 then 987
when 61763 then 988
when 73352 then 989
when 49785 then 990
when 24707 then 991
when 114035 then 992
when 49786 then 993
when 209030 then 994
when 121863 then 995
when 271491 then 996
when 255300 then 997
when 252002 then 998
when 323507 then 999
when 205600 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 (143100,155356,207047,225677,61302,247536,261358,265014,268728,43620,268373,61303,43025,213857,250127,121210,254547,245026,126805,272506,143315,288346,298540,298396,212129,213858,254313,268723,277175,316545,211811,222406,245028,245027,268731,257285,39530,184310,184311,254186,268724,298711,306703,202302,39340,195463,249990,207700,170314,252444,73378,254223,184357,255591,228153,291725,322836,124789,202798,249935,125018,181487,202527,217965,282963,151558,23539,248264,28114,251682,312306,247671,144880,327004,270732,248751,317901,204442,19181,19180,137597,161825,204311,216552,216527,249937,254848,260841,141562,267981,128312,79096,99665,24534,169843,169846,213297,245695,253465,264889,248955,200029,247658,263909,256020,285501,307781,292040,105889,23529,139955,207854,199244,200342,205382,269967,44908,130331,205679,214097,280390,312307,211810,178667,13392,248752,249311,249312,251863,292979,203790,232220,247679,247680,247673,247783,267843,267845,267846,267844,269101,277916,277918,285507,285771,287937,287933,289385,290483,299262,299253,307696,318055,319852,331020,330978,69675,136927,141800,202739,202511,206256,210145,248328,249754,254592,255251,207424,89930,284851,304633,128311,256903,145134,195748,245694,264586,118076,178666,251738,281331,291113,321263,200339,153387,89241,181482,188870,225344,227233,285943,285839,291109,291754,305222,307890,309625,326292,330957,110675,257287,124924,206284,254256,283972,205195,175546,175547,111562,202131,205643,173493,117161,228155,228156,228154,152910,255661,263549,293404,296548,158388,89028,61175,61170,103831,101905,61300,159424,164832,168324,165522,202771,214611,249934,252398,254572,255252,276723,257257,97871,153388,197602,198802,205379,213726,121174,112595,163704,171941,251295,267818,268271,268413,269277,280182,280843,285187,285166,285146,285156,285155,285185,285514,285803,285886,287925,287899,290551,290584,291077,294930,299054,299205,301551,305568,305103,307695,309311,319851,326318,326566,330767,330955,41531,248659,256899,128639,110298,48944,181572,196049,202481,213298,213299,225270,263666,278149,272200,169480,169845,183951,13393,150211,209921,210318,171944,218079,218326,117818,247676,247826,267838,267841,267774,268265,268770,269080,269081,269451,277907,277909,279963,280845,280830,281657,281736,281416,285508,285522,285379,285347,285428,285346,285794,285840,287930,287910,289745,287013,292997,294876,294960,296575,248952,298986,298993,305507,310291,316663,312284,331001,164345,202628,293151,61169,61301,61487,179676,204919,202738,72688,204312,204587,201196,218016,219610,159149,247445,245350,248327,250052,126694,250055,254118,256793,253439,277298,290187,293164,293364,154689,205191,209840,220974,220976,220975,209475,251862,251860,253108,261340,266935,193439,295107,301285,206744,172710,203616,122517,122327,141242,142968,169265,202158,208654,245849,248959,248956,151676,252346,272916,283970,323328,248661,256900,148326,157927,156356,171961,169875,193227,202808,221035,215235,242412,61374,246760,250165,250445,67720,252148,256068,97196,267419,267886,268284,268239,277878,280181,285143,285423,285493,285510,285779,288151,288098,288033,289744,289770,290843,290536,290594,293059,294899,297394,301150,305107,309610,311775,318057,318061,319846,324842,322977,330990,68634,75668,24386,99095,264449,191512,28308,182367,221038,123907,111463,122834,139993,48945,151211,151774,161406,48981,65289,115101,181484,198514,202530,202528,202529,151650,205603,247363,126572,252448,256646,264887,264888,317862,317863,317864,255290,317892,317891,130488,28043,172953,196379,197599,204867,225339,228588,242415,245427,253303,266766,267839,267835,267821,267825,267828,267824,267814,267832,267819,267836,267831,267826,267829,267833,267816,267817,267820,267882,276782,278382,279984,281159,281730,285412,285415,285516,285506,285426,286308,285783,285819,285855,277379,290506,290502,291112,290565,290497,291256,293003,294871,294877,297379,297414,297373,299254,300610,300594,303655,307702,307777,312395,323587,325234,326308,326306,329044,329558,330244,330972,61173,61172,179496,72689,204061,204062,185604,250053,126762,254571,256417,193652,250485,266745,291607,298172,324009,24385,24387,47886,183979,254377,255615,261337,262405,286588,292850,292827,295109,159528,277843,285206,44726,13397,13396,210666,217333,118777,158335,222563,217253,223087,228599,228613,228603,242398,249115,72185,49007,168856,170677,252303,263956,267412,267791,267795,267797,267793,268778,272203,280844,281296,281746,281377,281365,285387,285937,285873,285843,287922,288115,290010,290660,291254,291255,292162,292996,292986,294950,294897,296471,299002,300588,305596,305070,305061,307691,307703,309652,309587,309591,310293,310284,317853,322500,322523,325223,319930,330977,331030,318079,77223,167824,267976,279112,157974,148141,170303,189066,188882,189306,192097,205601,214583,216708,266130,250944,323327,212275,122101,251118,264425,264440,285153,76867,287923,305594,324594,316672,61176,19430,19432,158312,209594,215040,221175,252622,262137,252759,290167,256902,175734,205193,253325,261338,263787,281537,289114,292849,292848,292853,292828,118863,103550,125792,163874,85564,108216,209923,220135,115803,225692,249308,167958,161359,143260,249167,266522,268240,268605,271473,277895,278389,279954,280859,285410,207386,285786,285813,285930,288135,297365,297392,298954,298971,298944,299329,301552,292647,305627,304994,307687,310289,312387,322585,324877,325293,324787,324757,322160,322162,211271,70403,79655,12689,24384,37245,101928,213316,273523,273524,49870,307721,171942,175979,205375,299027,305472,324593,321321,282186,326646,101487,267480,28018,116856,85413,111694,134647,137832,137833,138408,144915,144256,155027,151767,168032,169719,90415,178735,181485,189752,201014,202148,204122,203850,202526,215614,216915,216916,168583,216905,84397,225346,225284,245865,248221,216904,117476,252447,48986,117394,185645,252445,252306,254368,256783,256069,263547,264311,262439,263957,256070,263764,266475,267126,267306,267235,267830,267837,267784,268299,268457,271764,271472,274316,278347,280493,282167,248957,279974,283366,283351,283347,285416,285380,285381,285492,285949,285832,287924,290590,290516,291971,293105,292993,293200,292856,292855,294910,294940,294653,298054,298326,299060,298994,299006,299308,299208,299256,299223,301334,299004,304694,305223,305624,306881,307892,307689,309650,309516,309344,309490,309299,309330,309296,309351,310282,305509,317889,323345,324878,324854,325290,324880,325296,328377,330970,284329,111301,73345,48963,48976,148697,148355,151775,170109,198238,201756,227953,253878,264002,271871,270215,274039,122230,19434,179487,191741,185603,207438,221114,260894,267071,126615,79544,170304,227469,252009,49868,255514,184301,192164,200047,264492,263988,266584,301158,305505,317857,277025,167897,115914,207110,208050,228177,256507,257302,256765,290225,292851,292852,292826,199026,211273,211940,285181,126590,109422,61124,61763,73352,49785,24707,114035,49786,209030,121863,271491,255300,252002,323507,205600)
and ltrim(rtrim(lower(a.dept))) = 'firearm accessories'
and ltrim(rtrim(lower(a.brand))) = 'ets group'
group by a.style_id
order by instock desc, ranking asc
|