case

Only one expression can be specified in the select list when the subquery is not introduced with EXISTS nested case statements

给你一囗甜甜゛ 提交于 2019-12-22 10:39:15
问题 I am trying to create a query that gets the number of hours an event was open below is my query. I am using case statements because it needs to take into account to only count weekdays. This is a step in the process my overall goal is to actually get the hours for those days. So for example if the the days is more than one count all those days and multiply by 8.. if its less than one do a datediff hours and just get the hours for that day.. Any help would be greatly appreciated! but I am

SQL Case statement specifiying condition in where clause?

跟風遠走 提交于 2019-12-22 09:59:54
问题 I have the the following query: SELECT * FROM dbo.tblOrders o WHERE o.OrderId IN (SELECT [Value] FROM [dbo].[udf_GenerateVarcharTableFromStringList](@OrderId, ',')) AND @ActiveInactive = CASE WHEN 'Active' THEN (o.[orderactivedate] > o.[orderinactivedate]) WHEN 'Inactive' THEN (o.[orderactivedate] < o.[orderinactivedate]) END This returns An expression of non-boolean type specified in a context where a condition is expected, near 'THEN'. How would I get this to work? saying if the parameter

How to use a case statement to determine which field to left join on

巧了我就是萌 提交于 2019-12-22 05:25:15
问题 I have a query that needs to be able to left join a field at the right place given the condition that the field is equal to a variable. Something like: CASE WHEN challenges.userID = $var LEFT JOIN challengesRead ON challenges.userID = challengesRead.userID CASE WHEN challenges.opponentID = $var LEFT JOIN challengesRead ON challenges.opponentID = challengesRead.userID I think I am on the right track but I'm not sure how to put the query together. Thanks 回答1: Something like this may work LEFT

MySQL CASE statement and REGEXP

二次信任 提交于 2019-12-22 05:09:14
问题 I want to use a CASE statement that uses REGEXP. Currently I am doing something like this: SELECT NAME, CASE INFO WHEN 'not cool' THEN 'Not Cool' WHEN 'very cool' THEN 'Cool' ELSE INFO END AS INFO FROM INFO_TABLE Is there any way to use REGEXP in the initial statement to make the condition act as a REGEXP? In theory this is what I want, which doesn't work: SELECT NAME, CASE INFO REGEXP WHEN 'not cool' THEN 'Not Cool' WHEN 'very cool' THEN 'Cool' ELSE INFO END AS INFO FROM INFO_TABLE I want

scala case classes questions

眉间皱痕 提交于 2019-12-22 04:19:13
问题 I have two questions regarding the '::' case class. :: can be used as case head :: tail => ... How does it work? Meaning, what is exactly the flow that Scala uses to match a List instance with the :: case class? Given that I have a class MyClass, with operator op, can I create a case class named op that I can use as: case foo op bar => .... ? 回答1: scala> abstract class Stack { | def push(n :Int):Stack | } defined class Stack scala> final case class push(st :Stack,hd :Int) extends Stack { |

Title Case in JavaScript for diacritics (non-ASCII)

不打扰是莪最后的温柔 提交于 2019-12-22 00:29:24
问题 Is it possible to create a JavaScript function that can convert a string to title case but one that works with non-ASCII (Unicode) characters? For example with characters like: Áá Àà Ăă Ắắ Ằằ Ẵẵ Ẳẳ Ââ Ấấ Ầầ Ẫẫ Ẩẩ Ǎǎ Åå Ǻǻ Ää Ǟǟ Ãã Éé Èè Ĕĕ Êê Ếế Ềề Ễễ Ểể Ěě Ëë Ẽẽ Ėė Ȩȩ Ḝḝ Ęę Ēē Ḗḗ Ḕḕ etc. For example if the string is "anders ångström", it should transform it into "Anders Ångström". The script that already exists it will transform into "Anders åNgström". 回答1: Try this: var str = 'anders

ruby case statement with comparison [duplicate]

孤街浪徒 提交于 2019-12-21 17:02:38
问题 This question already has answers here : Ruby range: operators in case statement (3 answers) Closed 5 years ago . 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

Nested CASE in SQL

痴心易碎 提交于 2019-12-21 05:30:13
问题 TABLE1: ARTIKEL SUPPLIERID SALE_SUM_PIECES TV SONY 7 TABLE2: ROW_ID ARTIKEL SUPPLIERID PIECES 1 TV SONY 6 2 TV SONY 10 3 TV SONY 6 4 TV SONY 14 5 TV SONY 18 6 TV SONY 4 I need to subtract value X=23 on TABLE2."PIECES" , only when the value TABLE1."SALE_SUM_PIECES" is less than the SUM of "PIECES" in TABLE2. For example: the value of TABLE1."SALE_SUM_PIECES" is 7 . NOw I need to check at which row the value 7 goes less than the SUM of TABLE2."PIECES" .In the below example the first row in

Determine data type of a column in SQLite

假如想象 提交于 2019-12-21 04:33:14
问题 I'm working on an Android App where the user has different options for sorting the displayed data that comes from the database. Currently my orderBy string that I pass to Androids query() method looks like this: "LOWER("+columnName+") ASC" The problem with this is that if the data type in the column specified by columnName is integer, calling LOWER() on it will cause it to be sorted alphabetically, i.e. based only on the leftmost digit, which of course doesn't make any sense for numeric data.

Which things around case classes will be removed after Scala 2.9 exactly?

杀马特。学长 韩版系。学妹 提交于 2019-12-21 04:32:12
问题 I know that the are some changes planned regarding case classes, like disallowing inheritance between them: scala> case class Foo() defined class Foo scala> case class Bar() extends Foo() <console>:9: warning: case class `class Bar' has case ancestor `class Foo'. Case-to-case inheritance has potentially dangerous bugs which are unlikely to be fixed. You are strongly encouraged to instead use extractors to pattern match on non-leaf nodes. case class Bar() extends Foo() ^ defined class Bar or