SHARE
TWEET

Untitled

a guest Feb 28th, 2020 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT ba.NAME_BRANDS
  2. , t.brand_id
  3. , count(t.art_num) kol
  4. , SUM(if(c_all>0, 1, 0)) "Товары с кросами"  
  5. , SUM(if(c_all>0, 0, 1)) "Товары без кросов"  
  6. from
  7. (select
  8. pa.art_num,
  9. pa.brand_id,
  10. count(ca.mca_id) c_all
  11.  
  12. FROM prices_all pa
  13. LEFT JOIN brand_all_prices bap ON bap.parent_id = pa.brand_id
  14. LEFT JOIN cross_all         ca ON pa.art_num = ca.mca_art_num_b and bap.id = ca.mca_bap_b_id
  15.  
  16.  
  17. WHERE pa.brand_id IN (
  18. 27,
  19. 80,
  20. 149,
  21. 171,
  22. 192,
  23. 278,
  24. 331,
  25. 340,
  26. 408,
  27. 542,
  28. 580,
  29. 632,
  30. 653,
  31. 654,
  32. 758,
  33. 915,
  34. 954,
  35. 975,
  36. 1104,
  37. 1130,
  38. 1174,
  39. 1258,
  40. 1286,
  41. 1447,
  42. 1587,
  43. 1602,
  44. 1645,
  45. 1654,
  46. 1655,
  47. 1810,
  48. 1838,
  49. 1852,
  50. 1859,
  51. 1861,
  52. 1893,
  53. 1903,
  54. 1905,
  55. 1963,
  56. 1995,
  57. 2029,
  58. 2083,
  59. 2098,
  60. 2201,
  61. 2215,
  62. 2237,
  63. 2246,
  64. 2277,
  65. 2394,
  66. 2396,
  67. 2410,
  68. 2429,
  69. 2460,
  70. 2567,
  71. 2568,
  72. 2584,
  73. 2604,
  74. 2609,
  75. 2612,
  76. 2627,
  77. 2633,
  78. 2653,
  79. 2704,
  80. 2726,
  81. 2732,
  82. 2742,
  83. 2796,
  84. 2857,
  85. 2877,
  86. 2929,
  87. 3072,
  88. 3190,
  89. 10241,
  90. 10707,
  91. 11161,
  92. 11468,
  93. 11469,
  94. 11481,
  95. 11482,
  96. 11666,
  97. 12030,
  98. 12031,
  99. 12032,
  100. 12033,
  101. 12034,
  102. 12035,
  103. 12036
  104. )
  105. AND pa.avalaible_gen IN (0, 1)
  106. AND (pa.pa_ga_id IS NULL OR pa.pa_ga_id IN (
  107. 938,
  108. 41313,
  109. 41314,
  110. 41315,
  111. 41316,
  112. 41317,
  113. 41318,
  114. 41319,
  115. 41352,
  116. 41382,
  117. 41383,
  118. 41399,
  119. 41411,
  120. 41426,
  121. 41435,
  122. 41439,
  123. 298,
  124. 62,
  125. 2504,
  126. 54293,
  127. 54294,
  128. 54295,
  129. 54296,
  130. 54297,
  131. 54298,
  132. 54299,
  133. 54300,
  134. 54397,
  135. 54400,
  136. 54406,
  137. 54416,
  138. 54425,
  139. 54427,
  140. 54428,
  141. 54430,
  142. 54434,
  143. 54436,
  144. 54460,
  145. 54461,
  146. 54462,
  147. 54476,
  148. 54484,
  149. 54491,
  150. 54492,
  151. 54493,
  152. 54507,
  153. 54515,
  154. 54522,
  155. 54523,
  156. 54530,
  157. 54537,
  158. 54540,
  159. 1488,
  160. 1914,
  161. 1915,
  162. 2809,
  163. 2810,
  164. 3392,
  165. 1377,
  166. 14,
  167. 1373,
  168. 1374,
  169. 1375,
  170. 712,
  171. 2872,
  172. 703,
  173. 2870,
  174. 289,
  175. 2484,
  176. 1560,
  177. 50130,
  178. 50132,
  179. 50133,
  180. 50134,
  181. 50135,
  182. 50136,
  183. 50137,
  184. 50138,
  185. 50139,
  186. 50140,
  187. 53977,
  188. 54041,
  189. 54073,
  190. 54089,
  191. 54104,
  192. 54160,
  193. 54191,
  194. 54206,
  195. 54213,
  196. 259,
  197. 3175,
  198. 3328,
  199. 30379,
  200. 30381,
  201. 30382,
  202. 30383,
  203. 30384,
  204. 30385,
  205. 30386,
  206. 30387,
  207. 30388,
  208. 30548,
  209. 30578,
  210. 30607,
  211. 30618,
  212. 30622,
  213. 30625,
  214. 794,
  215. 2903,
  216. 2801,
  217. 41699,
  218. 1191,
  219. 901,
  220. 4370,
  221. 449,
  222. 41247,
  223. 41248,
  224. 41249,
  225. 41250,
  226. 41251,
  227. 41252,
  228. 41283,
  229. 41284,
  230. 41292,
  231. 41299,
  232. 23,
  233. 2476,
  234. 3257,
  235. 3393,
  236. 531,
  237. 3331,
  238. 3232,
  239. 391,
  240. 2492,
  241. 291,
  242. 89,
  243. 3336,
  244. 88,
  245. 3335
  246. ))
  247. GROUP BY pa.id ) as t
  248.  
  249. LEFT JOIN brand_all         ba ON ba.id = t.brand_id
  250.  
  251. GROUP BY t.brand_id
  252. ORDER BY kol desc
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top