I have DDL like the below, which returns data like such:  GP17    GP16 0       103 90      0 375     0   I am wanting to pivot the data somehow so that it returns only one row, like such:  Jan 17 ---- Jan 16 ---- Feb 17 ---- Feb 16 ---- Mar 17 ---- Mar 16 0            103         90          0           375         0      Now this is relevant to the date range being passed in below, for example, if the date range being passed in is 20170401  20170630 then I would want the dates to read Apr 17, Apr 16, May 17, May 16, Jun 17, Jun 16  How can this be achieved with SQL Server 2008 R2 and the DDL below?  Declare @Test Table (     dname varchar(100)     ,tr float     ,dc float     ,sdate date )   Insert Into @Test (dname, tr, dc, sdate) Values ('Green', 100.00, 10.00, '20170101'), ('Green', 200.00, 15.00, '20170201'), ('Green', 200.00, 10.00, '20170215') ,('Green', 10.00, 0.00, '20160101'), ('Green', 15.00, 10.00, '20160130'), ('Green', 110.00, 22.00, '20160101')  Declare @startdate date = '20170101', @enddate date = '20170331'  SELECT  ROUND(SUM(ISNULL(tr17,0))-SUM(ISNULL(DC17,0)),0) As GP17, ROUND(SUM(ISNULL(tr16,0))-SUM(ISNULL(DC16,0)),0) As GP16 FROM ( SELECT ZT1.dname, SUM(ISNULL(ZT1.tr,0)) AS tr17, 0 As DC17, 0 As DC16, 0 AS tr16, sdate As activityDate FROM @Test AS ZT1 WHERE ZT1.sdate &gt;= @startdate AND ZT1.sdate &lt;= @enddate GROUP BY ZT1.dname, ZT1.sdate UNION ALL Select t1.dname, 0 As tr17, SUM(ISNULL(t1.dc,0)) As DC17, 0 As DC16, 0 AS tr16, sdate as activityDate FROM @Test t1 WHERE t1.sdate &gt;= @startdate AND t1.sdate &lt;= @enddate Group By t1.dname, t1.sdate UNION ALL SELECT ZT1.dname, 0 As tr17, 0 As DC17, 0 As DC16, SUM(ISNULL(ZT1.tr,0)) AS tr16, sdate As activityDate FROM @Test AS ZT1 WHERE ZT1.sdate &gt;= DateAdd(yy, -1, @startdate) AND ZT1.sdate &lt;= DateAdd(yy, -1, @enddate) GROUP BY ZT1.dname, ZT1.sdate UNION ALL Select t1.dname, 0 As tr17, 0 As DC17, SUM(ISNULL(t1.dc,0)) As DC16, 0 AS tr16, sdate as activityDate FROM @Test t1 WHERE t1.sdate &gt;= DateAdd(yy, -1, @startdate) AND t1.sdate &lt;= DateAdd(yy, -1, @enddate) Group By t1.dname, t1.sdate ) AS A GROUP BY YEAR(activityDate), MONTH(activityDate)
My table is like this:  Sitecode    Month  Amount --------    -----  ------ XX          Jan     1000 XX          Jan     3000 XX          Apr     3000 XX          Apr     1000   What I want is, to show the result something like this:  Sitecode    MonthJAN   MonthAPR --------    --------   -------- XX          4000       4000
how can i forward requests to my own IP address to a local IP address in my network (possibly using named)? My setup  I have a linux server running in my basement. I currently have my router looking to that server for DNS lookup, so I can use named to spoof a bunch of domain names to point to my local server's local address, 192.168.0.111. This works great.  I also am running Apache and PHP on this server, and have forwarded port 80 on my router to this machine, so my public IP xx.xxx.x.xx is sent to the basement server.  This is a great development set up for me, because I can develop websites in my local network and pull them up on numerous devices with a *.mylocal.net address. I can also quickly share a website on my public IP with others that are outside of my network.  I have a static IP, so that makes this even easier.  The problem  Some applications need to have an absolute URL. My spoofed DNS doesn't work outside my network, and neither does my internal IP address.  I need to be able to access the sites at the same IP that they are accessed publicly, which is my public IP: xx.xxx.x.xx    For some reason, I can't access my own public IP address from within my own network.  My router's public IP is xx.xxx.x.xx, and when I hit xx.xxx.x.xx from outside my network I see exactly what I want -- my development website. But, when I hit xx.xxx.x.xx from inside my network, the connection times out.    I assume my ISP has a firewall that blocks requests from xx.xxx.x.xx to xx.xxx.x.xx where the origin and the destination are the same IP (or maybe this is impossible on any network?)  So how can I set up my network to forward the internal request to my public IP to the local IP of my basement server?   I would like to do this within the local DNS server I set up, or in my router, so the change can be applied to all devices in my network, and not just the basement server or the windows tablet/laptop, etc individually. Intuitive examples of importance sampling My background is computer science. I am fairly new to monte carlo sampling methods and, although I understand the math, I have hard time coming up with intuitive examples for importance sampling. More precisely, could someone provide examples of:    an original distribution one cannot sample from but one can estimate an importance distribution which can be sampled from and adequate for this original distribution. examples:         Gift (German) = poison   poisson (French) = fish   embarazada (Spanish) = pregnant   sauce (Spanish) = willow   triviale (Italian) = vulgar   parentes (Portuguese) = relatives   slim (Dutch) = smart Cannot add PPA: 'ppa:~darklin20/ubuntu/bomi'.     ERROR: '~darklin20' user or team does not exist.   Showing this message when suing this command:    sudo add-apt-repository ppa:darklin20/bomi   please help me. If $A$ commutes with $B$ and $B$ commutes with $C$, then $A$ commutes with $C$ Let $A,B,C \in \ M(3,\mathbb{R})$ be such that $A$ commutes with $B $and $B$ commutes with $C$. $B$ is not scalar matrix. Then, $A$ commutes with $C$.   Is this true or false? I think it is not true, but cannot think of a counterexample. Any suggestions? How to "inverse match" with regex? Flows/Processes, Version Control and CI I've started using Processes and Flows and am really excited about these features -- but am still wrapping my mind about how to manage them in Version Control (which I use) and Continuous Integration (which I don't yet... but am trying to work in that direction). The underlying challenge is that each time a process or flow is edited, the metadata file is renamed to reflect its update version, e.g. MyFlow-1.flow, MyFlow-2.flow, etc. The Challenge for Version Control If each version of the flow has its own file name, this makes it more complicated to track changes to flows.  It seems like there could be two strategies here:  Rename the files to remove the version number.  I'd need a script to run through my src folder pre-commit, and remove the number so that my file name is always MyFlow.flow.  This is an annoying extra step, but makes version control simpler.  On the other hand, it probably makes deployment much harder.  Track each file in version control with its original name.  We'd need to be diligent about deleting MyFlow-1 in the commit where we add MyFlow-2 so that git would recognize this as a rename/move and show helpful diffs.  Otherwise, the whole file appears to change with every change, which makes version control rather less useful.   The Challenge for Deployment/Continuous Integration From my experiments so far, once a flow has been activated in a given environment, the metadata file can't be deployed again (either it is currently active, or has been active in the past and superseded). That means that I need to prevent my previous flow versions from being included in a deployment package (either by not tracking them at all, or by using a script to delete earlier versions).  I also need some way to determine whether the current version (in my repo) should be included in the deployment payload for a given environment or not. I could imagine a script that (1) downloads flows from the target environment, and removes *.flow files from the payload if they already exist in the target environment, but that feels complicated.  And it's even harder if I've removed the version numbers from my flow files. Are you using flows in VS or CI?  How are you managing these issues? Note:  I'm not sure whether VC and CI should be one question or two - depends on how integrated the strategy for dealing with these two challenges.  If you think these should be separate questions, comment and I'll re-post. Badge Notification Repeats Not sure if someone else has already raised this - I've got eleven notifications that I've received a Caucus badge on English Language Learners. Perhaps one notification for each community that I'm a member of?  I am a member of the community, and did visit the election. Also, the badge hasn't been awarded more that once (so I think it's just the notification that's at fault).  Note that this seems to happen for other badges, it has been reported for: Caucus, Nice Answer, Enthusiast. property not working with getter AND setter Showing inequality for harmonic series. I want to show that $$\log N&lt;\sum_{n=1}^{N}\frac{1}{n}&lt;1+\log N.$$ But I don't know how to show this. Difference between projection and datum? Illustrating op amp feedback without control theory We are teaching op amps in a high school class, before calculus.  So we can't use control theory to teach how op amps respond.  All the same, I would like to have an intuitive explanation for how a feedback circuit works.  Take the negative feedback, for instance.  Is there a clear way to show how an initial difference of delta between V+ and V- leads to a very large (G(V+ - V-)) difference in the output, which then leads to ...  I'd like to be able to take that argument and show how the voltage of the output converges in addition to the standard virtual short argument.  Can anyone explain it clearly? Can SQL Server's Page Life Expectancy be too high? I've read several articles about SQL Server's Page Life Expectancy and what it means and what kind of information you can glean from it. In most of these articles that I've read, a common, healthy PLE value is somewhere around 1000-2000 seconds. I've read that getting down to around 300 seconds can mean you're likely low on RAM.  I recently just upgraded our hardware to have 64GB of RAM, up from 14GB. On the 14GB my PLE was around 300 seconds, and I was having a lot of 5-6 memory grants pending per second. So, that was bad and I increased the RAM. Now, my PLE is much, much higher around 5000 seconds, and no more pending memory grants. I've seen it 7000 seconds, if I recall. This is much higher than anything I've read.  Can a high PLE be a bad thing? Or is it the higher the better?  EDIT: I'm sorry, my PLE wasn't 7000 seconds, it was 70,000 seconds! Although, at the moment it is down to around 7000.     The database size is around 160GB. A few tables have 5+ million rows. max_server_memory is set to 2147483647. Can a non-EU citizen travel freely within the Schengen area without passport? My current situation is that I have residence permit of Germany (as a stamp in passport) and I wish to apply for UK visa in next few days from Germany and won't have my passport anymore during the processing time.  Instead of waiting for the process, I wish to travel to Scandinavian countries immediately on holidays, later receive my passport from visa center after I return back to Germany.   I am wondering if photocopy of passport and residence permit suffice as identity proof to border control (if I face them)? What else are valid documents that I can show as valid identity proof to border control? What are the exact problems I will face if I face the border control, and they are not satisfied with my travel documents? Can we modify "Ask question" to automatically suggests tags based on your question content.   So instead that user needs to type "team-foundation-server" or "TFS" or "TeamFoundationServer" he will see list of tags auto-populated with ajax which he (or she) can then select and it will be associated with the question. So basically only thing we need is code which will cross-match question content with list of known tags while user is typing and display results in some nice ajax-enabled list/cloud/whatever UI control. This should be separate control for tags suggestions so user still has option to use standard tag list input to type-in tags.  In this case, instead of three (or more) tag variations we would have only one tag for Team-Foundation-Server. Is there any "superlogarithm" or something to solve $x^x$? Is there any "superlogarithm" or something to solve an equation like this:  $$x^x = 10?$$ Antonym of "phobia" If a phobia is to have an irrational fear of something, what is the word for having an irrational affinity for something?  For example a numerologist may fear the number 13, but be attracted to (or even have a love for) the number 8. (Some would say this is irrational.) Why do I get a black rectangle instead of my external picture? I write some of my network notes in TeX. I wanted to make a table, and inside it insert an image:   .   I wrote a document:  \documentclass{article} \usepackage[demo]{graphicx} \usepackage{booktabs} \usepackage{array}  \begin{document} \begin{tabular}{m{3cm}m{3cm}m{5cm}} \toprule Configuration for ... &amp; Commands &amp; Topology\\ \midrule PPP: CHAP, PAP &amp; \#sh int se 0/0/0  &amp; \includegraphics[width=4cm, height=4cm]{chappap.png}\\  &amp; &amp; \\ \bottomrule \end{tabular} \end{document}   But instead of my network topology image, I see only this: .   I don't know what is wrong, cause my image is 100% in the same dir, as my *.tex file.  EDIT:  Changed my code as @Jubobs suggested, now everything is as I wanted:  \documentclass{article}     \usepackage{graphicx}     \usepackage{booktabs}     \usepackage{array}      \begin{document}     \begin{tabular}{m{3cm}m{3cm}m{5cm}}     \toprule     Configuration for ... &amp; Commands &amp; Topology\\     \midrule     PPP: CHAP, PAP &amp; \#sh int se 0/0/0  &amp; \includegraphics[width=4cm, height=4cm]{chappap.png}\\      &amp; &amp; \\     \bottomrule     \end{tabular}     \end{document} "invalid EFI file path" while booting Windows @future method: Unsupported parameter type I am trying to copy records from one org to other via web services. I am calling a class which has logic written into a trigger. But @ future method is not taking sObject  list as a parameter. Can someone suggest me an alternative?  The Code:  public class webServicesTriggerClass   {     @future public static void webServicesMethod(list&lt;MyFriend__c&gt; mfList)     {         partnerSoapSforceCom.Soap sp = new partnerSoapSforceCom.Soap();       partnerSoapSforceCom.LoginResult lr = sp.login('hitesh.kumar.singh@accenture.com.varun','4Rajyavardhan');      soapSforceComSchemasClassNiralaapp.SessionHeader_element ses = new soapSforceComSchemasClassNiralaapp.SessionHeader_element();      ses.sessionId = lr.sessionId;       soapSforceComSchemasClassNiralaapp.MyFriendsDetailSoapApi vNapp=new soapSforceComSchemasClassNiralaapp.MyFriendsDetailSoapApi();      for(MyFriend__c mf:mfList)       {        string  s1= mf.myEmail__c;        string  s2=mf.friendName__c;         string  s3=mf.friendEmail__c;        string  s4=mf.aboutFriend__c;        integer i1=Integer.ValueOf(mf.age__c);        boolean result=vNapp.addFriendDetails(s1,s2,s3,s4,i1);        system.debug('################' +result);           }     }    }     Trigger-->  trigger webServicesTrigger on MyFriend__c (after insert)     {      webServicesTriggerClass.webServicesMethod(trigger.new);    }     Error--    Error: Compile Error: Unsupported parameter type LIST at line 3 column 30