Advertisement
naimul64

just raw

Jul 2nd, 2016
1,337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 8.05 KB | None | 0 0
  1. select distinct ab.school_name_unicode from `stipend_info_10_11JulDis_2Jul_1` ab where (ab.school_name = 'Bashgari () Sarkari Prathmik Bidjalay' or ab.school_name = 'Bashgari Sarkari Prathmik Bidjalay');
  2.  
  3. -- today 03-07-2016
  4. SELECT ab.total_amount AS tot, COUNT(*) AS total, ab.school FROM
  5. (SELECT
  6.   SUM(s.`amount`) AS total_amount,
  7.   s.`school_name_unicode` AS school
  8. FROM
  9.   `stipend_info_02072016` s
  10.   INNER JOIN `student` t
  11.     ON s.`id` = t.`stipend_info_id`
  12. WHERE -- s.mobile_flag=0
  13. -- AND s.`amount_flag` = 0
  14. flag = 0
  15. AND s.amount IS NOT NULL
  16. GROUP BY s.`mobile_number`,
  17.   s.`parent_name`
  18. ) ab
  19. GROUP BY ab.total_amount, ab.school
  20. HAVING tot = 600 OR tot = 1200
  21. ORDER BY ab.school,total DESC;
  22.  
  23. select * from
  24.   `stipend_info_02072016` s
  25.   INNER JOIN `student` t
  26.     ON s.`id` = t.`stipend_info_id`;
  27.    
  28. select s.thana_name, s.thana_name_original, s.thana_name_unicode from
  29.   `stipend_info_02072016` s
  30.   where school_name_unicode = 'আটঘেরা সরকারি প্রাথমিক বিদ্যালয়';
  31.  
  32.  
  33. SELECT ab.total_amount AS tot, COUNT(*) AS total, ab.school, ab.thana, ab.district FROM
  34. (SELECT
  35.   SUM(s.`amount`) AS total_amount,
  36.   s.`school_name_unicode` AS school, s.thana_name_unicode as thana, s.district_original  as district
  37. FROM
  38.   `stipend_info_02072016` s
  39.   INNER JOIN `student` t
  40.     ON s.`id` = t.`stipend_info_id`
  41. where flag = 0
  42. AND s.amount IS NOT NULL
  43. GROUP BY s.`mobile_number`
  44. -- ,
  45.   -- s.`parent_name_modified`
  46. ) ab
  47. GROUP BY ab.total_amount, ab.school
  48. HAVING tot = 600 OR tot = 1200
  49. ORDER BY ab.school,total DESC;
  50.  
  51.  
  52. ////////////////////////////
  53.  
  54. select * from `stipend_info_10_11JulDis_2Jul_1`;
  55.  
  56. select count(*) from `stipend_info_10_11JulDis_2Jul_1` t
  57. group by t.parent_name_unicode, t.nationalidoriginal;
  58.  
  59. select count(distinct t.mobile_number) validMobileCount, Group_Concat(distinct t.mobile_number separator ',  ') from `stipend_info_10_11JulDis_2Jul_1` t
  60. where
  61. (
  62.   (SUBSTR(t.`mobile_number`,1,3) IN ('017','016','015','019','018','011') AND LENGTH(t.`mobile_number`) = 11)
  63.   OR
  64.   (SUBSTR(t.`mobile_number`,1,2) IN ('17','16','15','19','18','11') AND LENGTH(t.`mobile_number`) = 10)
  65. )
  66. group by t.parent_name_unicode, t.nationalidoriginal
  67. order by validMobileCount desc;
  68.  
  69.  
  70.  
  71. SELECT
  72.     f.parent_name_unicode,
  73.     f.nationalidoriginal,
  74.     f.mobile_number,
  75.     s.mobile_number
  76. FROM
  77.     `stipend_info_10JulDisb_1Jul-1` f
  78.         INNER JOIN
  79.     `stipend_info_10JulDisb_1Jul-1` s ON f.parent_name_unicode = s.parent_name_unicode
  80.         AND f.nationalidoriginal = s.nationalidoriginal
  81.         INNER JOIN
  82.     (SELECT
  83.         COUNT(DISTINCT t.mobile_number) validMobileCount,
  84.             t.mobile_number
  85.     FROM
  86.         `stipend_info_10JulDisb_1Jul-1` t
  87.     WHERE
  88.         ((SUBSTR(t.`mobile_number`, 1, 3) IN ('017' , '016', '015', '019', '018', '011')
  89.             AND LENGTH(t.`mobile_number`) = 11)
  90.             OR (SUBSTR(t.`mobile_number`, 1, 2) IN ('17' , '16', '15', '19', '18', '11')
  91.             AND LENGTH(t.`mobile_number`) = 10))
  92.     GROUP BY t.parent_name_unicode , t.nationalidoriginal) t ON f.mobile_number = t.mobile_number
  93. WHERE
  94.     f.mobile_number != s.mobile_number
  95.         AND f.nationalidoriginal != 'Null'
  96.         AND ((SUBSTR(f.`mobile_number`, 1, 3) IN ('017' , '016', '015', '019', '018', '011')
  97.         AND LENGTH(f.`mobile_number`) = 11)
  98.         OR (SUBSTR(f.`mobile_number`, 1, 2) IN ('17' , '16', '15', '19', '18', '11')
  99.         AND LENGTH(f.`mobile_number`) = 10))
  100.         AND NOT ((SUBSTR(s.`mobile_number`, 1, 3) IN ('017' , '016', '015', '019', '018', '011')
  101.         AND LENGTH(s.`mobile_number`) = 11)
  102.         OR (SUBSTR(s.`mobile_number`, 1, 2) IN ('17' , '16', '15', '19', '18', '11')
  103.         AND LENGTH(s.`mobile_number`) = 10));
  104.  
  105.  
  106.  
  107.  
  108. UPDATE
  109.     `stipend_info_10JulDisb_1Jul-1` f
  110.         INNER JOIN
  111.     `stipend_info_10JulDisb_1Jul-1` s ON f.parent_name_unicode = s.parent_name_unicode
  112.         AND f.nationalidoriginal = s.nationalidoriginal
  113.         INNER JOIN
  114.     (SELECT
  115.         COUNT(DISTINCT t.mobile_number) validMobileCount,
  116.             t.mobile_number
  117.     FROM
  118.         `stipend_info_10JulDisb_1Jul-1` t
  119.     WHERE
  120.         ((SUBSTR(t.`mobile_number`, 1, 3) IN ('017' , '016', '015', '019', '018', '011')
  121.             AND LENGTH(t.`mobile_number`) = 11)
  122.             OR (SUBSTR(t.`mobile_number`, 1, 2) IN ('17' , '16', '15', '19', '18', '11')
  123.             AND LENGTH(t.`mobile_number`) = 10))
  124.     GROUP BY t.parent_name_unicode , t.nationalidoriginal) t ON f.mobile_number = t.mobile_number
  125.     set s.mobile_number = f.mobile_number
  126. WHERE
  127.     f.mobile_number != s.mobile_number
  128.         AND f.nationalidoriginal != 'Null'
  129.         AND ((SUBSTR(f.`mobile_number`, 1, 3) IN ('017' , '016', '015', '019', '018', '011')
  130.         AND LENGTH(f.`mobile_number`) = 11)
  131.         OR (SUBSTR(f.`mobile_number`, 1, 2) IN ('17' , '16', '15', '19', '18', '11')
  132.         AND LENGTH(f.`mobile_number`) = 10))
  133.         AND NOT ((SUBSTR(s.`mobile_number`, 1, 3) IN ('017' , '016', '015', '019', '018', '011')
  134.         AND LENGTH(s.`mobile_number`) = 11)
  135.         OR (SUBSTR(s.`mobile_number`, 1, 2) IN ('17' , '16', '15', '19', '18', '11')
  136.         AND LENGTH(s.`mobile_number`) = 10));
  137.  
  138.  
  139. ///////////////////////
  140.  
  141.  
  142. select ab.mobile_number, ab.Amount as amount, count(*) as COUNT, Group_Concat(ab.beneficiary separator ','), ab.school_name_unicode
  143. from
  144. (
  145. SELECT
  146.   s.`parent_name_unicode` AS beneficiary,
  147.   s.mobile_number,
  148.   SUM(s.`amount`) AS Amount,
  149.   s.`school_name_unicode`,
  150.   s.school_name
  151. FROM
  152.   `stipend_info_10JulDisb_1Jul-1` s
  153.   INNER JOIN `student_10JulDisb_1Jul-1` t
  154.     ON s.`id` = t.`stipend_info_id`
  155. WHERE s.mobile_flag=0
  156. AND s.amount IS NOT NULL
  157.  
  158. GROUP BY s.`mobile_number`,
  159.   s.`parent_name_bijoy`, s.school_name_original
  160.   HAVING Amount > 0
  161. ) ab
  162. where (ab.school_name = 'Bashgari () Sarkari Prathmik Bidjalay' or ab.school_name = 'Bashgari Sarkari Prathmik Bidjalay')
  163. group by ab.mobile_number, amount
  164.  
  165. having count> 1
  166. order by  ab.school_name,ab.mobile_number,amount,COUNT desc;
  167.  
  168.  
  169. select ab.mobile_number, ab.Amount as amount, count(*) as COUNT, Group_Concat(ab.beneficiary separator ','), ab.school_name_unicode
  170. from
  171. (
  172. SELECT
  173.   s.`parent_name_unicode` AS beneficiary,
  174.   s.mobile_number,
  175.   SUM(s.`amount`) AS Amount,
  176.   s.`school_name_unicode`,
  177.   s.school_name
  178. FROM
  179.   `stipend_info_10JulDisb_1Jul-1` s
  180.   INNER JOIN `student_10JulDisb_1Jul-1` t
  181.     ON s.`id` = t.`stipend_info_id`
  182. WHERE s.mobile_flag=0
  183. AND s.amount IS NOT NULL
  184.  
  185. GROUP BY s.`mobile_number`,
  186.   s.`parent_name_bijoy`, s.school_name_original
  187.   HAVING Amount > 0
  188. ) ab
  189. where ab.school_name = 'Bashgari Sarkari Prathmik Bidjalay'
  190. group by ab.mobile_number, amount
  191.  
  192. having amount=600 and count> 1
  193. order by  ab.school_name,ab.mobile_number,amount,COUNT desc;
  194.  
  195. select * from `stipend_info_10JulDisb_1Jul-1` t join `student_10JulDisb_1Jul-1` s on t.id = s.stipend_info_id where t.mobile_number = '01718962780'
  196.  
  197. //////////////////////
  198.  
  199.  
  200. SELECT
  201.   SUM(s.`amount`) AS total_amount,
  202.   s.`school_name_unicode` AS school
  203. FROM
  204.   `stipend_info_02072016` s
  205.   INNER JOIN `student` t
  206.     ON s.`id` = t.`stipend_info_id`
  207. -- WHERE s.mobile_flag=0
  208. -- AND s.`amount_flag` = 0
  209. -- AND s.amount IS NOT NULL
  210. where flag = 0
  211. GROUP BY s.`mobile_number`,
  212.   s.`parent_name`;
  213.  
  214. ////////////////////////
  215.  
  216. SELECT
  217.   s.`token_no`,
  218.   s.`parent_name_bijoy` AS beneficiary,
  219.   s.`customer_wallet`,
  220.   GROUP_CONCAT(DISTINCT t.student_name_original SEPARATOR ',') AS Students_name,
  221.   SUM(s.`amount`) AS Amount,
  222.   GROUP_CONCAT(t.`class_name_orginal` SEPARATOR ',') AS classes,
  223.   COUNT(
  224.     DISTINCT t.`student_name_original`
  225.   ) AS total,
  226.   s.`school_name_original`
  227. FROM
  228.    stipend_info_02072016 s
  229.   INNER JOIN `student` t
  230.     ON s.`id` = t.`stipend_info_id`
  231. WHERE -- s.mobile_flag=0 and
  232.  s.school_name_unicode = 'আজিমপুর সরকারি প্রাথমিক বিদ্যালয়'
  233. -- AND s.`amount_flag` = 0
  234. AND s.amount IS NOT NULL
  235. and flag = 0
  236. GROUP BY s.`mobile_number`,
  237.   s.`parent_name_bijoy`
  238. ORDER BY s.`school_name_original`,s.`token_no` ASC;
  239.  
  240. //////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement