PostreSQL execute a default query when no row are returned I need to calculate the average score of a list of userId.  I have a table "user_place_score" (user_id / place_id/ score).  Sometimes I do not have the score for a user_id so I need to fetch a "default" score in a the "default_place_score" table (place_id / score).  Is is possible in PostreSQL to do this in one query ? For a a given list of users and one place_id select all their score in the user_place_score and if now row found take the score found if the default_place_score table ?  Basically I want to avoid doing this kind of stuff:  for (Integer userId : userIds) {   score = (query to fetch the score for this userId)   if (score == null)     defaultScore = (query to fetch the default score for this PlaceId)    total = total + defaultScore }  //return the average return total/numberOfUser   Thank you!
PostgreSQL execute a default query when no row are returned I need to calculate the average score of a list of userId.  I have a table user_place_score:  (user_id, place_id, score)   Sometimes I do not have the score (no row for (user_id,place_id) in the table) so I need to fetch a "default" score from the table default_place_score:  (place_id, score)   Is is possible in PostgreSQL to do this in one query? For a given list of users and one place_id, select all their scores in the user_place_score and if no row is found then take the score found if the default_place_score table?  Basically I want to avoid doing this kind of stuff:  for (Integer userId : userIds) {   score = (query to fetch the score for this userId)   if (score == null)     defaultScore = (query to fetch the default score for this PlaceId)    total = total + defaultScore }  //return the average return total/numberOfUser
How to modify an invalid '/etc/sudoers' file? How do I edit an invalid sudoers file? It throws the below error and it's not allowing me to edit again to fix it.  Here is what happens:  $ sudo visudo &gt;&gt;&gt; /etc/sudoers: syntax error near line 28 &lt;&lt;&lt; sudo: parse error in /etc/sudoers near line 28 sudo: no valid sudoers sources found, quitting Mixed content on many SE sites Many SE sites (like math.SE) have a problem with mixed content, which causes display bugs in recent browsers. This is particularly evident with math.SE (because of the huge use of MathJax) and with chat sections.  Will this be fixed?  How to reproduce  Visit  or   What happens  Mixed content is blocked, output is missing pieces of code (MathJax):    This picture also includes my main Firefox addons (top right), it relevant. It shows missing styles:    The white on the left is my tab list. Alright, when I run certain commands the wrong way, (misspelled, etc.) The terminal outputs this: &gt; instead of computername:workingfolder username$, and when I type enter it goes like this:  &gt;  &gt;  &gt;   That would be if I pressed enter 3 times. How do I breed Pokemon for their Hidden Abilities? I want to legitimately breed a competitive team, but I don't know how to breed for hidden abilities unless I just breed two Pokemon who have their normal ability(s) together until I breed one with a hidden ability. Does someone know a useful trick or item I could use? Word caption style -- different style for label and number? This should be a common problem for anyone involved in technical writing.  When you insert an image (or table etc.) caption in Word, you get  dialog. You enter your caption,  "A happy bicycle" (in yellow).  This might be fine for a happy bicycle, but I want to have captions that have one style for the "enumeration" (label and number) and one style for the description (caption text, as called by Word), as such:    I have tried searching for this but I haven't found anything yet... I tried Libreoffice, but its Import option while pasting in the cell is very  annoying.I also tried Gnumeric but I am not able to paste using middle button.Parcellite to make copy paste faster and middle button pasting is not working with Gnumeric. Is there any simple table maker app available that can accept only simple unformatted text? All these software are very complicated for this simple work. Move files from multiple folders all into parent directory with command prompt I have multiple .rar files in multiple folders like this:    C:\Docs\Folder1\rarfile1-1.rar C:\Docs\Folder1\rarfile1-2.rar C:\Docs\Folder1\rarfile1-3.rar    C:\Docs\Folder2\rarfile2-1.rar C:\Docs\Folder2\rarfile2-2.rar C:\Docs\Folder2\rarfile2-3.rar    C:\Docs\Folder3\rarfile3-1.rar C:\Docs\Folder3\rarfile3-2.rar C:\Docs\Folder3\rarfile3-3.rar     I want to move all of the .rar files to the parent directory 'C:\Docs'. I have a lot more than 3 folders, so I was thinking of making a batch file or something. What would be the commands to do this? Thanks Is "bared fruit" grammatical? Am I the only one whos athletic career bared fruit?    Is this sentence correct grammatically? For a project into balloon simulation I'd like to know how the force on a balloon changes with altitude:  I know that the Buoyant force on a balloon is:  $F = (\rho_{air} - \rho_{helium})gV$  Using changing air density from the international standard atmosphere and changes in gravitational acceleration I can calculate the buoyant force and add this to the (negative) force of gravity mg.  However I know that it isn't this simple, the balloon changes volume with altitude as the air pressure outside the balloon changes.  I'd like to know how the balloon inflates - this would be a great help!  I think it may be something to do with ideal gas laws -  I can calculate air temperature and pressure from the international standard atmosphere but do I use pressure as the air pressure? - or air pressure minus balloon pressure? Has user testing found that the "three horizontal bars" for main menu on mobile is commonly understood? "Three horizontal lines" aka "hamburger icon" seems to be becoming a convention for the "main menu" button, especially on mobile sites:    Has anyone done any user testing of this convention, or got any A/B testing results? (i.e. is there an increase in bounce rate compared to using the word "Menu"?)  I did some quick user testing with wireframes featuring this icon for the main menu. 3 out of 6 people got it and used it. The others did not.  One person in particular had a lot of trouble "getting back to the top" (i.e. restarting their navigation from the top level of the site) as they didn't know about the convention, or that the logo would link to the home page.  I guess it will be different for different demographics - users of Facebook on mobile probably know it.  Anyone got any findings they can share? I have always heard that it's a bad idea to install lots of software on a Windows machine, and new software should always be tested in a virtual machine so as to not permanently affect the operating system. But does the actual act of installing a piece of software really slow down the Windows OS? Or is it more due to the programs themselves running a bunch of background services?  To rephrase my question, if I were to continuously install software but then remove it later, would Windows still slow down? I have a UK Refugee passport. Do I need a visa to go to France?   I want to go for two days with my husband, but I'm not quite sure if I can go without a visa. In what cases should I use a comma before "or"? Will an object always fall at an infinite speed in a black hole? I recently came across the paper . The author raised a few common misconceptions regarding hypothesis testing and p-values, about which I have two specific questions:   The p-value is technically $P({\rm observation}|H_{0})$, which, as pointed out by the paper, generally does not tell us anything about $P(H_{0}|{\rm observation})$, unless we happen to know the marginal distributions, which is rarely the case in "everyday" hypothesis testing. When we obtain a small p-value and "reject the null hypothesis," what exactly is the probabilistic statement that we are making, since we cannot say anything about $P(H_{0}|{\rm observation})$? The second question relates to a particular statement from page 6(652) of the paper:      Since the p-value, or range of p-values indicated by stars, is not set a priori, it is not the long-run probability of making a Type I error but is typically treated as such.   Can anyone help to explain what is meant by this statement? Alternative to LibreOffice Base for Ubuntu How should I setup separate MX records for a subdomain? Where are the proprietary NVIDIA drivers in 16.04? The proprietary NVIDIA drivers "disappeared" with my latest update:    The option of "Proprietary drivers for devices" is correctly set under the "Ubuntu Software" tab. I have the graphics-driver PPA (ppa:graphics-drivers/ppa) correctly added to my sources.  Any ideas on how to bring the proprietary drivers back?  PS1: I need them because some of the games I play under wine don't work without them, for whatever reason.  PS2: Also, this feels like it should have a straightforward answer, but I've been looking online for a while without luck. Separable Hilbert space have a countable orthonormal basis I want to show that every an infinite-dimensional separable (contains countable dense set) Hilbert space has a countable orthonormal basis.  I know that every orthogonal set in a separable Hilbert space is countable, it is help me with the proof? Can PHP PDO Statements accept the table or column name as parameter? Why can't I pass the table name to a prepared PDO statement?  $stmt = $dbh-&gt;prepare('SELECT * FROM :table WHERE 1'); if ($stmt-&gt;execute(array(':table' =&gt; 'users'))) {     var_dump($stmt-&gt;fetchAll()); }   Is there another safe way to insert a table name into a SQL query? With safe, I mean that I don't want to do  $sql = "SELECT * FROM $table WHERE 1"