mysql: nested if you add up

I want to count how many times confirmed_at was not null given that a promotion_id is either 1483 or 1887. select IF(promotion_id IN(1483,1887), sum(IF(confirmed_at IS NOT NULL,1,0)),0) as all_us_vs_voda, status_inv from blabla group by status_inv Ex

Use Multistorage for each pig group

I am trying to group my data and store in hdfs with a folder for each 'name' and subfolders for each 'YearMonth' under each name folder. Input: (Date) (name) (col3) (col4) 2015-02-02 abc y z 2016-01-02 xyz i j 2015-03-02 abc f b 2015-02-06 abc y z 20

Display a nested table in an HTML table

This is a simple problem that I've been trying to solve for several hours. I have an array containing information of several students and marks they scored in tests. There are 8 subjects in total, with each subject having 5 parameters. The array look

Avoid cascades of deeply embedded options at Scala

Say I have three database access functions foo, bar, and baz that can each return Option[A] where A is some model class, and the calls depend on each other. I would like to call the functions sequentially and in each case, return an appropriate error

Retrieving specific entries in nested lists

I'm new to Python and programming in general, so I apologise if I am not doing things in the most efficient manner possible. Suppose I have a list: Coords = [[1, 1], [2, 1], [1, 2], [1, 1]] And I'd like to make a new list called xCoords: xCoords = [1

Scala: best nested multiple-condition test

Lately, I frequently end up writing code like that: def doSomethingWithLotsOfConditions(arg1, arg2, arg3...) { arg1.get(arg2) match { case Some(value1) => arg3.get(value1) match { case Some(value2) => arg4.get(arg5, value2) match { case Some(value3)

Speed ​​up nested loops in R

I have a large datframe (about 3 million rows) which contain an ID, a year and three dates each: lookupdate, date1 and date2. The data.frame is sorted by ID and date1. I want to search through the whole data set and find the records i which: are of f

Java Nested Loop Triangle [Basic]

So the task is to make the system output a triangle with spaces that increment in between x's like this(dashes added in place of space for readability): xx x-x x--x x---x x----x x-----x x------x x-------x So, I've done this before and it seems easy e

Nested Python Loop - Get N Next Lines

I'm new to Python and trying to do a nested loop. I have a very large file (1.1 million rows), and I'd like to use it to create a file that has each line along with the next N lines, for example with the next 3 lines: 1 2 1 3 1 4 2 3 2 4 2 5 Right no

Creating HTML Fragments with PowerShell from CSV

I have a csv file that contains the following information ParentID,DivID,DataElement,Content,Class Dash_Reg,Summer_Active,Classes.Active,Active Classes:,class1 Dash_Reg,Summer_Active,Classes.Inactive,Inactive Classes:,class1 Summer_Active,Pass_classe

How to nest anonymous functions in Matlab?

I have a file funcs.m that stores anonymous functions. They must be usable by the files in the directory where it is. Currently, I use the anonymous functions so that I execute the file funcs.m in different files but I think this is a a wrong way of

Understand the equivalent of understanding the Python list

I have the following code: listOfStrings = ['i_am_exercising', 'python_functional', 'lists_comprehension'] [ "".join([elem.title() for elem in splited]) for splited in [el.split("_")for el in listOfStrings]] the result of this is: ['IA

How to make all nested attributes appear during 'edit'

I currently have a nested model User has_many Sales_Orders has_many Items. I can create the Sales_Order with nested Items properly but when I try to 'edit' the Sales_Order, the Sales_Order information is visible but the Items are not shown. Any idea

The recursive JavaScript function loses the return value

I want to search a string in a nested JSON object. If the string found in an object, I need to return that object. I am using a recursive function to achieve this. The problem is, the function is recursing until the end and not returning the object f

Check if a list is nested or not

Is there a "built-in"/efficient and robust way to check if list objects are nested or not? To clarify my understanding of the term nested: Flat or not-nested list x.1 <- list( a=TRUE, b=1:5 ) Nested list x.2 <- list( a=list(a.1=list(a.1.1=

Tool for flattening SVG nested transformations

I wonder if there is any command-line tool available to flatten nested groups with transformations in an SVG? In my particular case, I am converting a CAD-software produced PDF to SVG and then adding some elements and publishing the modified SVG to a

Member Visibility / Internal Class Attribute (C #)

I am looking for a visibility modifier for attributes of an inner class that would allow the outer class to modify/set a value but external classes could only get/read the value. public class Outer { public class Inner { // I want this to be editable

Function with a variable number of For loops (python)

My problem is difficult to explain. I want to create a function that contains nested for loops, the amount of which is proportional to an argument passed to the function. Here's a hypothetical example: Function(2) ...would involve... for x in range (

jquery access nested div

Here is my question. I am having this simple menu. <div id="menu"> <ul> <li> <a id="home" href="home.html"> home </a> </li> <li> <a id="profile" href="profile.html&q

SQL nested queries

Query 1: select PremiumYTDCurrent=Sum((AASI.Inv_Premium)*R.[Percent]), R.STAFF, L.Description, L.LINE_OF_BUSINESS from AAS_Invoice AASI,Invoice I,Revenue_Tracking R, Policy P, Line_Of_Business L where I.Invoice_No=convert(Char,Convert(int,AASI.Inv_En

Nested subquery T-SQL

Not being a SQL expert, and also only being semi-competent in CTE, how can I code this statement use the resultset from the following subquery within the main query, as our SQL Server is 2000. declare @subcategoryConcatenate varchar(3999) set @subcat

Nested foreach loop in pearl only once looped

I've written a perl script that opens two files which contain lists. I want to find items in the first list that are not in the second list. The script uses two foreach loops. The outer loop goes through each line of the first list, extracting the ne

Nested objects do not work as expected

I'm trying to get a nested model forms view working. As far as I can tell I'm doing everything right, but it still does not work. I'm on Rails 3 beta 3. My models are as expected: class Recipe < ActiveRecord::Base has_many :ingredients, :dependent =>