Sql |
SELECT distinct a.style_id,
case a.style_id
when 173054 then 1
when 282677 then 2
when 263426 then 3
when 248123 then 4
when 271787 then 5
when 205733 then 6
when 205732 then 7
when 162464 then 8
when 266174 then 9
when 321293 then 10
when 193357 then 11
when 299103 then 12
when 278269 then 13
when 203280 then 14
when 280880 then 15
when 306710 then 16
when 264982 then 17
when 304000 then 18
when 261794 then 19
when 100272 then 20
when 141281 then 21
when 260609 then 22
when 268592 then 23
when 213912 then 24
when 252081 then 25
when 260574 then 26
when 179690 then 27
when 281011 then 28
when 204886 then 29
when 266351 then 30
when 192150 then 31
when 252425 then 32
when 293284 then 33
when 262999 then 34
when 227148 then 35
when 199762 then 36
when 199112 then 37
when 283478 then 38
when 215653 then 39
when 281056 then 40
when 217712 then 41
when 251116 then 42
when 271642 then 43
when 268752 then 44
when 283250 then 45
when 268751 then 46
when 306704 then 47
when 278268 then 48
when 268753 then 49
when 46430 then 50
when 140107 then 51
when 199761 then 52
when 294746 then 53
when 93710 then 54
when 46435 then 55
when 264864 then 56
when 267754 then 57
when 46424 then 58
when 268754 then 59
when 157687 then 60
when 289664 then 61
when 122948 then 62
when 93495 then 63
when 161085 then 64
when 289443 then 65
when 294674 then 66
when 261120 then 67
when 262538 then 68
when 264862 then 69
when 287533 then 70
when 293270 then 71
when 220442 then 72
when 175885 then 73
when 322395 then 74
when 293274 then 75
when 322451 then 76
when 248417 then 77
when 298206 then 78
when 283212 then 79
when 78507 then 80
when 329199 then 81
when 260761 then 82
when 329200 then 83
when 286697 then 84
when 61945 then 85
when 61946 then 86
when 130232 then 87
when 173934 then 88
when 12666 then 89
when 12664 then 90
when 12665 then 91
when 99973 then 92
when 252744 then 93
when 130210 then 94
when 12732 then 95
when 248334 then 96
when 268382 then 97
when 271887 then 98
when 221146 then 99
when 12724 then 100
when 181947 then 101
when 12725 then 102
when 281336 then 103
when 216270 then 104
when 132147 then 105
when 266240 then 106
when 293450 then 107
when 24663 then 108
when 101791 then 109
when 136885 then 110
when 42264 then 111
when 113522 then 112
when 264431 then 113
when 252365 then 114
when 276350 then 115
when 91822 then 116
when 75029 then 117
when 249734 then 118
when 250024 then 119
when 252746 then 120
when 319458 then 121
when 264693 then 122
when 324165 then 123
when 42263 then 124
when 215085 then 125
when 113118 then 126
when 266601 then 127
when 121157 then 128
when 13370 then 129
when 219959 then 130
when 252747 then 131
when 252740 then 132
when 222418 then 133
when 236945 then 134
when 263234 then 135
when 74998 then 136
when 87656 then 137
when 205777 then 138
when 205776 then 139
when 288184 then 140
when 271889 then 141
when 257312 then 142
when 91793 then 143
when 297892 then 144
when 19096 then 145
when 123666 then 146
when 277407 then 147
when 217477 then 148
when 222425 then 149
when 222422 then 150
when 272048 then 151
when 61833 then 152
when 77693 then 153
when 114191 then 154
when 132071 then 155
when 36619 then 156
when 291252 then 157
when 84585 then 158
when 222424 then 159
when 222421 then 160
when 104903 then 161
when 201633 then 162
when 19098 then 163
when 252571 then 164
when 326829 then 165
when 44653 then 166
when 46368 then 167
when 46423 then 168
when 153094 then 169
when 105625 then 170
when 247624 then 171
when 225271 then 172
when 277410 then 173
when 268469 then 174
when 181144 then 175
when 212824 then 176
when 92315 then 177
when 110381 then 178
when 134640 then 179
when 118883 then 180
when 297549 then 181
when 130716 then 182
when 249560 then 183
when 201640 then 184
when 216706 then 185
when 245236 then 186
when 141253 then 187
when 260588 then 188
when 130717 then 189
when 326807 then 190
when 19418 then 191
when 264213 then 192
when 252356 then 193
when 126080 then 194
when 144193 then 195
when 124130 then 196
when 212996 then 197
when 222706 then 198
when 227159 then 199
when 138581 then 200
when 155427 then 201
when 134642 then 202
when 134643 then 203
when 254485 then 204
when 122628 then 205
when 252430 then 206
when 56011 then 207
when 191577 then 208
when 124132 then 209
when 213149 then 210
when 247494 then 211
when 247493 then 212
when 266865 then 213
when 277409 then 214
when 326334 then 215
when 210301 then 216
when 297736 then 217
when 263402 then 218
when 106297 then 219
when 134641 then 220
when 134645 then 221
when 134644 then 222
when 23413 then 223
when 36624 then 224
when 247495 then 225
when 247500 then 226
when 247498 then 227
when 247499 then 228
when 207672 then 229
when 288925 then 230
when 134646 then 231
when 207156 then 232
when 247501 then 233
when 13051 then 234
when 252480 then 235
when 118963 then 236
when 175710 then 237
when 118424 then 238
when 300593 then 239
when 119052 then 240
when 216281 then 241
when 176386 then 242
when 318177 then 243
when 23408 then 244
when 219848 then 245
when 260564 then 246
when 251722 then 247
when 257088 then 248
when 217478 then 249
when 271477 then 250
when 207233 then 251
when 324212 then 252
when 75051 then 253
when 42755 then 254
when 285851 then 255
when 252433 then 256
when 266384 then 257
when 268630 then 258
when 305251 then 259
when 216713 then 260
when 271780 then 261
when 79177 then 262
when 268583 then 263
when 268585 then 264
when 267632 then 265
when 118895 then 266
when 281255 then 267
when 227145 then 268
when 23419 then 269
when 277039 then 270
when 216914 then 271
when 216910 then 272
when 216911 then 273
when 216913 then 274
when 42662 then 275
when 326295 then 276
when 23379 then 277
when 164056 then 278
when 107516 then 279
when 262302 then 280
when 214142 then 281
when 114201 then 282
when 213783 then 283
when 23410 then 284
when 301547 then 285
when 330986 then 286
when 266631 then 287
when 154579 then 288
when 79793 then 289
when 31874 then 290
when 42492 then 291
when 208001 then 292
when 44656 then 293
when 36627 then 294
when 279643 then 295
when 213801 then 296
when 316495 then 297
when 297550 then 298
when 263280 then 299
when 249009 then 300
when 214629 then 301
when 225670 then 302
when 266288 then 303
when 99180 then 304
when 133073 then 305
when 156358 then 306
when 255286 then 307
when 289269 then 308
when 118893 then 309
when 117136 then 310
when 154937 then 311
when 184153 then 312
when 324213 then 313
when 23391 then 314
when 251723 then 315
when 251879 then 316
when 309735 then 317
when 227189 then 318
when 323723 then 319
when 248407 then 320
when 302667 then 321
when 322429 then 322
when 168616 then 323
when 254257 then 324
when 290123 then 325
when 297726 then 326
when 215565 then 327
when 282953 then 328
when 170100 then 329
when 211047 then 330
when 215440 then 331
when 250977 then 332
when 268619 then 333
when 276846 then 334
when 277408 then 335
when 293261 then 336
when 84398 then 337
when 194359 then 338
when 227143 then 339
when 215564 then 340
when 252874 then 341
when 133914 then 342
when 302543 then 343
when 267028 then 344
when 73443 then 345
when 303332 then 346
when 303333 then 347
when 117813 then 348
when 264834 then 349
when 318089 then 350
when 297561 then 351
when 303610 then 352
when 262785 then 353
when 294638 then 354
when 125511 then 355
when 23381 then 356
when 123774 then 357
when 125824 then 358
when 278789 then 359
when 302122 then 360
when 264142 then 361
when 123482 then 362
when 179406 then 363
when 252434 then 364
when 262786 then 365
when 268637 then 366
when 257284 then 367
when 268522 then 368
when 260448 then 369
when 123484 then 370
when 252461 then 371
when 141248 then 372
when 282654 then 373
when 277882 then 374
when 179405 then 375
when 106857 then 376
when 117615 then 377
when 172030 then 378
when 110413 then 379
when 264141 then 380
when 76387 then 381
when 205206 then 382
when 217082 then 383
when 252360 then 384
when 170101 then 385
when 179459 then 386
when 199545 then 387
when 217374 then 388
when 291691 then 389
when 316719 then 390
when 323993 then 391
when 129242 then 392
when 324739 then 393
when 287958 then 394
when 269481 then 395
when 269483 then 396
when 72175 then 397
when 280982 then 398
when 114053 then 399
when 249294 then 400
when 129326 then 401
when 145416 then 402
when 205208 then 403
when 201266 then 404
when 194358 then 405
when 250428 then 406
when 310788 then 407
when 296836 then 408
when 102137 then 409
when 192510 then 410
when 201265 then 411
when 205209 then 412
when 205205 then 413
when 119450 then 414
when 242382 then 415
when 324475 then 416
when 36595 then 417
when 105900 then 418
when 215153 then 419
when 202304 then 420
when 99933 then 421
when 323998 then 422
when 123997 then 423
when 159194 then 424
when 319845 then 425
when 291324 then 426
when 193163 then 427
when 61944 then 428
when 252478 then 429
when 251721 then 430
when 268616 then 431
when 291366 then 432
when 96036 then 433
when 203599 then 434
when 285343 then 435
when 291723 then 436
when 253370 then 437
when 247362 then 438
when 154577 then 439
when 301137 then 440
when 152532 then 441
when 279998 then 442
when 291471 then 443
when 309732 then 444
when 288010 then 445
when 298741 then 446
when 268548 then 447
when 252569 then 448
when 277405 then 449
when 257066 then 450
when 36614 then 451
when 173699 then 452
when 247360 then 453
when 193158 then 454
when 201264 then 455
when 36610 then 456
when 36613 then 457
when 220615 then 458
when 262613 then 459
when 254112 then 460
when 264148 then 461
when 264145 then 462
when 293042 then 463
when 298066 then 464
when 310121 then 465
when 298740 then 466
when 310271 then 467
when 193157 then 468
when 193147 then 469
when 193140 then 470
when 288985 then 471
when 305039 then 472
when 193148 then 473
when 193153 then 474
when 193152 then 475
when 193154 then 476
when 271891 then 477
when 36622 then 478
when 247438 then 479
when 318808 then 480
when 193167 then 481
when 322572 then 482
when 304002 then 483
when 302121 then 484
when 193145 then 485
when 193151 then 486
when 193150 then 487
when 193146 then 488
when 249289 then 489
when 193149 then 490
when 245413 then 491
when 149701 then 492
when 193139 then 493
when 46420 then 494
when 118099 then 495
when 296445 then 496
when 322350 then 497
when 276944 then 498
when 36623 then 499
when 99404 then 500
when 36626 then 501
when 251706 then 502
when 253589 then 503
when 292373 then 504
when 310783 then 505
when 219936 then 506
when 302533 then 507
when 44657 then 508
when 269400 then 509
when 97510 then 510
when 184237 then 511
when 147786 then 512
when 266632 then 513
when 306716 then 514
when 257098 then 515
when 262610 then 516
when 287546 then 517
when 267296 then 518
when 261493 then 519
when 118362 then 520
when 48800 then 521
when 262560 then 522
when 266940 then 523
when 305217 then 524
when 220443 then 525
when 138439 then 526
when 144905 then 527
when 266942 then 528
when 197390 then 529
when 260518 then 530
when 287543 then 531
when 271577 then 532
when 147502 then 533
when 134638 then 534
when 328898 then 535
when 250461 then 536
when 138441 then 537
when 138443 then 538
when 202351 then 539
when 217040 then 540
when 264161 then 541
when 162136 then 542
when 162135 then 543
when 147503 then 544
when 38932 then 545
when 134604 then 546
when 217042 then 547
when 326283 then 548
when 155342 then 549
when 144172 then 550
when 266280 then 551
when 322641 then 552
when 322643 then 553
when 322639 then 554
when 302529 then 555
when 113147 then 556
when 144548 then 557
when 119180 then 558
when 191304 then 559
when 266665 then 560
when 109880 then 561
when 114636 then 562
when 38930 then 563
when 44748 then 564
when 252357 then 565
when 323724 then 566
when 261486 then 567
when 133831 then 568
when 116155 then 569
when 136939 then 570
when 38931 then 571
when 214886 then 572
when 205731 then 573
when 109823 then 574
when 114014 then 575
when 171945 then 576
when 131365 then 577
when 193533 then 578
when 253983 then 579
when 266941 then 580
when 277317 then 581
when 293201 then 582
when 213510 then 583
when 296877 then 584
when 222595 then 585
when 116008 then 586
when 124007 then 587
when 160859 then 588
when 157813 then 589
when 217043 then 590
when 192347 then 591
when 277316 then 592
when 293181 then 593
when 262257 then 594
when 28050 then 595
when 269494 then 596
when 302528 then 597
when 199544 then 598
when 123902 then 599
when 138367 then 600
when 206588 then 601
when 220134 then 602
when 277315 then 603
when 123999 then 604
when 141491 then 605
when 148103 then 606
when 302532 then 607
when 322474 then 608
when 138567 then 609
when 257263 then 610
when 326187 then 611
when 131075 then 612
when 172739 then 613
when 156361 then 614
when 138563 then 615
when 155320 then 616
when 132724 then 617
when 193108 then 618
when 204766 then 619
when 261539 then 620
when 277318 then 621
when 270969 then 622
when 300524 then 623
when 164579 then 624
when 288987 then 625
when 206584 then 626
when 125457 then 627
when 245235 then 628
when 319684 then 629
when 46404 then 630
when 290893 then 631
when 326188 then 632
when 203792 then 633
when 262787 then 634
when 132455 then 635
when 137855 then 636
when 319682 then 637
when 319683 then 638
when 319685 then 639
when 319686 then 640
when 319688 then 641
when 193109 then 642
when 260753 then 643
when 262614 then 644
when 262615 then 645
when 278792 then 646
when 297979 then 647
when 252550 then 648
when 103054 then 649
when 316338 then 650
when 213252 then 651
when 124319 then 652
when 178877 then 653
when 267176 then 654
when 213270 then 655
when 176314 then 656
when 193107 then 657
when 271562 then 658
when 262617 then 659
when 262616 then 660
when 147427 then 661
when 152681 then 662
when 220231 then 663
when 10303 then 664
when 256903 then 665
when 319687 then 666
when 293202 then 667
when 211580 then 668
when 262612 then 669
when 10316 then 670
when 4740 then 671
when 194075 then 672
when 4738 then 673
when 218523 then 674
when 264163 then 675
when 264164 then 676
when 9149 then 677
when 10308 then 678
when 195865 then 679
when 208116 then 680
when 215150 then 681
when 215149 then 682
when 219891 then 683
when 255809 then 684
when 299162 then 685
when 190102 then 686
when 326153 then 687
when 151488 then 688
when 155732 then 689
when 267171 then 690
when 310791 then 691
when 155322 then 692
when 15167 then 693
when 262788 then 694
when 94151 then 695
when 154531 then 696
when 189949 then 697
when 253369 then 698
when 262604 then 699
when 276968 then 700
when 319689 then 701
when 319690 then 702
when 319691 then 703
when 319693 then 704
when 319695 then 705
when 168261 then 706
when 179120 then 707
when 219976 then 708
when 289959 then 709
when 266039 then 710
when 328270 then 711
when 322400 then 712
when 264103 then 713
when 10315 then 714
when 170408 then 715
when 178596 then 716
when 203476 then 717
when 205233 then 718
when 205465 then 719
when 208117 then 720
when 247233 then 721
when 255787 then 722
when 248908 then 723
when 319694 then 724
when 323953 then 725
when 104547 then 726
when 276158 then 727
when 282651 then 728
when 213265 then 729
when 296740 then 730
when 49055 then 731
when 4741 then 732
when 286665 then 733
when 171946 then 734
when 10317 then 735
when 215152 then 736
when 289550 then 737
when 44691 then 738
when 262136 then 739
when 150206 then 740
when 249012 then 741
when 95836 then 742
when 266131 then 743
when 141442 then 744
when 141443 then 745
when 189189 then 746
when 251146 then 747
when 262140 then 748
when 262609 then 749
when 262603 then 750
when 279285 then 751
when 319699 then 752
when 247124 then 753
when 249008 then 754
when 266910 then 755
when 44680 then 756
when 97311 then 757
when 63789 then 758
when 49050 then 759
when 134639 then 760
when 276159 then 761
when 69632 then 762
when 176527 then 763
when 263431 then 764
when 21875 then 765
when 122660 then 766
when 178616 then 767
when 193307 then 768
when 222786 then 769
when 247235 then 770
when 260979 then 771
when 262606 then 772
when 276969 then 773
when 276967 then 774
when 285038 then 775
when 319697 then 776
when 319932 then 777
when 104498 then 778
when 292731 then 779
when 147964 then 780
when 122521 then 781
when 97312 then 782
when 44686 then 783
when 252510 then 784
when 322418 then 785
when 206286 then 786
when 143712 then 787
when 168709 then 788
when 266215 then 789
when 266214 then 790
when 252509 then 791
when 161993 then 792
when 84849 then 793
when 155708 then 794
when 147500 then 795
when 138429 then 796
when 175892 then 797
when 215151 then 798
when 255441 then 799
when 262605 then 800
when 262602 then 801
when 267463 then 802
when 262611 then 803
when 262938 then 804
when 270246 then 805
when 280517 then 806
when 287539 then 807
when 319698 then 808
when 319701 then 809
when 319933 then 810
when 122979 then 811
when 100239 then 812
when 94091 then 813
when 123314 then 814
when 286850 then 815
when 123891 then 816
when 252479 then 817
when 252481 then 818
when 279058 then 819
when 252432 then 820
when 267630 then 821
when 210934 then 822
when 100658 then 823
when 173159 then 824
when 222359 then 825
when 249011 then 826
when 320234 then 827
when 254239 then 828
when 138675 then 829
when 143739 then 830
when 114630 then 831
when 44677 then 832
when 69320 then 833
when 168215 then 834
when 110015 then 835
when 245607 then 836
when 213251 then 837
when 125806 then 838
when 191387 then 839
when 289599 then 840
when 4580 then 841
when 227162 then 842
when 252219 then 843
when 262608 then 844
when 301238 then 845
when 301253 then 846
when 306876 then 847
when 319700 then 848
when 319817 then 849
when 319818 then 850
when 154978 then 851
when 245159 then 852
when 256645 then 853
when 126124 then 854
when 125690 then 855
when 81239 then 856
when 130260 then 857
when 173157 then 858
when 268620 then 859
when 221156 then 860
when 134110 then 861
when 138732 then 862
when 87211 then 863
when 200103 then 864
when 201783 then 865
when 246718 then 866
when 28121 then 867
when 282954 then 868
when 268648 then 869
when 110809 then 870
when 159662 then 871
when 193946 then 872
when 300520 then 873
when 278730 then 874
when 99394 then 875
when 129037 then 876
when 309700 then 877
when 298636 then 878
when 253472 then 879
when 130770 then 880
when 136937 then 881
when 151649 then 882
when 152098 then 883
when 159148 then 884
when 202785 then 885
when 170855 then 886
when 197834 then 887
when 217883 then 888
when 253144 then 889
when 262364 then 890
when 264422 then 891
when 192280 then 892
when 250181 then 893
when 255163 then 894
when 323954 then 895
when 319814 then 896
when 263531 then 897
when 268624 then 898
when 175327 then 899
when 152571 then 900
when 44697 then 901
when 154855 then 902
when 252355 then 903
when 128850 then 904
when 121162 then 905
when 111206 then 906
when 107577 then 907
when 300519 then 908
when 326842 then 909
when 155184 then 910
when 158990 then 911
when 220601 then 912
when 173263 then 913
when 195695 then 914
when 115822 then 915
when 172664 then 916
when 202078 then 917
when 212144 then 918
when 254183 then 919
when 268594 then 920
when 261916 then 921
when 128766 then 922
when 165478 then 923
when 28123 then 924
when 323906 then 925
when 217766 then 926
when 169560 then 927
when 207657 then 928
when 248432 then 929
when 252075 then 930
when 251139 then 931
when 251140 then 932
when 267337 then 933
when 272963 then 934
when 191732 then 935
when 24212 then 936
when 130015 then 937
when 134114 then 938
when 44696 then 939
when 268571 then 940
when 269821 then 941
when 287554 then 942
when 319798 then 943
when 270442 then 944
when 168717 then 945
when 222946 then 946
when 100321 then 947
when 254753 then 948
when 300550 then 949
when 303682 then 950
when 136027 then 951
when 44688 then 952
when 196026 then 953
when 268551 then 954
when 268609 then 955
when 155414 then 956
when 175607 then 957
when 125598 then 958
when 266281 then 959
when 262299 then 960
when 49057 then 961
when 203983 then 962
when 249448 then 963
when 263196 then 964
when 283950 then 965
when 288674 then 966
when 195395 then 967
when 220136 then 968
when 249242 then 969
when 256287 then 970
when 256286 then 971
when 262373 then 972
when 268644 then 973
when 159332 then 974
when 195792 then 975
when 252508 then 976
when 201749 then 977
when 208087 then 978
when 217767 then 979
when 268541 then 980
when 283436 then 981
when 278790 then 982
when 298566 then 983
when 324844 then 984
when 175977 then 985
when 217884 then 986
when 268638 then 987
when 228579 then 988
when 246134 then 989
when 287541 then 990
when 306875 then 991
when 260576 then 992
when 28045 then 993
when 277894 then 994
when 281091 then 995
when 301819 then 996
when 130209 then 997
when 113169 then 998
when 202977 then 999
when 179540 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 (173054,282677,263426,248123,271787,205733,205732,162464,266174,321293,193357,299103,278269,203280,280880,306710,264982,304000,261794,100272,141281,260609,268592,213912,252081,260574,179690,281011,204886,266351,192150,252425,293284,262999,227148,199762,199112,283478,215653,281056,217712,251116,271642,268752,283250,268751,306704,278268,268753,46430,140107,199761,294746,93710,46435,264864,267754,46424,268754,157687,289664,122948,93495,161085,289443,294674,261120,262538,264862,287533,293270,220442,175885,322395,293274,322451,248417,298206,283212,78507,329199,260761,329200,286697,61945,61946,130232,173934,12666,12664,12665,99973,252744,130210,12732,248334,268382,271887,221146,12724,181947,12725,281336,216270,132147,266240,293450,24663,101791,136885,42264,113522,264431,252365,276350,91822,75029,249734,250024,252746,319458,264693,324165,42263,215085,113118,266601,121157,13370,219959,252747,252740,222418,236945,263234,74998,87656,205777,205776,288184,271889,257312,91793,297892,19096,123666,277407,217477,222425,222422,272048,61833,77693,114191,132071,36619,291252,84585,222424,222421,104903,201633,19098,252571,326829,44653,46368,46423,153094,105625,247624,225271,277410,268469,181144,212824,92315,110381,134640,118883,297549,130716,249560,201640,216706,245236,141253,260588,130717,326807,19418,264213,252356,126080,144193,124130,212996,222706,227159,138581,155427,134642,134643,254485,122628,252430,56011,191577,124132,213149,247494,247493,266865,277409,326334,210301,297736,263402,106297,134641,134645,134644,23413,36624,247495,247500,247498,247499,207672,288925,134646,207156,247501,13051,252480,118963,175710,118424,300593,119052,216281,176386,318177,23408,219848,260564,251722,257088,217478,271477,207233,324212,75051,42755,285851,252433,266384,268630,305251,216713,271780,79177,268583,268585,267632,118895,281255,227145,23419,277039,216914,216910,216911,216913,42662,326295,23379,164056,107516,262302,214142,114201,213783,23410,301547,330986,266631,154579,79793,31874,42492,208001,44656,36627,279643,213801,316495,297550,263280,249009,214629,225670,266288,99180,133073,156358,255286,289269,118893,117136,154937,184153,324213,23391,251723,251879,309735,227189,323723,248407,302667,322429,168616,254257,290123,297726,215565,282953,170100,211047,215440,250977,268619,276846,277408,293261,84398,194359,227143,215564,252874,133914,302543,267028,73443,303332,303333,117813,264834,318089,297561,303610,262785,294638,125511,23381,123774,125824,278789,302122,264142,123482,179406,252434,262786,268637,257284,268522,260448,123484,252461,141248,282654,277882,179405,106857,117615,172030,110413,264141,76387,205206,217082,252360,170101,179459,199545,217374,291691,316719,323993,129242,324739,287958,269481,269483,72175,280982,114053,249294,129326,145416,205208,201266,194358,250428,310788,296836,102137,192510,201265,205209,205205,119450,242382,324475,36595,105900,215153,202304,99933,323998,123997,159194,319845,291324,193163,61944,252478,251721,268616,291366,96036,203599,285343,291723,253370,247362,154577,301137,152532,279998,291471,309732,288010,298741,268548,252569,277405,257066,36614,173699,247360,193158,201264,36610,36613,220615,262613,254112,264148,264145,293042,298066,310121,298740,310271,193157,193147,193140,288985,305039,193148,193153,193152,193154,271891,36622,247438,318808,193167,322572,304002,302121,193145,193151,193150,193146,249289,193149,245413,149701,193139,46420,118099,296445,322350,276944,36623,99404,36626,251706,253589,292373,310783,219936,302533,44657,269400,97510,184237,147786,266632,306716,257098,262610,287546,267296,261493,118362,48800,262560,266940,305217,220443,138439,144905,266942,197390,260518,287543,271577,147502,134638,328898,250461,138441,138443,202351,217040,264161,162136,162135,147503,38932,134604,217042,326283,155342,144172,266280,322641,322643,322639,302529,113147,144548,119180,191304,266665,109880,114636,38930,44748,252357,323724,261486,133831,116155,136939,38931,214886,205731,109823,114014,171945,131365,193533,253983,266941,277317,293201,213510,296877,222595,116008,124007,160859,157813,217043,192347,277316,293181,262257,28050,269494,302528,199544,123902,138367,206588,220134,277315,123999,141491,148103,302532,322474,138567,257263,326187,131075,172739,156361,138563,155320,132724,193108,204766,261539,277318,270969,300524,164579,288987,206584,125457,245235,319684,46404,290893,326188,203792,262787,132455,137855,319682,319683,319685,319686,319688,193109,260753,262614,262615,278792,297979,252550,103054,316338,213252,124319,178877,267176,213270,176314,193107,271562,262617,262616,147427,152681,220231,10303,256903,319687,293202,211580,262612,10316,4740,194075,4738,218523,264163,264164,9149,10308,195865,208116,215150,215149,219891,255809,299162,190102,326153,151488,155732,267171,310791,155322,15167,262788,94151,154531,189949,253369,262604,276968,319689,319690,319691,319693,319695,168261,179120,219976,289959,266039,328270,322400,264103,10315,170408,178596,203476,205233,205465,208117,247233,255787,248908,319694,323953,104547,276158,282651,213265,296740,49055,4741,286665,171946,10317,215152,289550,44691,262136,150206,249012,95836,266131,141442,141443,189189,251146,262140,262609,262603,279285,319699,247124,249008,266910,44680,97311,63789,49050,134639,276159,69632,176527,263431,21875,122660,178616,193307,222786,247235,260979,262606,276969,276967,285038,319697,319932,104498,292731,147964,122521,97312,44686,252510,322418,206286,143712,168709,266215,266214,252509,161993,84849,155708,147500,138429,175892,215151,255441,262605,262602,267463,262611,262938,270246,280517,287539,319698,319701,319933,122979,100239,94091,123314,286850,123891,252479,252481,279058,252432,267630,210934,100658,173159,222359,249011,320234,254239,138675,143739,114630,44677,69320,168215,110015,245607,213251,125806,191387,289599,4580,227162,252219,262608,301238,301253,306876,319700,319817,319818,154978,245159,256645,126124,125690,81239,130260,173157,268620,221156,134110,138732,87211,200103,201783,246718,28121,282954,268648,110809,159662,193946,300520,278730,99394,129037,309700,298636,253472,130770,136937,151649,152098,159148,202785,170855,197834,217883,253144,262364,264422,192280,250181,255163,323954,319814,263531,268624,175327,152571,44697,154855,252355,128850,121162,111206,107577,300519,326842,155184,158990,220601,173263,195695,115822,172664,202078,212144,254183,268594,261916,128766,165478,28123,323906,217766,169560,207657,248432,252075,251139,251140,267337,272963,191732,24212,130015,134114,44696,268571,269821,287554,319798,270442,168717,222946,100321,254753,300550,303682,136027,44688,196026,268551,268609,155414,175607,125598,266281,262299,49057,203983,249448,263196,283950,288674,195395,220136,249242,256287,256286,262373,268644,159332,195792,252508,201749,208087,217767,268541,283436,278790,298566,324844,175977,217884,268638,228579,246134,287541,306875,260576,28045,277894,281091,301819,130209,113169,202977,179540)
and ltrim(rtrim(lower(a.dept))) = 'firearms'
and a.of3='270 WINCHESTER'
group by a.style_id
order by instock desc, ranking asc
|