case

Use Boolean algebra in tsql to avoid CASE statement or deal complex WHERE conditions

♀尐吖头ヾ 提交于 2019-12-04 12:35:45
I came across a scenario,I will explain it with some dummy data. See the table Below Select * from LUEmployee empId name joiningDate 1049 Jithin 3/9/2009 1017 Surya 1/2/2008 1089 Bineesh 8/24/2009 1090 Bless 7/15/2009 1014 Dennis 1/5/2008 1086 Sus 9/10/2009 I need to increment the year column by 1, only If the months are Jan, Mar, July Or Dec. empId name joiningDate derived Year 1049 Jithin 3/9/2009 2010 1017 Surya 1/2/2008 2009 1089 Bineesh 8/24/2009 2009 1090 Bless 7/15/2009 2010 1014 Dennis 1/5/2008 2009 1086 Sus 9/10/2009 2009 derived Year is the required column We were able to achieve

mysql case in update statement with REPLACE

风流意气都作罢 提交于 2019-12-04 11:58:31
I currently have something like this: UPDATE table1 SET column1 = REPLACE(column1, 'abc', 'abc1') WHERE column1 LIKE '%abc%'; UPDATE table1 SET column1 = REPLACE(column1, 'def', 'def1') WHERE column1 LIKE '%def%'; I am trying to consolidate these into a single update statement and am trying the following: UPDATE table1 SET column1 = CASE WHEN column1 LIKE '%abc%' THEN REPLACE(column1, 'abc', 'abc1') WHEN column1 LIKE '%def%' THEN REPLACE(column1, 'def', 'def1') ELSE column1 END; Is this the correct way of doing this? I am new to case/when. Thanks! Since you are using LIKE '%abc%' , the update

How to proceed through all cases if they are true PHP

▼魔方 西西 提交于 2019-12-04 09:28:21
I want to know if there is a way to proceed through all three cases,if they are all true,but with using break,because as an example,if the first case is true,the second case is false and the third is also false,and i am not using break,it will procced trough all anyway.Change the strtotime with 6 October 2014,and you will see what i mean $date = strtotime("1 October 2014"); switch($date) { case (date('l', $date) == 'Monday'): //case 1: If the current day is Monday echo "weekly<br>"; break; case (date('d', $date) == '01'): //case 2: If the current day of the month is 1 echo "monthly<br>"; break

ruby case statement with comparison [duplicate]

自作多情 提交于 2019-12-04 07:27:49
This question already has an answer here: Ruby range: operators in case statement 3 answers Is there a way to use a case statement with integer comparisons in ruby? I have found lots of examples comparing strings, but my case example below fails with syntax errors. def get_price_rank(price) case price when <= 40 return 'Cheap!' when 41..50 return 'Sorta cheap' when 50..60 return 'Reasonable' when 60..70 return 'Not cheap' when 70..80 return 'Spendy' when 80..90 return 'Expensive!' when >= 90 return 'Rich!' end end In case..when block you can't perform any comparisons except === . So I'd write

SET in combination with CASE statement in cypher

假如想象 提交于 2019-12-04 07:11:17
I am tryin to set two different relationship properties to a count, with a case construct depending on the value of another relationship property. There is a console at http://console.neo4j.org/?id=rt1ld5 the cnt column contains the number of times r.value occurs. The two first rows of the initial query in the console indicate that the term "Car" is linked to 1 document that is considered relevant, and to two documents that are considered not relevant. I want to SET a property on the [:INTEREST] relation between (user) and (term) with two properties, indicating how many times an interest is

SQL学习精粹之group by分组

若如初见. 提交于 2019-12-04 06:46:33
group by 有一个原则, 不分组必聚合原则: 就是 select 后面的所有列中,没有使用聚合函数的列,必须出现在 group by 后面(重要) 一、group by取最大值 面试遇到一个分组取最大值的问题 例子一 取最新充值记录 充值记录表 CREATE TABLE chongZhi ( id int not null primary key AUTO_INCREMENT COMMENT '主键编号', userId int COMMENT '充值用户id', jine int COMMENT '充值金额', date date COMMENT '充值日期' )ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT '充值记录表'; insert into chongZhi(userId,jine,date) value(1,20,'2016-10-28'); insert into chongZhi(userId,jine,date) value(1,60,'2016-10-29'); insert into chongZhi(userId,jine,date) value(1,55,'2016-10-30'); insert into chongZhi(userId,jine,date) value(2,100,'2016-10-22')

Any ideas how to determine what age group an individual belongs in Excel?

做~自己de王妃 提交于 2019-12-04 06:33:20
问题 I have 2 columns in an Excel spread sheet. First column header is called AGE and the second column header is called Age_Group. The ages in the AGE column are between 18 and 45. There could be multiple rows with same age. I am tasked with determining what age group a certain age falls into and then print out that age group. For instance, if someone’s age is 18, I would like to use IF statement or CASE statement to determine that age 18 is between 18 and 24 and then put that value into Age

MySQL Case Select not behaving as expected

牧云@^-^@ 提交于 2019-12-04 06:12:28
问题 While creating a more complex stored procedure in MySQL, I encountered a weird problem with my CASE statement. I have simplified my procedure to show the issue. I am selecting three things per loop to clarify the problem: the count variable, the modTemp variable before the CASE, and then a number representing which CASE path was taken. DELIMITER // CREATE PROCEDURE `AddPlants` (IN plantNum int) BEGIN DECLARE count int; DECLARE modTemp int; SET count = 1; WHILE count <= plantNum DO SELECT

Splitting value of a varchar column into two columns

╄→гoц情女王★ 提交于 2019-12-04 06:00:42
问题 If I have a column in which strings vary in length but they ALL have a slash \ within, how can I SELECT to have one column display everything BEFORE the \ and another column displaying everything AFTER the \ ? name column1 column2 DB5697\DEV DB5697 DEV I have seen CHARINDEX and REVERSE on MSDN but haven't been able to put together a soltuion. How can I best split a varchar/string column value into 2 columns in a result set in TSQL ? 回答1: How about the following (SQL Fiddle): SELECT m.name,

intent to activity in Side-Menu.Android of material design

自古美人都是妖i 提交于 2019-12-04 05:14:26
in https://github.com/Yalantis/Side-Menu.Android please help me :( How can when i click on each item in side menu, go to command "intent to other activity" instead of transport between images import android.content.res.Configuration; import android.graphics.Color; import android.graphics.drawable.BitmapDrawable; import android.os.Bundle; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import