case

Scope of variables inside scala’s case guard statement.

For lift development, I sometimes need to use match–case statements like the following. (Rewritten to plain scala for easier understanding.) One note to them: These are actually different partial functions, defined in different parts of the code, so it’s important that a case statement fails in or before the guard in order to have the ot...

need to translate specific t-sql case in pl/sql

Can anyone tell me how to translate the following T-SQL statement: SELECT fileld1 = CASE WHEN T.option1 THEN -1 ELSE CASE WHEN T.option2 THEN 0 ELSE 1 END END FROM Table1 AS T The point is I need to validate two diff...

I wanted to know how to properly use switch/case

hello, I was just wondering if someone could just give me an example of how to use switch/case. I kinda get the just of it but am having trouble figuring out what and how i can use this. Thank you in advance. ...

MySQL Case in Select Statement with LIKE operator

Is it possible to combine the CASE statement and the LIKE operator in a MySQL SELECT statement? For Example, I am trying to query a database that stores data in a single column in either one of two formats (this is awful and hurts my head, but I cant change the data so it is what it is.). So sometimes the column numbers would have data ...

Returning multiple columns from SELECT nested within CASE MySQL

Is there a better way to do this? SELECT subs. * , CASE subs.member_type WHEN 'member' THEN ( SELECT CONCAT_WS( ' ', members.first_name, members.last_name ) FROM members WHERE members.id = subs.member_id) ELSE ( SELECT members_anon.username FROM members_a...

Selecting table using case clause in from clause

I have 8 table that contain different specific value for computer peripheral they are glpi_device_ram, glpi_device_hdd, glpi_device_gfxcard, glpi_device_sndcard. Each table has the same designation column in each table that contain device name. i have table glpi_computer_device that contain FK_device that contain id for each 8 table abov...

doesPythonLikeCamels

Are Java style camelCase names good practice in Python. I know Capilized names should be reserved by convention for Class names. Methods should be small letters according to good style, or actually I am not so sure. Is there PEP about naming? COMMENTS: Sorry for camels :) , I learned from answer PEP8, that my title is actually properly...

Using a case expression in a where clause

Although I know this isn't very efficient, I need to get this working fast so I try to follow the easiest path, or at least I thought so. I'm trying to get the max data out of an entity and take into consideration only the rows where USER is not null, and in case no rows have USER not set to null, then I will take the null ones into cons...

How can i use a switch with a spinner ?

Hi everyone, so i started android programming like a month ago, and i've got a probleme today. The thing i want to do is : From a Item in the Spinner, when i select it there is a Text View changing on the back. spin.setAdapter(adapter_city); spin.setOnItemClickListener(this); } @Override public void onItemClick(AdapterView<?> p...

Select multiple columns as a result of a case expression

This is what I would like to do: case p.residency_status when 0 then dbo.fn_formatAddress(r1.prm_name, p.py_hospital, p.py_address1, p.py_city, p.pyear_state) when 1 then dbo.fn_formatAddress(r1.prm_name, p.respgm_hospital, p.respgm_address1, p.respgm_city, p.respgm_state) when 2 then dbo.fn_formatAdd...

query with case column

In a query, I have a column like this: case when X = 1 then case when Y <> 0 then YY else XX end else ZZ end as MyColumn Is there a way, in another column, to check the above column value referencing MyColumn instead of rewriting the case statement? I should value another column based on the MyColumn value. Thanks ...

T-SQL Case statement utilizing substring and isnumeric

I have a T-SQL stored proc that supplies a good amount of data to a grid on a .NET page....so much so that I put choices at the top of the page for "0-9" and each letter in the alphabet so that when the user clicks the letter I want to filter my results based on results that begin with that first letter. Let's say we're using product na...

VHDL Case/When: multiple cases, single clause

Inside a process I have something like this: CASE res IS WHEN "00" => Y <= A; WHEN "01" => Y <= A; WHEN "10" => Y <= B; WHEN "11" => Y <= C; WHEN OTHERS => Y <= 'X'; END CASE; Note that case "01" and "01" get the same value. Is there correct syntax for something like WHEN "00", "01" => ? Extra note: There's far more to th...

Eliminating NULLs when using CASE in SQL Server SELECT statement

I have a large, messy report to write that joins across 5 tables. There is one column in one table that is being used for several different values--essentially a "tag" column, where the tags are used in creative ways depending on what kind of miscellaneous metadata the users want to use. As a result, my query for the report returns 3 ne...

Python runs a if-case that it should not!

I have this code: def random_answerlist(self): self.li = [] self.winning_button = random.randint(0, 3) i = 0 while i < 20 and len(self.li) is not 4: if i == self.winning_button: self.li.append(self.flags[self.current_flag][0]) else: new_value = self.random_value() if se...

how to include the column name in case statement

Hi, I need to include a column name in the where clause of SQL query depending on a variable value. For Example, 1. If I have a variable,say,@test and I assigned the variable with the value 1/0. 2. I have a table ,say, table1 with 2 column names col1,col2. Now, I am writing a query to fetch some data from the table by including only one...

getting a unique number for the contents of a cell

I am looking for a HASH or maybe something even simpler. I want to return a unique number for every string in a cell. Does anyone know if there is a function in a cell that will return a unique number or a unique string for another string? The problem is I would like to compare whether two string are totally equal, I need to be case s...

Ruby `when' keyword does not use == in case statement. What does it use?

x == User returns true, but case x statement does not run the block associated with User. What's happening here? u = User.new # => #<User:0x00000100a1e948> x = u.class # => User x == User # => true case x when User puts "constant" when "User" puts "string" else puts "nothing?" end # => nothing? ...

Using case in a sql select statement

Consider a table with a column amount, Amount -1235.235 1356.45 -133.25 4565.50 5023 -8791.25 I want to my result pane to be like this, Debit Credit 0 -1235.235 1356.45 0 0 -133.25 Here is my stored procedure, USE [HotelBI_CustomDB] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[SP_Ge...

iPhone Packager AS3 failing to convert switch case statement?

So, I've been creating an application using the Adobe AIR Packager for iPhone (command line style). The app consists of a lot of screens that provide various information, and the navigation is handled all in the document class via an event-triggered function that uses a large switch-case statement to determine what screen to go to. When...