With the following sample data, requestedDate         Status 2020-04-21            APPROVED 2020-04-23            APPROVED 2020-04-27            PENDING 2020-05-21            PENDING 2020-06-01            APPROVED  I have the following query to aggregate count by status,year, month etc select      status,     count(*) status_count,     date_format(requestedDate, '%b') requested_month,     sum(count(*)) over(partition by year(requestedDate), month(requestedDate)) month_count,     sum(count(*)) over() total_count from Reports where requestedDate between current_date - interval 120 day and current_date group by status, year(requestedDate), month(requestedDate), date_format(requestedDate, '%b') ;  Output for the query is as follows, status     status_count requested_month month_count total_count APPROVED     1             Apr             2           4 PENDING      1             Apr             2           4 PENDING      1             May             1           4 APPROVED     1             Jun             1           4  Can i instead get an output that looks like the following which is status,month,count for each status for that month and total count for all records for the period stated, Status     Month  COUNT TOTAL_COUNT APPROVED    APR    2      5 APPROVED    MAY    0      5 APPROVED    JUN    1      5 PENDING     APR    1      5 PENDING     MAY    1      5 PENDING     JUN    0      5  My db is mysql 8.0.17
I'm building a quick csv from a mysql table with a query like:  select DATE(date),count(date) from table group by DATE(date) order by date asc;   and just dumping them to a file in perl over a:  while(my($date,$sum) = $sth-&gt;fetchrow) {     print CSV "$date,$sum\n" }   There are date gaps in the data, though:  | 2008-08-05 |           4 |  | 2008-08-07 |          23 |    I would like to pad the data to fill in the missing days with zero-count entries to end up with:  | 2008-08-05 |           4 |  | 2008-08-06 |           0 |  | 2008-08-07 |          23 |    I slapped together a really awkward (and almost certainly buggy) workaround with an array of days-per-month and some math, but there has to be something more straightforward either on the mysql or perl side.   Any genius ideas/slaps in the face for why me am being so dumb?    I ended up going with a stored procedure which generated a temp table for the date range in question for a couple of reasons:   I know the date range I'll be looking for every time The server in question unfortunately was not one that I can install perl modules on atm, and the state of it was decrepit enough that it didn't have anything remotely Date::-y installed   The perl Date/DateTime-iterating answers were also very good, I wish I could select multiple answers!
Stored Procedures, MySQL and PHP The question is a fairly open one. I've been using Stored Procs with MS SQLServer for some time with classic ASP and ASP.net and love them, lots.  I have a small hobby project I'm working on and for various reasons have gone the LAMP route. Any hints/tricks/traps or good starting points to get into using stored procedures with MySQL and PHP5? My version of MySQL supports Stored Procedures. Android – Listen For Incoming SMS Messages How do I add reCaptcha to a custom form? I need to add a reCaptcha to my form; creating the form then adding the form ID to the reCaptcha settings did nothing. I told my follower (Serana) to wait. But this is different. I told her to go somewhere and wait so it will activate the enemies. Well it did and I killed them. But Serana seems to be not following me anymore. I can't tell her to follow me. And she is constantly in a squatting position. The only thing I can do is tell her to wait somewhere else to move her. And I can't part ways because I'm doing a main quest and she has to be there. Can anybody give me a tip on what to do? How to achieve line break in simple $formula$-mode Dirac's remark that inspired Feynman when formulating path integral When Feynman was trying to formulate  of quantum mechanics, he was inspired by Dirac's remark which roughly states that $e^{i\frac{S}{\hbar}}$corresponds to the transition amplitude, where $S$ is the action.   I'm wondering what was Dirac's original argument behind this statement. Prove that $\sin(\theta) + \sin(\theta+2\pi/3) + \sin(\theta+4\pi/3) = 0 $ for any angle $\theta$.   This came up in the context of electricity:  It is common in electrical power engineering to use three-phase circuits with sinusoidal currents out of phase with each other by 120 degrees. The benefit of this is that the currents sum to zero at the neutral point meaning less copper is required for the system.    However, while I know that the three phasors always sum to zero, and can see visually, as in the figure that this is true at every point, how can this be shown more formally, or algebraically? Test -n gives unexpected result I understand test -n &lt;expression&gt; to return false if the expression evaluates to a string length of greater than 0.  Why then does the following happen?  Macbook:~ echo ${#undeclared_variable} 0 Macbook:~ test -n $undeclared_variable &amp;&amp; echo Foo Foo   Bash 4.x  My expectation is that since test -n $undeclared_variable should evaluate false, that Foo should not be echoed.  If I use [[  ]] instead of test, it works as expected. Throughout Blade Runner we see Gaff (Edward James Olmos) making origami figures at various points in the movie. He makes a chicken, matchstick men and at the end of the film there is a unicorn waiting outside Deckard's apartment.    There is a   of  out there regarding the unicorn in particular, and how it indicates that Deckard is a replicant. I think an answer regarding the use of origami in general will be interesting new ground to cover.  Why origami? What does the origami represent in Blade Runner? What does the dot mean Avoiding Windows 10 Creator, but not other updates How can I detect mouse events on sprites in a canvas? I'm making an HTML 5 game. I want mouse clicks on sprites drawn in a canvas element cause events that my code can react to. At the moment, I'm doing it by checking through all of my sprites in a for-loop on each click.  Is there a way to do that by adding an event listener to a sprite so it would respond just like that?  Are Javascript's custom events useful in this situation? I know it's possible with KinectJS, but I don't have any experience with it and really I'd like to learn how to do this myself without the help of a library. During the latest gaming session our level 3 Rogue was Two-Weapon fighting with a Rapier in the main-hand and a scimitar in the off-hand.  At the completion of our gaming session I contested the application of the Two-Weapon fighting rules as it seemed unbalanced.  Once I got home I reviewed the PHB and various RPGStack and Reddit but couldn't find a concrete answer.  My interpretation of the PHB Reference rules below is that although any class/character can technically wield a weapon in their off-hand, only those who have been granted a Bonus Action for which no explicit bonus action have been defined would be allowed to actually attack.  So in the case of a Rogue the Bonus Actions granted under Cunning Action allow for specific actions (none of which are attack).  The alternate interpretation would be the rules under Two-Weapon Fighting, perhaps it should be written      you receive a bonus action to attack with a different light melee weapon that you’re holding in the other hand.   This would, in my opinion, explicitly grant the Bonus Action to any character/class who is Two-Weapon Fighting.  After thorough review does it boil down to application of the rules-as-written and determining a house-rule to apply in our campaign?    References  Page 189 of PHB : Bonus Actions  Various class features, spells, and other abilities let you take an additional action on your turn called a bonus action. The Cunning Action feature, for example, allows a rogue to take a bonus action.      You can take a bonus action only when a special ability, spell, or other feature of the game states that you can do something as a bonus   action. You otherwise don’t have a bonus action to take.   You can take only one bonus action on your turn, so you must choose which bonus action to use when you have more than one available. You choose when to take a bonus action during your turn, unless the bonus action’s timing is specified, and anything that deprives you of your ability to take actions also prevents you from taking a bonus action.  Page 96 of PHB  A Rogue receives cunning action at level 2, You can take a bonus action on each of your turns in combat.      This action can be used only to take the Dash, Disengage, or Hide action.   Page 195 of PHB  Two-Weapon Fighting (Combat Rules)  When you take the Attack action and attack with a light melee weapon that you’re holding in one hand, you can use a bonus action to attack with a different light melee weapon that you’re holding in the other hand. You don’t add your ability modifier to the damage of the bonus attack, unless that modifier is negative. If either weapon has the thrown property, you can throw the weapon, instead of making a melee attack with it.  Page 165 of PHB  Dual Wielder  (Feat)  You master fighting with two weapons, gaining the following benefits:   You gain a +1 bonus to AC while you are wielding a separate melee weapon in each hand. You can use two-weapon fighting even when the one-handed melee weapons you are wielding aren't light. You can draw or stow two one-handed weapons when you would normally be able to draw or stow only one. Can I use a HDD on my PS3 if I have already used another on the same console? I'm thinking of changing the Hard Disk of my PS3 (Slim 120GB), but I am unsure of what will happen to the data on the one I previously had if I do this:   PS3 has some data in the HDD. I turn off PS3, change HDD, install OS on new HDD. I download some data on new HDD from PS Plus.   Let's imagine I forgot to back something up...   I turn PS3 off, change HDD back.   Can I still use the old hard drive without needing to format it again? How to type special/accented letters in LaTeX? How to type these special letters from European languages in latex? ä, é, and L'? What was the purpose of banning use/development of cloaking technology in Treaty of Algeron? The  prohibited the development or use of cloaking technology by the Federation. This treaty was a peace treaty and use of cloaking technology in one's own space couldn't disturb peace. Plus, the Romulans already had cloaking technology, so banning it was unfair for the Federation. So, why was this ban introduced?  Another thing: There were many things to ban, but why cloaking technology? What to do with meta questions referring to currently non-existing features? I sometimes come across such questions like that:    The "Not a real question" close reason doesn't exist for long time. It doesn't make sense to answer, comment, or even up/downvote (since there's nothing more to vote for/against it).   Shouldn't such questions be locked as historical ones? Should I flag them for moderator attention or just ignore them? When a ball moves to the right, friction acts to oppose the motion, in other words, to the left. However, when a car travels around a bend, the friction acts in the perpendicular direction to the car's velocity and provides the centripetal force. I just cannot understand why friction would act in that direction. Overlapping matches in Regex I can't seem to find an answer to this problem, and I'm wondering if one exists. Simplified example:  Consider a string "nnnn", where I want to find all matches of "nn" - but also those that overlap with each other. So the regex would provide the following 3 matches:   nnnn nnnn nnnn   I realize this is not exactly what regexes are meant for, but walking the string and parsing this manually seems like an awful lot of code, considering that in reality the matches would have to be done using a pattern, not a literal string. Can $R \times R$ be isomorphic to $R$ as rings?