Questions tagged [multiple-conditions]

Examples include if, for, while and other loops.

while (a==1 && b==2)
{
   ...
}

The loop will continue as long as a is 1 and b is 2.

630 questions
7
votes
2 answers

basic sql : selecting AVG() values from the same column multiple times in one query, when each wanted AVG() value uses different WHERE clause

I want to get three different average values from one column (value_to_count) inside one table where all of those average values has a different WHERE clause (according to time). Example Data: ###services#### Table service_id value_to_count …
ranssi
  • 71
  • 1
  • 1
  • 2
7
votes
2 answers

Pandas: np.where with multiple conditions on dataframes

hi folks i have look all over SO and google and cant find anything similar... I have a dataframe x (essentially consisting of one row and 300 columns) and another dataframe y with same size but different data. I would like to modify x such that it…
swyx
  • 2,378
  • 5
  • 24
  • 39
7
votes
5 answers

Multiple query conditions in Rails - if they exist.

I found a few similar questions while searching here, but when I tried to add unless to the solutions I found, things started to break... Here's what I have that works: Controller: @metrics = Metric.where("current_ratio > ?",…
6
votes
3 answers

R check row for row if a combination exists in another dataframe

I have two data frames (df1 and df2) in R with different information except for two columns, a person number (pnr) and a drug name (name). Row for row in df1, I want to check, if the combination of pnr and name exists somewhere in df2. If this…
reuss
  • 121
  • 1
  • 1
  • 9
6
votes
1 answer

get subsection of df based on multiple conditions

I'm trying to extract rows from a df based on multiple conditions, ALL of the conditions must be met before any rows are selected else nothing. My df columns = ['is_net', 'is_pct', 'is_mean', 'is_wgted', 'is_sum'] index = ['a','b','c','d'] data =…
Boosted_d16
  • 13,340
  • 35
  • 98
  • 158
6
votes
2 answers

SQL where both conditions in brackets are true

SELECT * FROM TableName WHERE Column1 = 'X' AND Column2 = 'Y' AND (Column3 != 'D' AND Column4 != 'D') -- Want to apply this filter ONLY if both conditions are true How to write third filter so that it's applied only if both of…
ilija veselica
  • 9,414
  • 39
  • 93
  • 147
6
votes
1 answer

Bash IF : multiple conditions

I've been trying to make this thing work for a couple of hours but I can't get it to work : if [ "$P" = "SFTP" -a "$PORT" != "22" ] || [ "$P" = "FTPS" && [ "$PORT" != "990" -a "$PORT" != "21" ] ] ; then Can someone help me ? I know that multiple…
5
votes
2 answers

SQL exclude rows matching all of multiple criteria

I currently have a query merging two tables to create a new one for analysis. After getting some funny results when trying to chart it for presentation, I learned that some of it is fake data that was never cleaned up. I've been able to identify the…
Minadorae
  • 301
  • 3
  • 5
  • 13
5
votes
5 answers

SQL CASE checking for two conditions from the same column

I currently have a CASE statement that checks to see whether certain tasks are completed or not, and then returns the date of the next task. Since the tasks are ordered, each WHEN statement becomes longer, checking each of the previous tasks to see…
Matthew Paxman
  • 247
  • 2
  • 4
  • 13
5
votes
3 answers

LINQ: Split Where OR conditions

So I have the following where conditions sessions = sessions.Where(y => y.session.SESSION_DIVISION.Any(x => x.DIVISION.ToUpper().Contains(SearchContent)) || …
Eric Bergman
  • 1,453
  • 11
  • 46
  • 84
5
votes
5 answers

Multiple conditions in if statement on both sides of the logical operator

I was experimenting with having multiple arguments in an if statement on both sides of the logical operator. I first started with the || operator, which worked as expected: var a = 'apple', b = 'banana', c = 'cherry'; if (a == 'banana' || a ==…
AKG
  • 2,936
  • 5
  • 27
  • 36
5
votes
1 answer

Using a combination of ANDs and ORs in Mongoid

I'd like to construct a query of the form: select * from some_table where (field1 = 'x' or field2 = 'y') and (field3 = 'z' or field4 = 'w') From reading the docs, I thought it should look something like this in…
sa125
  • 28,121
  • 38
  • 111
  • 153
4
votes
1 answer

Is there always the same execution sequence for various conditions in a If Statement in C++ for all compilers?

Lets assume a simple If Statement with two conditions A and B: If ( condA && condB) Is the Sequenz for all compilers the Same? condition A condition B And is the execution of condition B therefore optional, in case condition A is already…
Ernte1893
  • 183
  • 2
  • 11
4
votes
3 answers

Multiple conditions in if statements in R

I am trying to cut down a list of gene names that I have been given. I'm trying to eliminate any repetitive names that may be present but I keep getting an error when running my…
Rohan Singhal
  • 41
  • 1
  • 1
  • 2
4
votes
4 answers

list of dictionaries comprehension - multiple conditions

I have a problem with multiple conditions with list: listionary = [{u'city': u'paris', u'id': u'1', u'name': u'paul'}, {u'city': u'madrid', u'id': u'2', u'name': u'paul'}, {u'city': u'berlin', u'id': u'3', u'name':…
1
2
3
41 42