Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: SQL
Posted by: Влад Якуб
Added: Jun 24, 2021 7:15 AM
Modified: Jun 24, 2021 7:15 AM
Views: 37
Tags: no tags
  1. SELECT  
  2. `u`.`id`,  
  3. (SELECT COUNT(*) FROM `profi_research`.`survey` AS `s` WHERE `s`.`user` = `u`.`id`) AS 'total' ,
  4. (SELECT COUNT(*) FROM `profi_research`.`survey` AS `s` WHERE `s`.`user` = `u`.`id` AND `s`.`state` = 3) AS 'success' ,
  5. (SELECT COUNT(*) FROM `profi_research`.`survey` AS `s` WHERE `s`.`user` = `u`.`id` AND `s`.`state` = 2) AS 'process' ,
  6. (SELECT COUNT(*) FROM `profi_research`.`survey` AS `s` WHERE `s`.`user` = `u`.`id` AND `s`.`state` = 1) AS 'fail' ,
  7. `u`.`active`,  `u`.`karma`,  `u`.`email`,  `u`.`lastname`,  `u`.`name`,  `u`.`sex`,  `u`.`birthday`,  `u`.`city`,  `u`.`balance`,  `u`.`subscribe`,
  8.   `u`.`datecreate`,  `u`.`phone`,  `u`.`family`,  LEFT(`u`.`children`, 256),  `u`.`education`,  `u`.`earn`,  `u`.`earnself`,  LEFT(`u`.`jobarea`, 256),
  9.  `u`.`jobposition`,  LEFT(`u`.`cars`, 256),  `u`.`referrer`
  10.  
  11. FROM `profi_research`.`user`  AS `u`
  12. WHERE
  13. `u`.`id` IN (41166,60592,62559,65060,76484,83398,130765,131426,404066,426686,435417,493441,540841,879484,904977,934637,944313,959537,1021085,1110134,1125801,1279599,1294950,1358820,1379350,1395561,1397917,1405868,1441912,1567778,1598273,2147970,2153189,2260140,2260425,2288912,2306738,2327580,2364866,2434484,2434834,2468129,2511414,2516781,2538696,2551173,2560998,2564834,2583514,2591559,2628481,2654824,2670795,2678095,2726128,2757710,2789701,2857416,2857471,2857521,2857541)