conditional-statements

Querying DynamoDB

拥有回忆 提交于 2020-01-03 20:04:09
问题 I've got a DynamoDB table with a an alpha-numeric string as a hash key (e.g. "d4ed6962-3ec2-4312-a480-96ecbb48c9da"). I need to query the table based on another field in the table, hence I need my query to select all the keys such as my field x is between dat x and date y. I know I need a condition on the hash key and another on a range key, however I struggle to compose a hash key condition that does not bind my query to specific IDs. I thought I could get away with a redundant condition

Querying DynamoDB

 ̄綄美尐妖づ 提交于 2020-01-03 20:01:49
问题 I've got a DynamoDB table with a an alpha-numeric string as a hash key (e.g. "d4ed6962-3ec2-4312-a480-96ecbb48c9da"). I need to query the table based on another field in the table, hence I need my query to select all the keys such as my field x is between dat x and date y. I know I need a condition on the hash key and another on a range key, however I struggle to compose a hash key condition that does not bind my query to specific IDs. I thought I could get away with a redundant condition

IF returns FALSE when it sould return TRUE

 ̄綄美尐妖づ 提交于 2020-01-03 17:09:12
问题 I tried to do something like this sub test() a=inputbox("value1:") b=inputbox("value2:") c=inputbox("value3:") if a<b and a>c then msgbox(a) else msgbox(b) msgbox(c) end if end sub when I enter values such as 5 for a, 10 for b and 2 for c, condition should return TRUE and then message box with a is shown, but it returns FALSE and displays message boxes with b and c. I think the solution is pretty simple but I can't figure it out. thanks a lot 回答1: This happens because VBA is treating your

How can I use “OR” condition in MySQL CASE expression?

这一生的挚爱 提交于 2020-01-03 10:56:13
问题 I have a procedure that contains CASE expression statement like so: BEGIN .... WHILE counter < total DO .... CASE ranking WHEN 1 OR 51 OR 100 OR 167 THEN SET project_name = 'alpha'; WHEN 2 THEN SET project_name = 'beta'; WHEN 10 OR 31 OR 40 OR 61 THEN SET project_name = 'charlie'; .... ELSE SET project_name = 'zelta'; END CASE; INSERT INTO project (id, name) VALUES (LAST_INSERT_ID(), project_name); SET counter = counter + 1; END WHILE; END $$ DELIMITER ; When I call the above procedure, cases

Conditionally removing duplicates in Excel based on largest value in a Column

独自空忆成欢 提交于 2020-01-03 03:57:11
问题 I have a 2-column data in Excel that looks like this: The first column is a value, and the Second column contains a corresponding word. However, I want to remove rows in this dataset such that, in the end, for each unique word in Column two, only one row is retained for which the value in the Column one is the largest for that word, removing even those rows having duplicates of the largest value for each unique word and leaving one row for each unique word. 2 cat 2 cat 1 cat 3 dog 2 dog 1 dog

Equivalence of short-cut optional binding syntax in Swift

与世无争的帅哥 提交于 2020-01-03 00:38:48
问题 Given var maybeInt: Int? how to the following two conditional statements differ? // (1) if let y = maybeInt { y } else { println("Nope") } // (2) if let y = maybeInt? { y } else { println("Nope") } They seem to behave exactly the same. Is the former a short-cut for the latter? 回答1: The second syntax is optional chaining — just with nothing after the chaining operator. It accesses whatever optional comes before it (if the optional is not nil ), allows chaining property accesses or method calls

Perl. Using until function

五迷三道 提交于 2020-01-02 05:29:30
问题 I have a simple data file. Each line in the file has four elements. Some lines are filled with no blank entries. Other lines have a first entry and the remaining three are blank, or rather "filled" with a space. It is a tab delimited file. Example of the input file: . . . 30 13387412 34.80391242 sSN_FIRST 30 13387412 34.80391242 sSN5_40 30.1 30.2 30.3 30.4 31 14740248 65.60590089 s32138223_44 31 14740248 65.60590089 s321382_LAST . . . To reiterate, the "blanks" in my file actually contain a

Would it be pythonic to use `or`, similar to how PHP would use `or die()`?

五迷三道 提交于 2020-01-02 02:53:09
问题 Is it pythonic to use or , similar to how PHP would use or die() ? I have been using quiet or print(stuff) instead of if verbose: print(stuff) lately. I think it looks nicer, they do the same thing, and it saves on a line. Would one be better than the other in terms of performance? The bytecode for both look pretty much the same to me, but I don't really know what I'm looking at... or 2 0 LOAD_FAST 0 (quiet) 3 JUMP_IF_TRUE_OR_POP 15 6 LOAD_GLOBAL 0 (print) 9 LOAD_CONST 1 ('foo') 12 CALL

Two conditions in if

淺唱寂寞╮ 提交于 2020-01-01 23:52:33
问题 I'm trying to write a script which will read two choices, and if both of them will be "y" I want it to say "Test Done!" and if one or both of them won't be "y" I want it to say "Test Failed!" Here's what I came up with: echo "- Do You want to make a choice ?" read choice echo "- Do You want to make a choice1 ?" read choice1 if [ "$choice" != 'y' ] && [ "$choice1" != 'y' ]; then echo "Test Done !" else echo "Test Failed !" fi But when I answer both questions with "y" it's saying "Test Failed!"

Conditional SUM on oracle SQL

不想你离开。 提交于 2020-01-01 09:39:31
问题 I have the data in the follow way: ITEM LOCATION UNIT RETAIL QUANTITY 100 KS 10 -10 200 KS 20 30 I want the sum of positive quantities (quantity > 0) and sum of negative quantities (quantity < 0). How do I get those column sum based on condition? 回答1: You can use SUM(CASE ... ) : SELECT item, location, SUM(CASE WHEN quantity > 0 THEN quantity ELSE 0 END) AS positive_sum, SUM(CASE WHEN quantity < 0 THEN quantity ELSE 0 END) AS negative_sum FROM your_table GROUP BY item, location; LiveDemo 回答2: