If I have a DB table called FAVORITE_FLAVOR where each row has a user's favorite flavor of ice cream.  User ID | Flavor      | State 1       | Chocolate   | CA 2       | Vanilla     | ND 3       |   Chocolate | CA 4       | Rocky Road  | CA 5       | vanilla     | CA 6       | Vanilla     | CA 7       | Vanilla     | CA   Now, if I want to query the 2 most popular flavors in each state (normalizing capitalization and whitespace), I could query:  SELECT state, INITCAP(TRIM(flavor)), count(INITCAP(TRIM(flavor))) AS total FROM favorite_flavor GROUP BY state, INITCAP(TRIM(flavor)) ORDER BY state ASC, total DESC;   Which returns:  CA | Vanilla    | 3 CA | Chocolate  | 2 CA | Rocky Road | 1 ND | Vanilla    | 1   Now, I only wanted to know the top 2 flavors per state. How do I limit the query so that Rocky Road is no longer listed.
How would I be able to get N results for several groups in an oracle query.  For example, given the following table:  |--------+------------+------------| | emp_id | name       | occupation | |--------+------------+------------| |      1 | John Smith | Accountant | |      2 | Jane Doe   | Engineer   | |      3 | Jack Black | Funnyman   | |--------+------------+------------|   There are many more rows with more occupations.  I would like to get three employees (lets say) from each occupation.  Is there a way to do this without using a subquery?
How can I make Windows Paint save by default as JPEG format? Every time I want to save an image I've pasted into the  application, it chooses a BMP/DIB format (which is the worst for saving things from the clipboard).  How can I hack Paint into defaulting to the JPEG format when saving images?  I am using Windows XP SP3 and Paint 5.1 at the moment. I hope though that any hacks might be generic and I'd be able to use them across all my Windows machines. I have a stupid self-answered question. Should I accept my own answer? was genuine at the time, but I realised that  gave the right advice, but required me to restart my Linux (which wasn't mentioned in the solution).  It's a bit of a  question and  points to me not deleting it.  But it seems hugely self-aggrandizing to accept my own answer. Should I? How to find the magnetic field due to a revolving electron of hydrogen atom in first orbit Suppose $G$ is a non-abelian group and $H,K$ are two abelian subgroups of $G$. Then must $HK$ be an abelian subgroup of $G$?  I know an example, but I am confused. Thus I just want to check that. Drawing different tikz shapes parameterized by data from a file I have a file with three columns of data, x, y, r.  # x y r 1 1 0.1 2 2 0.5 3 3 1.2   and so on. I'd like to loop over the rows, and draw a circle at x,y with radius r for each row.  I first thought I'd use pgfplots with customized marks, but I couldn't figure out how to pass the radius parameter into the pgfplot mark handler. Then I thought I'd use tikz and pgf directly, but I couldn't figure out how to reference the values for r inside a draw command sequence.   Any thoughts ? I'd be very grateful for some help. Why do you have to use copy_to_user()/copy_from_user() to access user space from the kernel? Viewing computer screen through 3D glasses, why the asymmetry? I have 3D glasses made up of plastic.  First case: When I hold front side of the 3D glasses (by this I mean that side on which light falls) in front of a computer screen, light coming from screen is not blocked, at any angle of rotation. But I see somewhat (slightly) bluish screen when 3D glasses are held horizontally; and yellowish (slightly) screen when glasses are held vertically.  Second case: Now I flip the side of the glasses i.e. "back" side of glasses is in front of screen and "front" side is closer to eyes. In this second case, when glasses are held horizontally, the light is blocked. When glasses are held vertically, light is not blocked; I can see the screen. For intermediate angle, intensity of light varies from minimum to maximum.  Questions:   Why I get slightly colored screens in the first case and why light is not blocked ? Why light is blocked in the second case ?   I know (after reading somewhere) that glasses consists of a pair of circular polarizer and linear polarizer. Circular polarizer in my first case will be near to computer screen and linear polarizer will be near to eyes; and in second case vice versa. Eevee - Light inside a bulb lamp not passing through glass Using Eevee, I'm trying to simulate a light bulb. I have a sphere with glass material and inside it, I have a Point light. But the light is not passing through the glass:  However, if I disable the sphere object, the light is working:   How to make the light inside a bulb lamp pass through glass (using Eevee)? Here my test project: Explain $\iint \mathrm dx\,\mathrm dy = \iint r \,\mathrm \,d\alpha\,\mathrm dr$ Column and row padding in tables How do you guys go about controlling column padding in tables?   Update  To clarify, I'm looking for a way to control both vertical and horizontal padding. So, if I had a simple table like in the following code snippet, I could pad the columns and make them look a bit less... ugly. :P   \begin{tabular}{|l|l|}     \hline     column 1 &amp; column 2 \\      \hline     I really would like this less &amp; crammed\\     \hline \end{tabular}   I tried this by using the command \vspace but it leaves gaps in the vertical lines. How to get dialog box input directed to a variable? I have been teaching myself bash scripting and have run into an issue. I have written a script to take input from the user, using the 'read' command, and make that input a variable to use later in the script. The script works, but....  I would like to be able to get it setup using 'dialog'. I found out that  'dialog --inputbox' will direct the output to 'stderr' and in order to get that input as a variable you have to direct it to a file and then retrieve it. The code I found to explain this is:  #!/bin/bash dialog --inputbox \  "What is your username?" 0 0 2&gt; /tmp/inputbox.tmp.$$  retval=$?  input=`cat /tmp/inputbox.tmp.$$`  rm -f /tmp/inputbox.tmp.$$  case $retval in 0)  echo "Your username is '$input'";; 1)  echo "Cancel pressed.";;  esac   I see that it is sending the sdterr to the /tmp/inputbox.tmp.$$ with 2>, but the output file looks like 'inputbox.tmp.21661'. When I try and cat the file it gives me an error. So I am still unable to get the user input from the --inputbox as a variable.   Example Script:   echo "  What app would you like to remove? "  read dead_app  sudo apt-get remove --purge $dead_app   So as you can see it is a basic script. Is it even possible to get the variable as a word from dialog --inputbox? How to use exclamation marks in Minecraft commands? Why do function pointers all have the same value? I gave my friend  as a brainteaser; while her attempted solution didn't work, it raised an interesting question.  I flip a fair coin repeatedly and record the results.  I stop as soon as the number of heads is equal to twice the number of tails (for example, I will stop after seeing HHT or THTHHH or TTTHHHHHH).  What's the probability that I never stop?  I've tried to just compute the answer directly, but the terms got ugly pretty quickly.  I'm hoping for a hint towards a slick solution, but I will keep trying to brute force an answer in the meantime. Where can I have a genuine Ainu cultural experience in Hokkaido? During my next trip to Japan I may end up in Hokkaido. I've read something about this mysterious indigenous group called Ainu/Aynu/Aino/Ezo, but I must admit my understanding of the whole thing is rather limited right now.   What I wish to know is: is there such a thing like an authentic Ainu village/town/whole-region where Ainu people live according to their tradition, as opposed to something staged for tourists?  Edit: given the comments below I wish to specify better what I mean with the word 'authentic'. Of course, I don't expect pristine landscapes and Ainu people living in blissful harmony with fluffy penguins (semi-quote) but I won't be surprised to find out there still are authentic villages in remote areas of Hokkaido where mass tourism is not an issue at all.  People are subject to tourist's attention (tourist coming from different countries, at least) everywhere, not only when they "made a conscious decision to live a traditional life". This doesn't actually mean anything. Indian people are surprisingly differents (in local customs) from Italians and Italians take a lot of pictures during their travels there, still the tourism isn't banned in India. What is the preferred way to remove spaces from a string in C++? I could loop through all the characters and build a new string, but is there a better way? Where can I buy an Ubuntu Phone? I need to buy an Ubuntu phone, where can I buy it? It is unavailable everywhere. The words in the node of tree I want to plot this graph, but I don't know how to code the words in the nodes.     Here is my code:  \documentclass{article} \usepackage{amsmath} \usepackage{titletoc} \usepackage{tikz} \usetikzlibrary{trees,positioning,fit}  \begin{document}{\allowdisplaybreaks[4]}  \tikzstyle{bag} = [text width=2em, text centered] \tikzstyle{end} = []  \begin{center} \begin{tikzpicture}[sloped] \node (a) at ( 0,0) [bag] {$\ln r_0$}; \node (b1) at ( 3,1.5) [bag] {$\ln r_{10} + \sigma_1\sqrt{\Delta t_1}$}; \node (b2) at ( 3,-1.5) [bag] {$\ln r_{10}$}; \node (c1) at ( 6,3) [bag] {$\ln r_{20} + 2\sigma_2\sqrt{\Delta t_2}$}; \node (c2) at ( 6,1.5) [bag] {$\textrm{Mean} = \ln r_{20} + \dfrac{3}{2}\sigma_2\sqrt{\Delta t_2}$\\$\textrm{Mean Change} = \mu_{11}\Delta t_2 = \ln\dfrac{r_{20}}{r_{10}} + \dfrac{3}{2}\sigma_2\sqrt{\Delta t_2} - \sigma_1\sqrt{\Delta t_1}$}; \node (c3) at ( 6,0) [bag] {$\ln r_{20} + \sigma_2\sqrt{\Delta t_2}$}; \node (c4) at ( 6,-1.5) [bag] {$\textrm{Mean} = \ln r_{20} + \dfrac{3}{2}\sigma_2\sqrt{\Delta t_2}$\\$\textrm{Mean Change} = \mu_{11}\Delta t_2 = \ln\dfrac{r_{20}}{r_{10}} + \dfrac{3}{2}\sigma_2\sqrt{\Delta t_2} - \sigma_1\sqrt{\Delta t_1}$}; \node (c5) at ( 6,-3) [bag] {$\ln r_{20}$}; \draw [-&gt;] (a) to node [below] {} (b1); \draw [-&gt;] (a) to node [above] {} (b2); \draw [-&gt;] (b1) to node [below] {} (c1); \draw [-&gt;] (b1) to node [below] {} (c2); \draw [-&gt;] (b1) to node [below] {} (c3); \draw [-&gt;] (b2) to node [below] {} (c3); \draw [-&gt;] (b2) to node [below] {} (c4); \draw [-&gt;] (b2) to node [below] {} (c5); \end{tikzpicture} \end{center}  \end{document}       Update code use  \draw [-&gt;] (a) to node [below] {} (b1.south east); \draw [-&gt;] (a) to node [above] {} (b2.north east); \draw [-&gt;] (b1.south east) to node [below] {} (c1.west); \draw [-&gt;] (b1.south east) to node [below] {} (c2.west); \draw [-&gt;] (b1.south east) to node [below] {} (c3.west); \draw [-&gt;] (b2.north east) to node [below] {} (c3.west); \draw [-&gt;] (b2.north east) to node [below] {} (c4.west); \draw [-&gt;] (b2.north east) to node [below] {} (c5.west); What determines color -- wavelength or frequency? What determines the color of light -- is it the wavelength of the light or the frequency?  (i.e. If you put light through a medium other than air, in order to keep its color the same, which one would you need to keep constant: the wavelength or the frequency?) Using WCS layer in QGIS for processing gives FAILURE: Missing destination I have a GeoServer serving raster dem data out via WCS and can add the layer easily to QGIS (3.2) but when I try to use it as the input for an operation (e.g. HillShade) I get an error.  Processing algorithm… Algorithm 'Hillshade' starting… Input parameters: { 'ALTITUDE' : 45, 'AZIMUTH' : 315, 'BAND' : 1, 'COMBINED' : False, 'COMPUTE_EDGES' : False, 'INPUT' : 'dpiMode=7&amp;identifier=training:panorama&amp;url=http://localhost:8080/geoserver/ows?version%3D1.1.1', 'MULTIDIRECTIONAL' : False, 'OPTIONS' : '', 'OUTPUT' : 'C:/Users/ishare/AppData/Local/Temp/2/processing_868cc25180f24d9f8e193bc0cfedb6d3/7cf48f64d8b54ee694c3ee93ed17e903/OUTPUT.tif', 'SCALE' : 1, 'ZEVENBERGEN' : False, 'Z_FACTOR' : 5 }  GDAL command: gdaldem hillshade dpiMode=7&amp;identifier=training:panorama&amp;url=http://localhost:8080/geoserver/ows?version%3D1.1.1 C:/Users/ishare/AppData/Local/Temp/2/processing_868cc25180f24d9f8e193bc0cfedb6d3/7cf48f64d8b54ee694c3ee93ed17e903/OUTPUT.tif -of GTiff -b 1 -z 5.0 -s 1.0 -az 315.0 -alt 45.0 GDAL command output:   FAILURE: Missing destination.   Clearly the missing destination is a red herring, and it is failing to understand the WCS layer as an input. But GDAL is built with WCS support included so shouldn't this work?  Do I need to do something else or start working out where to hack the QGIS code?