The Employee table holds the salary information in a year.  Write a SQL to get the cumulative sum of an employee's salary over a period of 3 months but exclude the most recent month.  The result should be displayed by 'Id' ascending, and then by 'Month' descending.  Example Input  | Id | Month | Salary | |----|-------|--------| | 1  | 1     | 20     | | 2  | 1     | 20     | | 1  | 2     | 30     | | 2  | 2     | 30     | | 3  | 2     | 40     | | 1  | 3     | 40     | | 3  | 3     | 60     | | 1  | 4     | 60     | | 3  | 4     | 70     |   Output  | Id | Month | Salary | |----|-------|--------| | 1  | 3     | 90     | | 1  | 2     | 50     | | 1  | 1     | 20     | | 2  | 1     | 20     | | 3  | 3     | 100    | | 3  | 2     | 40     |   Explanation Employee '1' has 3 salary records for the following 3 months except the most recent month '4': salary 40 for month '3', 30 for month '2' and 20 for month '1' So the cumulative sum of salary of this employee over 3 months is 90(40+30+20), 50(30+20) and 20 respectively.  | Id | Month | Salary | |----|-------|--------| | 1  | 3     | 90     | | 1  | 2     | 50     | | 1  | 1     | 20     |   Employee '2' only has one salary record (month '1') except its most recent month '2'.  | Id | Month | Salary | |----|-------|--------| | 2  | 1     | 20     |   Employ '3' has two salary records except its most recent pay month '4': month '3' with 60 and month '2' with 40. So the cumulative salary is as following.  | Id | Month | Salary | |----|-------|--------| | 3  | 3     | 100    | | 3  | 2     | 40     |   My query is   SELECT e.id, e.month,        RunningTotal = sum(e.salary ) OVER (ORDER BY e.Id  ,e.month )  FROM employee e inner join      employee e2       on e.id=e2.id and e.month=e2.month and          e.month &lt;&gt; (select max(month) from employee group by id having id=e.id ) order by e.id asc, e.month desc   Error I am getting is      Line 3: SyntaxError: near '(ORDER BY e.Id  ,e.month )  FROM employee e   inner join  employee e2 on e.id=e2.i'
I have this MySQL query:  SELECT DAYOFYEAR(`date`)  AS d, COUNT(*)  FROM  `orders`  WHERE  `hasPaid` &gt; 0 GROUP  BY d ORDER  BY d   Which returns something like this:  d  | COUNT(*) | 20 |  5       | 21 |  7       | 22 | 12       | 23 |  4       |   What I'd really like is another column on the end to show the running total:  d  | COUNT(*) | ??? | 20 |  5       |   5 | 21 |  7       |  12 | 22 | 12       |  24 | 23 |  4       |  28 |   Is this possible?
How can I kill the Mirelurk Queen? What is the difference between \big[ (or equivalently \big() and \bigl[? Is it always necessary to mention l (left) and r (right)? I'm using JUnit 4.4 and Maven and I have a large number of long-running integration tests.  When it comes to parallelizing test suites there are a few solutions that allow me to run each test method in a single test-class in parallel. But all of these require that I change the tests in one way or another.  I really think it would be a much cleaner solution to run X different test classes in X threads in parallel. I have hundreds of tests so I don't really care about threading individual test-classes.  Is there any way to do this? I have some music discs, but every time I put it in a jukebox I can't hear it. It says it's playing, my friend (on PS4) says he can hear it, but I don't. All other audio is fine, I can hear the game audio fine, even if I have a world that's only me: it still doesn't produce jukebox sounds. It visually shows that it's playing (the notes come out of the jukebox) but there is no music. I play on Pocket Edition. Can someone help me resolve this issue? Why am I getting shopping trolley notifications about local store savings? I am getting "Shopping Trolley" notifications appearing regularly. The notification looks like this:   The notification is about "Store savings" at a local supermarket and that is it!   Is this notification from Google Maps or another application like Google Assistant? I'm struggling to find the specific setting to disable the notification.  I am also interested to know if this notification could in any way be targeted advertising generated by the store. My marketing preferences with the store are opt-out and this strikes me as very dumb advertising. Surely Google isn't doing this? Is there a means that a store can generate notifications like this? Could it be targeted if they have my email address?  These are pain and I want to understand why they are spamming me and disable them without disabling everything else.  I can see various options under Google Maps, settings, notifications. Which setting would apply? Could it be "New on maps, Get occasional updates about new features in your area"? I can't see what setting to suppress!  Thanks for all help. Getting arguments underneath \min in an align environment Where to spend a night in the Mumbai airport My girlfriend and I have a layover at the Mumbai airport from 19:35 to 05:55 and we would like to sleep in a cheap place near to the airport (maximum 30 minutes away). Is there any cheap hotel near there? Or any cheap lounge where to sleep well? (flight at 05:55 is an intercontinental flight and we prefer to stay "fresh"). If not possible, is the airport a safe place to sleep? Importing installed package from script raises "AttributeError: module has no attribute" or "ImportError: cannot import name" In today's pattern recognition class my professor talked about PCA, eigenvectors and eigenvalues.   I understood the mathematics of it. If I'm asked to find eigenvalues etc. I'll do it correctly like a machine. But I didn't understand it. I didn't get the purpose of it. I didn't get the feel of it.        I strongly believe in the following quote:     You do not really understand something unless you can explain it to your grandmother. -- Albert Einstein   Well, I can't explain these concepts to a layman or grandma.   Why PCA, eigenvectors &amp; eigenvalues? What was the need for these concepts? How would you explain these to a layman? What is information? A simple pendulum suspended from the ceiling of a stationary lift has period $T_0$. When the lift descends at steady speed, the period is $T_1$. When the lift descends with constant downward acceleration, the period is $T_2$. Explain why $T_0 = T_1 &lt; T_2$.  I know that for small angles of oscillations, $T \approx 2\pi\sqrt\frac{l}{g}$ where $l$ is the length of the pendulum. For the first two cases, since $\sum F = 0$, the value of $g$ is apparently the same. However, I am unable to explain why the period is largest for $T_2$. If $g$ is the same for all cases, shouldn't their periods be the same? Fullscreen YouTube video crash Stop generating "possible duplicate" comments When a question has pending close votes, the system now adds a banner indicating that the question might be a duplicate:    But the first user to vote still generates a possible duplicate comment:    Those comments were always a hack, just like editing the link into the top of the post. The banner eliminated the need for the latter; can we stop generating those comments too? Let $y_n$ be a sequence such that  $\lim_{n\to \infty} y_n= y$ then prove that     $ \lim \dfrac{y_1+y_2+...+y_n}{n}= y$   My try:  As  $\lim_{n\to \infty} y_n= y$ then given $\epsilon&gt;0$ there exists $N$ such that $\forall n\ge N ;||y_n-y||&lt;\epsilon $.  Now $||\dfrac{y_1+y_2+...+y_n}{n}-y||\le n^{-1}\{||y_1-y||+||y_2-y||+...+||y_n-y||\}$  How to make this limit tend to zero? Grub rescue after installing Ubuntu on a external HDD from USB Finder search doesn't work properly after Yosemite update Ever since I upgraded to Yosemite, search no longer works properly in Finder. Spotlight works fine but Finder search just gives me a blank window with a spinning ball.  I've tried reindexing and I've also tried deleting Spotlight's .plist file. I restart my MacBook Pro after doing either. Finder search will work for one or two queries and stop again. I don't know what else I can do. Are there any options of bash with which it is invoked? I  that the default shell that I use when I start Terminal (with Ctrl+Alt+T) is /bin/bash.   And running the built-in command  on  as:   type -p bash   returns the result as:  /bin/bash   Suggesting the same executable is run when I do Ctrl+Alt+T or say bash.  This shell is the same as an invocation of the command  with some of its options passed to it right? If yes, what are these options?   As an example, perhaps the -i option gets passed so as to make the bash shell interactive?   PS: Maybe  is related too, but I cannot seem to piece together all the pieces here. I understand if you travelling in or to the US, you can lock your luggage using the TSA Luggage Lock. (Immigration is still able to open your luggage using their own special keys)  How about Europe? Especially Heathrow + Charles de Gaulle?    If the TSA Lock is not acceptable in Europe, are there any other alternative precautions I could use instead?  (FYI, information about the ) Can I publish parts of the Ph.D thesis as a paper in a journal? Sum of two uniform random variables