Solution required on Microsoft SQL Server.  Here is a example of a table I have:  --------------------------------------------------------------------- | Currency Code | Starting Date           | Exchange Rate Amount    | --------------------------------------------------------------------- | CZK           | 2014-09-10 00:00:00.000 | 27.64000000000000000000 | | EUR           | 2015-09-01 00:00:00.000 | 1.17570000000000000000  | | CZK           | 2015-07-30 00:00:00.000 | 28.29840000000000000000 | | PLN           | 2015-06-16 00:00:00.000 | 5.35640000000000000000  | | EUR           | 2016-09-01 00:00:00.000 | 1.17090000000000000000  | | PLN           | 2015-07-30 00:00:00.000 | 5.49070000000000000000  | ---------------------------------------------------------------------   I would like to return the last entry for each [Currency Code] in a single table like so:  --------------------------------------------------------------------- | Currency Code | Starting Date           | Exchange Rate Amount    | --------------------------------------------------------------------- | CZK           | 2015-07-30 00:00:00.000 | 28.29840000000000000000 | | EUR           | 2016-09-01 00:00:00.000 | 1.17090000000000000000  | | PLN           | 2015-07-30 00:00:00.000 | 5.49070000000000000000  | ---------------------------------------------------------------------   I can do it individually like this  SELECT TOP 1 [Currency Code] AS Currency, CONVERT(varchar, [Starting Date], 103) AS Date, CAST([Exchange Rate Amount] AS DECIMAL(8,3)) AS Rate FROM myTable WHERE [Currency Code] = 'EUR' ORDER BY [Starting Date] DESC   This returns the following:  --------------------------------- | Currency | Date       | Rate  | --------------------------------- | EUR      | 01/09/2016 | 1.171 | ---------------------------------   However, I would like the last entry for each currency listed in a single table.
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.
Should I let potential employers know I have a job offer? I've interviewed for a few positions, one of which has made me an offer.  I'm very pleased with the offer, but I prefer some of the other positions.  I have the luxury of being able to take a lot of time to decide whether or not I accept this offer, so I'm certain I will hear back (either positively or negatively) from the other positions before a decision is required for the offer I've received.  I'm trying to decide between two courses of action, and I want to choose the one that will best help my candidacy with the positions I've yet to hear from.  Plan 1 is to do nothing and simply wait to hear back from the other positions for which I've already interviewed.  Plan 2 is to be in touch with the other positions to let them know I have an offer, and ask where I stand with them.  Would Plan 2 make me a more desirable candidate with the other positions, as they might see my offer as further validation of my credentials?  Or, might initiating with the interviewers in this way be detrimental to my candidacy, perhaps making me seem pushy or self-centered?  If so, I would rather just wait for them to run their course of action (Plan 1).  As I've said, I have plenty of time, so I don't want impatience to hurt me.  If there is a good chance that my meddling will be detrimental, then I'd rather be hands-off here.  However, if it's more likely that informing the other interviewers of my offer will give me a boost, then I'd want to do so.  Thanks for any clarity you can provide!  Edit: For a bit more information and context, the position I've been offered is a non-academic research position that my advisor has described as "prestigious."  The other positions for which I've interviewed (and which I prefer) are mostly academic teaching-centered positions (visiting assistant professors, tenure-track at smaller four year institutions). what operation repeated $n$ times results in the addition operator? Suppose I wanted to travel to one of the recently discovered potentially Earth-like planets such as Kepler 186f that is 490 light years away. Assuming I had a powerful rocket and enough fuel, how long would it take me? Is it possible to play D&D 5e solo? I'm using a docker image as a base for my own development that adds the jessie backports repository in its Dockerfile and uses that to install a dependency. This image uses the following command to add the repository:  echo "deb http://ftp.debian.org/debian jessie-backports main" &gt;&gt; /etc/apt/sources.list   The problem is that fetching packages from the backports repository now  fails with the following error (this used to work previously):  W: Failed to fetch http://ftp.debian.org/debian/dists/jessie-backports/main/binary-amd64/Packages 404  Not Found  W: Failed to fetch http://deb.debian.org/debian/dists/jessie-updates/main/binary-amd64/Packages  404  Not Found   I looked on that server, and those paths are indeed not present there.  I tried to figure out on the Debian backports site whether this particular repository should still be available, and I didn't find any indication that this was deprecated or something like that.  Is this a temporary issue with the repository, or is the jessie-backports repository not available anymore? And if this is not a temporary issue, what options do I have to use this or an equivalent repository without upgrading to the newer Debian stable version? Can a self-complementary graph on 100 vertices have precisely one vertex of degree 50? SOAP or REST for Web Services? Does there currently exist a free online service that accepts a file, hashes it, takes an authoritatively chosen timestamp (from one or more time services), signs these and sends this signed message back? E.g. a digital notary, but only with regards to the timestamp and not the validity of the content as legal notaries might be obligated to guarantee.  Such a service might have an extremely simple API: Simply wget http://service/&lt;checksum&gt; and receive a signed message containing one or more timestamps and the checksum. The emphasis would be on the type of authority who might make such a service.  Edit: Although the original question did not emphasise the following, the Bitcoin-based timestamping services provided below do not rely on one authority, but rather the entire Bitcoin network. They can be seen as tamper-proof and verifiable without the help of the service that helped you sign it! How can I launch screensaver with a keyboard shortcut? In the  question one of the answers had the following code snippet:  IEnumerable&lt;object&gt; FilteredList() {     foreach(object item in FullList)     {         if(IsItemInPartialList(item))             yield return item;     } }   What does the yield keyword do there?  I've seen it referenced in a couple places, and one other question, but I haven't quite figured out what it actually does.  I'm used to thinking of yield in the sense of one thread yielding to another, but that doesn't seem relevant here. Value of $\lim_{n\to \infty}\frac{1^n+2^n+\cdots+(n-1)^n}{n^n}$ I remember that a couple of years ago a friend showed me and some other people the following expression:  $$\lim_{n\to \infty}\frac{1^n+2^n+\cdots+(n-1)^n}{n^n}.$$  As shown below, I can prove that this limit exists by the monotone convergence theorem. I also remember that my friend gave a very dubious "proof" that the value of the limit is $\frac{1}{e-1}$. I cannot remember the details of the proof, but I am fairly certain that it made the common error of treating $n$ as a variable in some places at some times and as a constant in other places at other times. Nevertheless, numerical analysis suggests that the value my friend gave was correct, even if his methods were flawed. My question is then:  What is the value of this limit and how do we prove it rigorously?  (Also, for bonus points, What might my friend's original proof have been and what exactly was his error, if any?)  I give my convergence proof below in two parts. In both parts, I define the sequence $a_n$ by $a_n=\frac{1^n+2^n+\cdots+(n-1)^n}{n^n}$ for all integers $n\ge 2$. First, I prove that $a_n$ is bounded above by $1$. Second, I prove that $a_n$ is increasing.   (1) The sequence $a_n$ satisfies $a_n&lt;1$ for all $n\ge 2$.  Note that $a_n&lt;1$ is equivalent to $1^n+2^n+\cdots+(n-1)^n&lt;n^n$. I prove this second statement by induction. Observe that $1^2=1&lt;4=2^2$. Now suppose that $1^n+2^n+\cdots+(n-1)^n&lt;n^n$ for some integer $n\ge 2$. Then  $$1^{n+1}+2^{n+1}+\cdots+(n-1)^{n+1}+n^{n+1}\le(n-1)(1^n+2^n+\cdots+(n-1)^n)+n^{n+1}&lt;(n-1)n^n+n^{n+1}&lt;(n+1)n^n+n^{n+1}\le n^{n+1}+(n+1)n^n+\binom{n+1}{2}n^{n-1}+\cdots+1=(n+1)^{n+1}.$$  (2) The sequence $a_n$ is increasing for all $n\ge 2$.  We must first prove the following preliminary proposition. (I'm not sure if "lemma" is appropriate for this.)  (2a) For all integers $n\ge 2$ and $2\le k\le n$, $\left(\frac{k-1}{k}\right)^n\le\left(\frac{k}{k+1}\right)^{n+1}$.  We observe that $k^2-1\le kn$, so upon division by $k(k^2-1)$, we get $\frac{1}{k}\le\frac{n}{k^2-1}$. By , we may find:  $$\frac{k+1}{k}\le 1+\frac{n}{k^2-1}\le\left(1+\frac{1}{k^2-1}\right)^n=\left(\frac{k^2}{k^2-1}\right)^n.$$  A little multiplication and we arrive at $\left(\frac{k-1}{k}\right)^n\le\left(\frac{k}{k+1}\right)^{n+1}$.  We may now first apply this to see that $\left(\frac{n-1}{n}\right)^n\le\left(\frac{n}{n+1}\right)^{n+1}$. Then we suppose that for some integer $2\le k\le n$, we have $\left(\frac{k}{n}\right)^n\le\left(\frac{k+1}{n+1}\right)^{n+1}$. Then:  $$\left(\frac{k-1}{n}\right)^n=\left(\frac{k}{n}\right)^n\left(\frac{k-1}{k}\right)^n\le\left(\frac{k+1}{n+1}\right)^{n+1}\left(\frac{k}{k+1}\right)^{n+1}=\left(\frac{k}{n+1}\right)^{n+1}.$$  By backwards (finite) induction from $n$, we have that $\left(\frac{k}{n}\right)^n\le\left(\frac{k+1}{n+1}\right)^{n+1}$ for all integers $1\le k\le n$, so:  $$a_n=\left(\frac{1}{n}\right)^n+\left(\frac{2}{n}\right)^n+\cdots+\left(\frac{n-1}{n}\right)^n\le\left(\frac{2}{n+1}\right)^{n+1}+\left(\frac{3}{n+1}\right)^{n+1}+\cdots+\left(\frac{n}{n+1}\right)^{n+1}&lt;\left(\frac{1}{n+1}\right)^{n+1}+\left(\frac{2}{n+1}\right)^{n+1}+\left(\frac{3}{n+1}\right)^{n+1}+\cdots+\left(\frac{n}{n+1}\right)^{n+1}=a_{n+1}.$$  (In fact, this proves that $a_n$ is strictly increasing.) By the monotone convergence theorem, $a_n$ converges.  I should note that I am not especially well-practiced in proving these sorts of inequalities, so I may have given a significantly more complicated proof than necessary. If this is the case, feel free to explain in a comment or in your answer. I'd love to get a better grip on these inequalities in addition to finding out what the limit is.  Thanks! for working with MS word files in python, there is python win32 extensions, which can be used in windows. How do I do the same in linux? Is there any library? Reference for creative set criterion theorem Smallest dense subset of $\mathbb{R}$ I am not sure if what I am looking for even makes sense (or) exists. Anyway I would be happy if someone can clear my confusion.  The set of real numbers $\mathbb{R}$ is obtained as completion of $\mathbb{Q}$. However, $\mathbb{Q}$ is not the only set which is dense in $\mathbb{R}$. $\mathbb{Q} \backslash \mathbb{Z}$ is also a dense subset of $\mathbb{R}$. I am wondering if it makes sense to talk of the "smallest" dense subset of $\mathbb{R}$. To phrase what I am looking for precisely and what I mean by smallest, I am looking for a dense set $A$ of $\mathbb{R}$ such that if $B$ is a proper subset of $A$ then $B$ is not dense in $\mathbb{R}$. I am able to "see" that the set $A$, I am looking for doesn't exist since any open interval consists of infinite rationals. But I am unable to precisely argue out to myself and convince why $A$ doesn't exist. Could some one throw more light on this? Are split infinitives grammatically incorrect, or are they valid constructs? Integrate $\int_0^{\pi/2} \frac{1}{1+\tan^\alpha{x}}\,\mathrm{d}x$ Evaluate the integral $$\int_0^{\pi/2} \frac{1}{1+\tan^\alpha{x}}\,\mathrm{d}x$$ Is it true that: $a+bi$ is prime in $\mathbb{Z}[i]$ if and only if $a^2+b^2$ is prime in $\mathbb{Z}$ How can I move Steam games to another disk? I love apples. I like to eat them with skin as it has plenty of fiber in the skin. But apples are famous for wax and pesticides on the skin which I don’t want to ingest. I have read many articles on the web and suggestions for removing the wax from the surface.   These suggestions include soaking in vinegar or hot water and other methods. They suggest that soaking apples in vinegar removes the wax that can be seen in the vinegar. I have done that, but never seen any residue of wax in the vinegar.   So I have set aside a new kitchen sink Scotch-Brite scrubber for this purpose and been scrubbing the apple skin under running water before eating. I think this method should remove most of the wax and pesticides. I would like to hear your input. I have been texture painting in look dev mode. But when i try to render it, everything looks very dark. I have 3 sun lights in my scene, ambient turned on in Eevee settings. What am i missing? I really like the look of my scene in Look Dev mode, how can i achieve the same look when my scene is rendered too?