Code Monkey home page Code Monkey logo

microhardtec's Introduction

Query

SELECT AgeRange.ageGroup, Gender.gender, COUNT(person.partyId), ROUND(100 * COUNT(person.partyId) / Total.countOfPeople) AS percentage FROM (SELECT '00 - 1' AS ageGroup, CURRENT_DATE AS lower, CURRENT_DATE - INTERVAL 1 YEAR AS upper UNION ALL SELECT '1 - 3', CURRENT_DATE - INTERVAL 1 YEAR, CURRENT_DATE - INTERVAL 3 YEAR UNION ALL SELECT '3 - 5', CURRENT_DATE - INTERVAL 1 YEAR, CURRENT_DATE - INTERVAL 3 YEAR UNION ALL SELECT '5 - 12', CURRENT_DATE - INTERVAL 1 YEAR, CURRENT_DATE - INTERVAL 3 YEAR UNION ALL SELECT '12 - 18', CURRENT_DATE - INTERVAL 1 YEAR, CURRENT_DATE - INTERVAL 3 YEAR UNION ALL SELECT '18 - 24', CURRENT_DATE - INTERVAL 18 YEAR, CURRENT_DATE - INTERVAL 25 YEAR UNION ALL SELECT '25 - 34', CURRENT_DATE - INTERVAL 25 YEAR, CURRENT_DATE - INTERVAL 35 YEAR UNION ALL SELECT '35 - 44', CURRENT_DATE - INTERVAL 35 YEAR, CURRENT_DATE - INTERVAL 45 YEAR UNION ALL SELECT '45 - 54', CURRENT_DATE - INTERVAL 45 YEAR, CURRENT_DATE - INTERVAL 55 YEAR UNION ALL SELECT '55 - 64', CURRENT_DATE - INTERVAL 55 YEAR, CURRENT_DATE - INTERVAL 65 YEAR UNION ALL SELECT '65+', CURRENT_DATE - INTERVAL 65 YEAR, null UNION ALL SELECT 'Unknown', null, null) AgeRange CROSS JOIN (SELECT 'M' AS Gender UNION ALL SELECT 'F' UNION ALL SELECT 'Unknown') Gender CROSS JOIN (SELECT COUNT(*) countOfPeople FROM person) Total LEFT JOIN person ON ((person.dateOfBirth > AgeRange.upper AND dateOfBirth <= AgeRange.lower) OR (person.dateOfBirth <= AgeRange.lower AND AgeRange.upper IS NULL) OR (AgeRange.lower IS NULL AND AgeRange.upper IS NULL AND person.dateOfBirth IS NULL)) AND (Gender.gender = person.gender OR Gender.gender = 'Unknown' AND person.gender IS NULL) GROUP BY AgeRange.ageGroup, Gender.gender

https://blog.edmdesigner.com/sending-email-with-php/

microhardtec's People

Contributors

pascalkknde avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.