I'm pretty new to SQL (I'm using MySQL) and need some help. I'm currently trying to select the most common age(s) from a table called PERSON. Suppose PERSON has an AGE column which has values: 10, 10, 20, 20, 30. The query should return the values 10 and 20.  The following query only retrieves the top row (20):  SELECT AGE FROM PERSON GROUP BY AGE ORDER BY COUNT(*) DESC LIMIT 1;   My other thought was to try something like:  SELECT AGE FROM PERSON GROUP BY AGE HAVING COUNT(AGE) = MAX(COUNT(AGE));   This returns an error, stating that it is invalid use of group function.  Any help would be greatly appreciated. Thanks!
I have a table like this:   Column  | Type | Modifiers  ---------+------+-----------  country | text |   food_id | int  |   eaten   | date |    And for each country, I want to get the food that is eaten most often.  The best I can think of (I'm using postgres) is:  CREATE TEMP TABLE counts AS     SELECT country, food_id, count(*) as count FROM munch GROUP BY country, food_id;  CREATE TEMP TABLE max_counts AS     SELECT country, max(count) as max_count FROM counts GROUP BY country;  SELECT country, max(food_id) FROM counts     WHERE (country, count) IN (SELECT * from max_counts) GROUP BY country;   In that last statement, the GROUP BY and max() are needed to break ties, where two different foods have the same count.  This seems like a lot of work for something conceptually simple.  Is there a more straight forward way to do it?
Question about the Euclidean ring definition I recently came across the following definition for a euclidean ring:  There exists a function $g:R\to\Bbb N_0$ with the following properties:  1.) $\forall x,y \in R$ with $ y \neq 0$ there exist $q,r \in R$ with $x = qy + r$ where $r=0$ or $g(r) &lt; g(y)$.  2.) $\forall x,y\in R\setminus\{0\}$ we have $g(xy)\ge g(x)$  What I don't understand, is the point of the second requirement. I have seen definitions where this is not a requirement. What does 2.) achieve?   Thanks very much Gravitational slingshot of light using a black hole/massive object Wikipedia has this page on  using planets. In some cases this effect was used to accelerate the spacecraft to a higher velocity. This diagram shows this in a very oversimplified manner.   That got me thinking that if light is affected by gravity, and if it slingshots around the black hole/massive object, can't it gain a higher speed than $c$? What limitations are stopping it from doing this?  Forgive me if the answer to this question is pretty straight-forward or staring-you-in-the-face kind. I haven't fully understood the mechanics of the gravitational slingshot fully yet, but I couldn't wait to ask this. Note: If it is possible (I highly doubt that!), could you provide an explanation using Newtonian mechanics, I'm not very familiar with general relativity because I'm in high school. Today I upgraded to the Creators Update by running setup from the ISO mounted locally. When I got back to my computer I opened Task Manager and saw my memory usage was a lot higher than it was previously (it's now almost 6GB memory usage at idle after logging in instead of 2-3GB with the previous Windows build) - the processes tab revealed that there were upwards of 60 different instances of svchost.exe running. This 6GB figure is just for process memory - not including memory used for caching or "standby".  I ran tasklist /svc to get a listing of which services were in which processes and it lists almost every svchost.exe instance as only having one running service contained within (with the exception of a handful of instances that are running a few system services).  Here's  my output:  Image Name                     PID Services ========================= ======== ============================================ System Idle Process              0 N/A System                           4 N/A smss.exe                       440 N/A csrss.exe                      612 N/A wininit.exe                    700 N/A csrss.exe                      708 N/A services.exe                   776 N/A lsass.exe                      784 KeyIso, Netlogon, SamSs, VaultSvc svchost.exe                    888 PlugPlay svchost.exe                    908 BrokerInfrastructure, DcomLaunch, Power,                                    SystemEventsBroker fontdrvhost.exe                936 N/A svchost.exe                   1000 RpcEptMapper, RpcSs svchost.exe                    104 LSM winlogon.exe                   544 N/A fontdrvhost.exe                420 N/A svchost.exe                   1072 DeviceInstall dwm.exe                       1136 N/A svchost.exe                   1164 BFE, CoreMessagingRegistrar, MpsSvc svchost.exe                   1424 lmhosts svchost.exe                   1432 W32Time svchost.exe                   1440 nsi svchost.exe                   1448 wudfsvc svchost.exe                   1528 hidserv svchost.exe                   1628 Dhcp svchost.exe                   1716 Dnscache svchost.exe                   1748 EventLog WUDFHost.exe                  1792 N/A svchost.exe                   1908 TimeBrokerSvc svchost.exe                   1952 NlaSvc NVDisplay.Container.exe       1968 NVDisplay.ContainerLocalSystem svchost.exe                   1324 Themes svchost.exe                   1596 ProfSvc svchost.exe                   1944 EventSystem svchost.exe                   1052 netprofm svchost.exe                   2116 StateRepository svchost.exe                   2256 SENS svchost.exe                   2296 AudioEndpointBuilder svchost.exe                   2304 FontCache (etc)...   I know you can configure individual services to run in their own instance of svc with the sc config &lt;serviceName&gt; type= own command, but to my knowledge I've never run this command.  I took a quick look at Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services and it looks like the Type key values for most of these services is missing the flag bit at 0x10 which controls if a service runs in its own svchost.exe instance or not. I wonder what could have effected this change.  Has anyone else observed this behaviour before or after installing Windows 10 Creators Update? If it is a default configuration change, will it have any implications on system performance or stability?  I suspect it will increase system stability because if a service crashes it won't bring down other services - but this comes at a massive cost of RAM - but I've never experienced a service crashing on me - or at least ever noticed it (instead the worst problem I've had is with wuauserv consuming 100% CPU for hours on end - and that's not a problem process isolation will solve).  (I just noticed: they finally added an address bar to the Registry Editor!) How to take the gradient of the quadratic form? Creating if-else condition with ArcGIS API for JavaScript combo boxes? How do I enable the "multiverse" repository? I keep seeing places refer to the "multiverse" repository as a place I can get software, how can I enable this repository? Please specify how to do this graphically and via command line. My son is almost 3 (33 months) and for the past few months, he has been holding his poop in, to the point that he won't go for many days a time. When this started, the doctor advised us to give him Miralax to make his stool softer so it comes out more easily. Even with the Miralax, he still managed to hold it for two days at a time sometimes, but at least it was coming out at all, so we continued with it.  Anyway, we've been giving him the Miralax for months now, and now he's (supposed to be) going to preschool in September, which of course requires that he be potty trained. We don't want to hold him back since he's developmentally ready otherwise, so we started potty training a few weeks ago.  He picked up the potty training really quickly – for peeing – but he still holds his poop in no matter what. If he's sitting on the potty, as soon as he's about to do it, he stands up and just keeps holding it in (and once he starts to stand, if we even so much as ask him to sit back down, he screams and cries).  We have tried everything to convince him (or distract him enough) to sit and poop: reading books, singing songs, playing games, playing with toys, offering him snacks/treats (graham crackers), giving him stickers, etc. Nothing works.  As of today, it has been a week since the last time he pooped, with the exception of a little bit today and a little bit yesterday (both of which ended up all over the bathroom floor since he won't sit down). The doctor says now we should give him an enema to force it all to come out, but even so, that won't solve anything going forward since he still won't go in his diaper or on the potty in the first place (what are we going to do, give him an enema every week, indefinitely?).  The issue isn't that he's scared of the potty itself, since (a) he was holding it before we started potty training, and (b) he knows exactly what he's supposed to do, since he has no problem with peeing (he sits down himself, points it out afterward, knows that it gets emptied into the big potty, etc.).  It's that he just won't poop, ever – not in his diaper, not on the potty – and the only reason why anything comes out at all is because we've been giving him the Miralax every day (and even then, these aren't "full" poops, just whatever happens to come out because it's soft enough that he's unable to hold it all in).  I'm at a complete loss as to why this even started, and what if anything we can do that would actually help. Is it a behavioral problem? Medical? Both?? Help!    UPDATE: I just wanted to update this question since a lot has changed since I originally posted it. We discovered there was a specific situation where he would go in his diaper voluntarily: in our bedroom closet with the door closed. So we knew then that the withholding was intentional, since it was now established that he could go if he wanted to.  So we let him continue going in the closet and, over time, found that he usually went around the same time each day. Based on that, we then had him sit on the potty when we knew it was most likely he would need to go. We also managed to find two things that distracted him enough to sit (blowing bubbles and playing with his toy laptop).  By doing this, we were able to get him to go on the potty without really realizing it (so he didn't try to fight it), and then made a big deal out of it every time he did. Over time, that helped establish that that's what he was supposed to do, and now he does so voluntarily. He hasn't pooped in his diaper in probably 3 weeks by now.  I wouldn't say he's "fully" potty trained, in that an adult still needs to go with him and distract him (and occasionally remind him when he needs to go in general), but finally we made progress. Irrationality of $\sum_{p\in\mathbb{P}} \frac{1}{2^{p}}$ Let $\mathbb{P}$ be the set of prime numbers, and consider $m=\displaystyle\sum_{p\in\mathbb{P}} \frac{1}{2^{p}}$. Is $m$ irrational?  In the following  , the author recalls several sufficient criteria for irrationality. When applying some of this criteria to $m$ I arrive that the condition of some of the criteria are not satisfied by means of Bertrand´s Postulate.  I found a similar result by Sándor:  Let $\lbrace a_m\rbrace$, $m\geq 1$ be a sequence of positive integers such that $$\text{lim sup}\frac{a_{m+1}}{a_1a_2\cdots a_m}=\infty \;\;\;\;\text{and}\;\;\;\;\;\;\text{lim inf}\frac{a_{m+1}}{a_m}&gt;1$$ Then the series $\displaystyle\sum_{m} \frac{1}{a_m}$ is an irrational number.  I have yet to prove that if $f$ is a continuous function then $\text{lim sup} \;f(a_m)=f(\text{lim sup}\, a_m)$. Assuming this;  $$\text{lim inf}\; P_{m+1}-P_{m}&gt;1$$ where $P_m$ is the $m$-th prime.  But I have trouble with $$\text{lim sup}\; P_{m+1}-\sum_{j=1}^{m}P_{j}$$ my guess is that $$\text{lim sup}\; P_{m+1}-\sum_{j=1}^{m}P_{j}\neq\infty$$ so $$\text{lim sup}\frac{2^{P_{m+1}}}{2^{P_1}\cdots 2^{P_m}}\neq\infty$$   and this theorem will result useless to tell if $m$ is irrational.   How can I prove (or disprove) that $m$ is irrational (are there any other simpler criteria)? How can I use Dirichlet criterion  or Hurwitz criterion? What is its ?    Any help is highly appreciated.      Edit: That $m$ is irrational is clear by the criteria provided in the comments, namely that if $x$ is rational then the binary representation of $x$ is periodic. The number $m$ in binary expansion has $1$ in the $P$-th position and zero elsewhere. As there are arbitrarily large gaps between primes; then the binary representation fails to be periodic.  So the question that remains unsolved is:   What is its irrationality measure? During iPhone update to iOS 10.3.1, I was asked for my password using the correct machine name for my Mac mini. To be clear, the request was not for my iCloud password, my actual local user account password for macOS. This can also happen in the other direction - setting up a Mac may ask for verification for you to enter your iPhone / iPad passcode (and not your iCloud password)  I could not find any information about this kind of access. I was thinking it was security for iCloud and possibly related to two step authorization or two factor authorization. This is the first time I can think of that I entered a desktop password outside of that actual desktop.  I don't have a screen shot but I recall an implication that some files in my Mac are encrypted and need my password. '... need to enter the password for .'   Are there settings I can I control this assuming it's a legitimate part of iCloud setup process or iOS setup process? I have an Asus Sabertooth Z170 motherboard, with a Samsung 950 Pro m.2 NVMe drive on it. I've heard in the past that installing Windows 7 on an NVMe drive was a significant amount of work. Its now August 2016, is it still difficult? I've seen updates from Microsoft saying they've added support for NVMe in Windows 7.  Can I just download Windows 7 from Microsoft () and put it on a USB drive and install?  Is it harder than that? "Where did you buy it?" or "where did you buy it from?" When someone purchase something from somewhere and I ask him the location of purchasing, which one is the correct question:     Where did you buy it?   OR     Where did you buy it from?   Is preposition necessary to use in this question or there is no need to use it? Prove that $x^2 + y^2 = z^4$ has infinitely many solutions with $(x,y,z)=1$.   Do I use the terms $x= r^2 - s^2$, $y = 2rs$, and $z = r^2 + s^2$ to prove this problem?  Thanks for any help. I am working on Ubuntu 12.04 64bit.  I want to add "Open terminal here" to Nautilus context or right-click menu but it tries to download 32bit version from Internet. Calling Overridden Constructor and Base Constructor in C# I have two classes, Foo and Bar, that have constructors like this:  class Foo {     Foo()     {       // do some stuff     }      Foo(int arg)     {       // do some other stuff     } }  class Bar : Foo {     Bar() : base()     {       // some third thing     } }   Now I want to introduce a constructor for Bar that takes an int, but I want the stuff that happens in Bar() to run as well as the stuff from Foo(int).  Something like this:  Bar(int arg) : Bar(), base(arg) {   // some fourth thing }   Is there any way to do this in C#?  The best I have so far is putting the work done by Bar() into a function, that also gets called by Bar(int), but this is pretty inelegant. What does "All things X" mean? Failed to download repository information due to missing CDROM When updating I got this error message:  W:Failed to fetch cdrom://Ubuntu 11.10 _Oneiric Ocelot_ - Release amd64 (20111012)/dists/oneiric/main/binary-i386/Packages  Please use apt-cdrom to make this CD-ROM recognized by APT. apt-get update cannot be used to add new CD-ROMs W:Failed to fetch http://ppa.launchpad.net/synce/ubuntu/dists/your_ubuntu_version/main/source/Sources  404  Not Found   What to do? Find $|(\mathbb{Z} \oplus \mathbb{Z}) / \langle(3,6)\rangle|$ and determine if its cyclic I would like to create a reminder on Google Calendar every month on the 15th, but if the 15th in that month is a Friday/Saturday, I want it automatically to set it to the closest Sunday/Thursday. Is this possible? I'm having problems understanding the following situation. Suppose two 1-tonne cars are going with the same orientations but opposite senses, each 50 km/h with respect to the road. Then the total energy is   $$\begin{eqnarray}E=E_1+E_2&amp;=&amp;\frac{1\mathrm t\times(50\mathrm{km}/\mathrm h)^2}2+\frac{1\mathrm t\times(50\mathrm{km}/\mathrm h)^2}2\\&amp;=&amp;1\mathrm t\times(50\mathrm{km}/\mathrm h)^2\\&amp;=&amp;2500\frac{\mathrm t\times\mathrm{km}^2}{\mathrm h^2}.\end{eqnarray}$$  Now if we look at it from the point of view of one of the cars, then the total energy is   $$\begin{eqnarray}E=E_1+E_2&amp;=&amp;\frac{1\mathrm t\times(0\mathrm{km}/\mathrm h)^2}2+\frac{1\mathrm t\times(100\mathrm{km}/\mathrm h)^2}2\\&amp;=&amp;\frac{1\mathrm t\times(100\mathrm{km}/\mathrm h)^2}2\\&amp;=&amp;5000\frac{\mathrm t\times\mathrm{km}^2}{\mathrm h^2}.\end{eqnarray}.$$  I know that kinetic energy is supposed to change when I change the frame of reference. But I understand that then there must be some other kind of energy to make up for it so that the energy in the system stays unchanged. But I don't see any other kind of energy here. I only see two total energies of the same system that seem to be different. Could you explain this to me?  Please note that while I don't understand any physics, I do understand college level mathematics, so if necessary please use it. (I doubt anything more than high school maths should be needed here, but I want to say this just in case.) The Bash Manual says   { list; }        Placing a list of commands between curly braces causes the list to be executed in the current shell context. No subshell is   created. The semicolon (or newline) following list is required.      The braces are reserved words, so they must be separated from the list   by blanks or other shell metacharacters.       The parentheses are operators, and are recognized as separate tokens   by the shell even if they are not separated from the list by   whitespace.   If I remove the semicolon, like this:  $ { date } &gt;    Why does it expect stdin input? A metacharacter is a character that separates words.  The semicolon and whitespace are both "shell metacharacters". Why can't whitespace separate words date and }? Why do we need a semicolon instead of a whitespace for separating the words?