How to select top 10 records from each category I have a table with fields  Hour, PathId, Duration, Event, CellId, Channel   I have 50+ CellId. Each CellId has four PathId (i.e. 0, 1, 2, 3). Each PathId has many Events and Durations. Now I want to display the top 10 records (each PathId) for each CellId.  Sample Table    Sample Output
Retrieving n rows per group I often need to select a number of rows from each group in a result set.  For example, I might want to list the 'n' highest or lowest recent order values per customer.  In more complex cases, the number of rows to list might vary per group (defined by an attribute of the grouping/parent record). This part is definitely optional/for extra credit and not intended to dissuade people from answering.  What are the main options for solving these types of problems in SQL Server 2005 and later? What are the main advantages and disadvantages of each method?  AdventureWorks examples (for clarity, optional)   List the five most recent recent transaction dates and IDs from the TransactionHistory table, for each product that starts with a letter from M to R inclusive. Same again, but with n history lines per product, where n is five times the DaysToManufacture Product attribute. Same, for the special case where exactly one history line per product is required (the single most recent entry by TransactionDate, tie-break on TransactionID.
If $x_1,...,x_n$ are positive real numbers and if $y_k=1/x_k$, prove that $$\left(\sum^n_{k=1}x_k\right)\left(\sum^n_{k=1}y_k\right)\geq n^2.$$   I've been learning induction, and I've come across this problem that I really can't even break down and begin to think about. I've been told it has something to do with Cauchy-Schwarz, but I cannot figure out how to apply it. I would appreciate help figuring out how to go about and formulate this proof. Thanks! How to shrink Windows 7 boot partition with unmovable files I have just bought an HP laptop with Windows&nbsp;7 (64 bit). It has a 500&nbsp;GB HDD with three partitions: a small hidden system partition, a 12&nbsp;GiB HP recovery partition, and a 450&nbsp;GiB C: boot partition.  I would like to split this large C: partition into two partitions, leaving only 100&nbsp;GiB for the system, and giving the rest to a new data partition.  Although the Windows built-in Disk Management utility has an option to shrink the bootable partition, it only allows me to shrink it roughly by half, even though only 20&nbsp;GiB on the partition is used. As far as I understand, system unmovable files lie in the middle of the partition, preventing Disk Management utility to do what I want.    And since new HP laptops don't come with OS installation disks (they only allow you to create recovery disks yourself), I can't just repartition HDD and then reinstall OS.  So, is there a way to shrink the C: bootable partition and preserve Windows&nbsp;7 working?  P.S.: I have tried to use the third-party  utility, and after shrinking the partition, Windows&nbsp;7 stopped booting, with a . System recovery didn't work, and I had to do factory recover. Since this is a long process, I would like to avoid doing it again :) So, please, suggest only proven solutions. Go to  Add a few photos to a photo album Go back to All Photos   See all of the photos there, even ones you copied to the Album. No problem here, per se. At least not yet.  What if you want to delete photos that you did not copy to that album?  Where is the selector or filter that filters those "in an album already" photos from this main view?  Or is there a way to create such a filtered view such that I can then cherry-pick photos for deletion? Consider the curve $\frac{1}{x}$  where $x \geq 1$. Rotate this curve around the x-axis.   One Dimension - Clearly this structure is infinitely long.  Two Dimensions - Surface Area = $2\pi\int_∞^1\frac{1}{x}dx = 2\pi(\ln ∞ - \ln 1) = ∞$   Three Dimensions -  Volume = $\pi\int_∞^1{x}^{-2}dx = \pi(-\frac{1}{∞} + \frac{1}{1}) = \pi$   So this structure has infinite length and infinite surface area. However it has finite volume, which just does not make sense.  Even more interesting, the "walls" of this structure are infinitely thin. Since the volume is finite, we could fill this structure with a finite amount of paint. To fill the structure the paint would need to cover the complete surface area of the inside of this structure. Since the "walls" are infinitely thin, why would a finite amount of paint not be able to cover the outside of the "walls" too?  Please help me make sense of this whole thing. How should I deal with becoming discouraged as a graduate student? My colleague is using an application that consumes a lot of memory which makes the system too slow. Is it possible to share memory with other PCs over the Internet?   The system has 8 GB of RAM, and the application consumes more than 6 GB. Suppose that $f(z)$ is analytic function in the disk $|z|\le R$ and $A(r)=\max_{|z|=r}Re(z)$ then prove that $r&lt;R$  $$\max_{|z|=r}\left|\frac{f^n(z)}{n!}\right|\le \frac{2^{n+2}R}{(R-r)^{n+1}}\{A(r)+|f(0)|\}$$  MY attempt   Using Cauchy generalized integral formula   $f^{(n)}(z_0)=\frac{n!}{2\pi i}\int _c\frac{f(z)dz}{(z-z_0)^{n+1}}$  then $\max_{|z|=r}\left|\frac{f^n(z)}{n!}\right|=\left|\max_{|z|=r} \frac{1}{2\pi i}\int _c\frac{f(z)dz}{(z-z_0)^{n+1}}\right|$  and i think we can solve by using Borel caratheodory theorem  Let $f(z)$ be holomorphic function on $|z|\le R$ and let $M(r)=\max_{|z|=r}|f(z)|$ and $A(r)=\max_{|z|=r}Re f(z)$ then  for $0&lt;r&lt;R$  $$ M(r)\le \frac{2r}{R-r}A(R)+\frac{R+r}{R-r}|f(0)|$$  from here how to processed ? How to repeat a string a variable number of times in C++? I want to insert 'n' spaces (or any string) at the beginning of a string in C++. Is there any direct way to do this using either std::strings or char* strings?  E.g. in Python you could simply do  &gt;&gt;&gt; "." * 5 + "lolcat" '.....lolcat' Avoiding the second leg of an international flight - different rates for a return ticket? Possible Duplicate:          I am in the process of booking a flight from LAX - ZUR. I found a flight for approx. 1100 USD. However, if I book that flight and then continue, after a 5 hour layover, onward to SVO, The flight is approx. half of the initial price, and the first leg of the second flight is the exact same flight as the first booking. Assuming I travel light and do not check any baggage, are there any potential issues with this? Seems like a hell of a way to save a good chunk of change. How do I find the address of last non-blank cell in a row (while skipping columns) LED light needs replacing every few weeks I have two GU5.3 bulbs in my bathroom - one of them went off a month or so ago so I bought the following 3 pack:   I've gone through 2 of the new bulbs in the space of weeks. I have never seen the bulbs fade out while being on, it's only when we turn the light switch on that they don't come back on (like this morning, I was first in the bathroom and the bulb was off again). No fuses blown or any indication of tripping.  How should I approach this? Finding a conformal map from the intersection of two disks to the unit disk. How to get Intel Dual Band Wireless-AC 3168 work on Ubuntu 16.04? I searched many solutions on this site but most of them were referring to Broadcom Wifi drivers while mine has Intel one.   Output of lspci -knn | grep Net -A2  arijit@HP-AU134TX:~$ lspci -knn | grep Net -A2  05:00.0 Network controller [0280]: Intel Corporation Device [8086:24fb] (rev 10) DeviceName: Intel Dual BandWireless-AC 3168 802.11 ac 1x1 WiFi + BT 4.0 Combo Adapter Subsystem: Intel Corporation Device [8086:2110]   Output of rfkill list  arijit@HP-AU134TX:~$ rfkill list  arijit@HP-AU134TX:~$    i.e No Output  Output of uname -a; dmesg | grep iwl  arijit@HP-AU134TX:~$ uname -a; dmesg | grep iwl  Linux HP-AU134TX 4.4.0-31-generic #50-Ubuntu SMP Wed Jul 13 00:07:12 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux How do I transition to SSL without affecting PageRank? Unintentional Lies and Misinformation Do the predictions of a Random Forest model have a prediction interval? I want to print the floating point number with exactly two significant digits in bash (maybe using a common tool like awk, bc, dc, perl etc.).  Examples:   76543 should be printed as 76000 0.0076543 should be printed as 0.0076   In both cases the significant digits are 7 and 6. I have read some answers for similar problems like:      but the answers focus on limiting the number of decimal places (eg. bc command with scale=2 or printf command with %.2f) instead of significant digits.  Is there an easy way to format the number with exactly 2 significant digits or do I have to write my own function? How can I calculate the angle and proper turn direction between two 2D vectors? I am working on some movement AI where there are no obstacles and movement is restricted to the XY plane. I am calculating two vectors, v, the facing direction of ship 1, and w, the vector pointing from the position of ship 1 to ship 2.  I am then calculating the angle between these two vectors using the formula  arccos((v · w) / (|v| · |w|))   The problem I'm having is that arccos only returns values between 0° and 180°.  This makes it impossible to determine whether I should turn left or right to face the other ship.  Is there a better way to do this? Workaround for Android 4.4 not being able to write to SD cards? Yesterday I upgraded my Samsung Galaxy S4 to Android 4.4 KitKat and had the bad surprise that it cannot write to my SD card anymore... I know this problem is widely documented everywhere, but has any workaround been found for it yet? (Other than removing the card physically from the phone and opening it on my PC) Also, because of the KNOX flag I can't downgrade to 4.3...  (PS: Rooted or not, it makes no difference) I am posting this question just to get a better understanding of the questions that can be asked on Stack Overflow.  I find that  can several answers based on users opinion and cause a discussion.  Why is this a good question when several other requests for books and tutorials are not acceptable?