i m trying to limit the rows to where the sum a column equals a certain value but i m getting unexpected results.  CREATE TABLE buy (   id int not null,   volume decimal(9,4) not null,   price decimal(9,2) not null  );  insert buy (id, volume, price) values  (1, 1.0000, 14250.00), (2, 0.2500, 14251.10), (3, 0.2500, 14250.00), (4, 0.0050, 14200.00), (5, 0.5000, 14255.01);   expected result selected ids 5,2,1(because ordering by higest price) but it selects ids 2,1,3  SELECT t.id, t.volume, t.price, (SELECT SUM(volume) FROM buy WHERE id &lt;= t.id) 'RequiredVolume' FROM buy t HAVING RequiredVolume &lt;= '1.5000' ORDER BY price DESC, id ASC;  | id | volume |   price | RequiredVolume | |----|--------|---------|----------------| |  2 |   0.25 | 14251.1 |           1.25 | |  1 |      1 |   14250 |              1 | |  3 |   0.25 |   14250 |            1.5 |
i have a table like this  +--------+------------+-----------+ | id     | volume     | price     | +--------+------------+-----------+ |      1 | 1.0000     |  14250.00 | |      2 | 0.2500     |  14251.10 | |      3 | 0.2500     |  14250.00 | |      4 | 0.0050     |  14200.00 | |      5 | 0.5000     |  14255.01 | +--------+------------+-----------+   Simply if volume 1.7500, how to select like bellow by ordering(highest price)  +--------+------------+-----------+ | id     | volume     | price     | +--------+------------+-----------+ |      5 | 0.5000     |  14255.01 | |      2 | 0.2500     |  14251.10 | |      1 | 1.0000     |  14250.00 | +--------+------------+-----------+   And if volume 1.5000 it also select the least amounts of records needed to calculate to the input volume  +--------+------------+-----------+ | id     | volume     | price     | +--------+------------+-----------+ |      5 | 0.5000     |  14255.01 | |      1 | 1.0000     |  14250.00 | +--------+------------+-----------+   some guys say i cant do this with sql
How to run a program on a remote pc via command line? How can I run a program on a remote Windows PC in our network without the need of killing an existing remote-desktop-connection? I only need a command line for running the program and getting its results. Thank you! How can author deal with late reviews? Another problem I personally struggle with in peer-review publication process is the situation when review takes really, really, really long. The precise definition of "long" is probably very area-specific: for example a paper in Maths will probably took longer to review than one in Physics. Many well-established journals and major publishers, sadly, prefer not to specify the "rules of the game" precisely, particularly how long the review process should normally take. Fortunately, I quite often serve as a referee with the very same journals and know the amount of time I am given to write a review. Unfortunately, when I am an author, I do not observe these deadlines to be always met. For example, a notable U.S. publisher would ask a reviewer to send a review in 2 months; but in practice a first review of my paper once took as long as 8 months.  As a rule of thumb, I usually start writing to editors with questions about "the status of my paper" in X+1 months time, when X is a deadline time for a reviewer to submit a review. This strategy is not particularly successful &mdash; what I usually get is a recommendation to be more patient. Since there is no "official" deadline time announced, there is no formal ground for complaints here.  Of course, such delays lead to a whole bunch of funny situations, particularly if a preprint is put online (e.g., on arXiv) and the results are presented in some conferences. Follow-ups with no official paper to cite, grant applications in which you can not justify by a solid publication, good research but bad bibliometrics or CV, to name just a few.   Could you recommend an efficient way to deal with this problem? Adding newmode with Xrandr - "800x480_60.00" I have 5-inch a 800x480 tft connected to the LVDS connector on a Portwell WADE-8020 mini-ITX embedded system board. I would like to build a XMBC/Kodi box for streming my music from my freenas PC with the tft showing what is been played, I got as fare as this...   sudo xrandr --newmode "800x480_60.00"  29.50  800 824 896 992  480 483 493 500 -hsync +vsync`enter code here   then,  sudo xrandr --addmode LVDS1 800x480_60.00   now that I get the correct resolution, I now have a black band on the top of the screen.  sudo xrandr --output LVDS1 --set "scaling mode"  "Full aspect"   However this did not solve the issue, also I know I need to amend the /bin/sh file with this from googling so I don't need to keep doing this at every boot. But I don't know how to as I'm very new to Linux.  #!/bin/sh xrandr --newmode "800x480_60.00"  29.50  800 824 896 992  480 483 493 500 -hsync +vsync xrandr --addmode LVDS1 800x480_60.00 In the answer to , I was advised:      Yes you have to download the language pack. And you also have to go here: C:\Program Files (x86)\Origin Games\Dragon Age Inquisition\Data\Win32        In the folder loctext leave only the files en.sb and en.toc present, put the others in a folder named temp.   In the folder locfacefx make a copy of en.sb_DiP_STAGED and en.toc_DiP_STAGED, rename them to en.sb and en.toc. place the other language files into a temp folder   When I started the game the language was changed also into the interface. Take notes on what you have done and keep the original files in case something doesn't work, but for the moment that seem to work."   I have no en.sb_DiP_STAGED and en.toc_DiP_STAGED files in my Origin version of the game. How do you call an external command (as if I'd typed it at the Unix shell or Windows command prompt) from within a Python script? Can I revert to the Mountain Lion style labels instead of Mavericks tags? How? Review bans should escalate beyond 30 days How do suggested edits work? When clicking &quot;edit&quot; I see:  Your edit will be placed in a queue until it is peer reviewed. We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.  Like:     Likewise, when I am not logged in, clicking &quot;improve this question&quot; or &quot;improve this answer&quot; shows:  You are not . Your edit will be placed in a queue until it is .  And when I click 'Save', I get:  Thanks for submitting an edit. It is only visible to you until it's been approved by trusted community members  Like:     Who can suggest an edit? Where do suggested edits go? Who can vote on a suggested edit? How do suggested edits get reviewed? Can I earn reputation? What about abuse or bad edits? Sometimes the Community user approves or rejects my edit. Why is that? When can I not suggest an edit? Is there a minimum change requirement for a suggested edit? How do I check my suggested edit history? I disagree with the reasons why my suggested edit was rejected. What can I do? How do I know whether there are edits waiting for review? Someone suggested an edit to my own post, and the reviewers took the wrong action. What can I do? Are tag wikis included in this scheme? What do the &quot;Improve Edit&quot; and &quot;Reject and Edit&quot; buttons do? Why are apparently valid links to rejected edits resulting in 404 errors?   For more information about editing, see &quot;&quot; in the . For which Natural $n\ge2: \phi(n)=n/2$ Clipping LAS data using shapefile polygons and open source software? I am trying to clip or filter lidar files (.las, .xyz) using a shapefile that contains multiple polygons.  Is there open source software that can do this spatial operation?  My .las files are enormous, and I should say that I am very new to DEM data and analysis so any help would be very welcome. system wide keyboard hook on X under linux Distance between two hyperplanes I have two parallel hyper planes $$a^Tx=b_1,a^Tx=b_2$$ where $a \in \mathbb{R}^n, x \in \mathbb{R}^n ,b \in \mathbb{R}$ and I want to find the distance between the two. I have read that the distance between the two hyperplanes is also the distance between the two points $x_1$ and $x_2$ where the hyperplane intersects the line through the origin and parallel to the normal vector $\vec a$. These points are given by $$x_1=\frac{b_1}{\|a\|^2_2}a$$ and $$x_2=\frac{b_2}{\|a\|^2_2}a$$ Then the distance is $|x_1-x_2|$ but I don't really understand how we got $x_1$ and $x_2$. A bob hanging in an accelerating train moves backward. What is the force moving it backward? When the train accelerates, the bob would also accelerate with the same magnitude and direction as the train. From the free body diagram, only tension and weight are exerted on the bob. I understand how to relate the "horizontal component" of the tension to the acceleration of the bob. It moves "backward" and in fact its vertical position is different from when the train is not accelerating.  I am not sure whether inertia could explain this situation. What is the force moving it backward/ lifting with the height? I'm trying to set an RSA key as an environment variable which, as a text file, contains newline characters.  Whenever I attempt to read from the file and pass it into an environment variable, it will just stop at the newline character on the first line. How can I prevent this? Spontaneous electroweak symmetry breaking (i.e. $SU(2)\times U(1)\to U(1)_{em}$ ) is at scale about 100 Gev. So, for , gauge bosons $Z$ &amp; $W$ have masses about 100 GeV. But before this spontaneous symmetry breaking ( i.e. Energy > 100 GeV) the symmetry $SU(2)\times U(1)$ is not broken, and therefore gauge bosons are massless.  The same thing happens when we go around energy about $10^{16}$ GeV, where we have the Grand Unification between electroweak and strong interactions, in some bigger group ($SU(5)$, $SO(10)$ or others). So theoretically we should find gauge bosons $X$ and $Y$ with masses about $10^{16}$ GeV after GUT symmetry breaks into the Standard Model gauge group $SU(3)\times SU(2)\times U(1)$, and we should find massless X and Y bosons at bigger energies (where GUT isn't broken).  So this is what happened in the early universe: when temperature decreased, spontaneous symmetry breaking happened and firstly $X$ &amp; $Y$ gauge bosons obtained mass and finally $Z$ &amp; $W$ bosons obtained mass.   Now, I ask: have I understood this correctly? In other words, if we make experiments at energy above the electroweak scale (100 GeV) we are where $SU(2)\times U(1)$ isn't broken and then we should (experimentally) find $SU(2)$ and $U(1)$ massless gauge bosons, i.e. $W^1$, $W^2$, $W^3$ and $B$ with zero mass? But this is strange, because if I remember well in LHC we have just make experiments at energy about 1 TeV, but we haven't discovered any massless gauge bosons. I would like to know how to put a time delay in a Python script. Spacing around \left and \right Why does the addition of a \left and \right introduces an extra space around the formula? Specifically, why do $\cos(\theta)$ and $\cos\left(\theta\right)$ render differently?  Is there a way to use resizable delimiters without introducing the spurious spaces?  Why did Knuth design it like this?  Edit: This occurs too, if \operatorname{MYOP} or some other operator, like \lim, \min etc. is used. (This edit is basically to make it easier to find this answer.) Recovering data from a faulty disk When I plug in a removable 1TB USB disk in my laptop, the operations led keeps blinking for a while and then you can hear the servo mechanism resetting with a short "tack".  I'd like to recover the data.    I believe there might be some way to get the data through low level IOs.    What I believe is that the mounting process assumes the disk is OK and I should prevent this before using ddrescue or something similar.  Does anybody have a solution to this problem? Why do we call a 1/2 spin particle satisfying the Dirac equation a , and not a  or a ? Let $I = \{a +ib \in \Bbb Z[i] : a$ and $b$ are both multiple of $5\}$.