Advertisement
Combreal

stats-ITShop.sql

Oct 3rd, 2019
662
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.30 KB | None | 0 0
  1. --budget per team in 2019
  2. SELECT intervention.STRUCTURE, SUM(intervention.Prix_total) AS "TOTAL in euros"
  3. FROM intervention
  4. WHERE (intervention.Date_maj > "2018-10-01 10:11:11") AND (intervention.STRUCTURE <> "-") AND (intervention.STRUCTURE IS NOT NULL)
  5. GROUP BY intervention.STRUCTURE
  6. ORDER BY SUM(intervention.Prix_total) DESC
  7. LIMIT 0 , 500
  8.  
  9.  
  10. --total items cost per team
  11. SELECT intervention.STRUCTURE AS "Team",article.Article,SUM(intervention.Prix_total) AS "TOTAL in euros"
  12. FROM intervention
  13. INNER JOIN article ON intervention.Code_article = article.Code_article
  14. WHERE (intervention.Date_maj > "2018-10-01 10:11:11") AND (intervention.STRUCTURE <> "-") AND (intervention.STRUCTURE IS NOT NULL)
  15. GROUP BY article.Article, intervention.STRUCTURE
  16. ORDER BY article.Article, SUM(intervention.Prix_total) DESC
  17. LIMIT 0 , 500
  18. INTO OUTFILE '/tmp/commandMagasin2019.csv'
  19. FIELDS TERMINATED BY ','
  20. ENCLOSED BY '"'
  21. LINES TERMINATED BY '\n'
  22.  
  23.  
  24. --total items cost
  25. SELECT article.Article,SUM(intervention.Prix_total) AS "TOTAL in euros"
  26. FROM intervention
  27. INNER JOIN article ON intervention.Code_article = article.Code_article
  28. WHERE (intervention.Date_maj > "2018-10-01 10:11:11") AND (intervention.Prix_total IS NOT NULL)
  29. GROUP BY article.Article
  30. ORDER BY SUM(intervention.Prix_total) DESC
  31. LIMIT 0 , 500
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement