case-statement

Bash Script to let user choose from a list or enter their own

核能气质少年 提交于 2021-02-05 08:49:27
问题 I have a simple script which i want to list some pre-filled choices or for the user to enter a number to correlate with a build This is what I have currently. read -p "Please select from the list below or enter the build number you would like to download " build case {build} in Latest) build=lastSuccessful break;; *) break;; esac The problem is that is doesn't provide a list for the user to choose. Ideally it would look something like this Build Choices 1) Latest 3) Successful 5) pick a build

Case Statement Not Working - VBA

左心房为你撑大大i 提交于 2020-07-30 12:00:52
问题 In my project I have a list of clients that have unique commission calculations (ex. Client_1 has a 0.1% commission rate, whereas Client_2 has a 0.25% commission rate). In my VBA code I made special cases, that vary by the client_id. The problem I'm getting with this code is that even though I put in a special ID, it jumps over the case (ex. if klienta_nr = 100, it skips over the Case klienta_nr = 100 and returns the Case Else). How can I fix this issue? Private Sub CommandButton1_Click() Dim

Python Pandas equivalent for SQL case statement using lead and lag window function

情到浓时终转凉″ 提交于 2020-05-29 10:28:08
问题 New to Python here and trying to see if there is a more elegant solution. I have a time series data of telematics devices that has motion indicator. I need to expand the motion indicator to +/- 1 row of the actual motion start and stop (denoted by motion2 column below). I was doing it in SQL using case statements and lead and lag window functions. Trying to convert my codes to python... Here is the data. import pandas as pd data = {'device':[1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2], 'time

How to create a sequence on selected values in MySQL?

↘锁芯ラ 提交于 2020-01-17 02:52:31
问题 I'm trying to create a query which will select a team from a declared variable and then make the remaining teams "anonymous" by giving them generic brands and sequential IDs. For example, if my dataset has 3 different team names (ABC, DEF, and GHI), but I would only like the true value of the 1 chosen team (ABC) displayed. Here is the skeleton of the query I'm working with: SET @teamid = 123; SELECT CASE WHEN ID = @teamid THEN NAME ELSE 'Team' + ' - ' + SEQ END AS 'Team Name', SUM(TOTAL) AS

Pattern matching variables in a case statement in Haskell

谁说胖子不能爱 提交于 2020-01-09 07:43:07
问题 If I compare a string literal to a string literal using the case statement, I get the expected behavior: if they are the same - it matches, if they are not - it does not. However, if I compare a string literal to a constant that is a string, I get "Pattern matches are overlapped" warning and the branch with the constant always matches. Here's an example session: Prelude> let var1 = "abc" Prelude> let var2 = "def" Prelude> case var1 of { var2 -> "Fail"; _ -> "Win" } <interactive>:1:0: Warning:

Case Statement Not Assigning Value

一笑奈何 提交于 2019-12-24 08:18:52
问题 I'm having some trouble debugging a case statement. I was hoping that the statement would assign numeric values to note-val , but so far it is assigning #<void> . I know it's something wrong with the case statement, because if I add an else clause, that value gets applied. Given a sample input of '(((#\3 #\A) (#\4 #\B)) ((#\4 #\C))) , what am I doing wrong here? (In regards to the case statement. I'm sure there are other errors, but I'd like to try to work those out myself if I can get this

Case Syntax Errors

余生颓废 提交于 2019-12-24 04:07:29
问题 Hello I am attempting to do this with mySQL. I tried using SELECT IF and CASE to alter titles. Every title description has "A " in front of the description; even if the second word starts with a consonant. So I'm trying to query the descriptions but edit the ones with a leading consonant to start with "An ". CASE WHEN description LIKE ('A A%') THEN CONCAT('An ', TRIM(LEADING 'A ' FROM description)) WHEN description LIKE ('A E%') THEN CONCAT('An ', TRIM(LEADING 'A ' FROM description)) WHEN

Getting the number of cases in a switch-case in C

落花浮王杯 提交于 2019-12-22 11:37:12
问题 Is it possible to get the number of cases in a switch case in C without manually adding a counter variable which is incremented in each case? 回答1: As I commented earlier, I think you want a dispatch table rather than a switch statement. Here's a little example. Say you got this: int find_the_case(); void do_something(); void do_something_different(); void do_something_completly_different(); void do_default(); int main(int argc, char *argv[]) { int c = find_the_case(); switch(c){ case 0: do

VB.NET Stacking Select Case Statements together like in Switch C#/Java

↘锁芯ラ 提交于 2019-12-21 07:08:34
问题 Seems If I stack the Cases together they don't work as one. Since VB.NET Cases don't require the use of Exit Select / Return it seems to automatically put that every time a new Case is detected under it? Dim Test as Integer = 12 Select Case Test Case 11 Case 12 Case 13 MsgBox.Show("Could be 11 or 12 or 13?") End Select It doesn't seem to work only 13 works.. Gotta always remember this rule that you can't stack Cases like this from now on It's not easy to remember it when porting applications.

T-SQL Conditional WHERE Clause

给你一囗甜甜゛ 提交于 2019-12-17 23:42:40
问题 Found a couple of similar questions here on this, but couldn't figure out how to apply to my scenario. My function has a parameter called @IncludeBelow . Values are 0 or 1 (BIT). I have this query: SELECT p.* FROM Locations l INNER JOIN Posts p on l.LocationId = p.LocationId WHERE l.Condition1 = @Value1 AND l.SomeOtherCondition = @SomeOtherValue If @IncludeBelow is 0, i need the query to be this: SELECT p.* FROM Locations l INNER JOIN Posts p on l.LocationId = p.LocationId WHERE l.Condition1