case

DATEDIFF With CASE Statement blank

≡放荡痞女 提交于 2020-01-17 03:15:11
问题 I'm pulling some data in an SQL query to output to PHP as below. , DATEDIFF('d',Activity.CreatedOn, NOW()) As Dif , DATEDIFF('d',qSWxSRLastUpdated.MaxOfCreatedOn, NOW()) As LastUpd , FORMAT((qSWxSRLastUpdated.MaxOfCreatedOn), 'DD-MMM-YYYY') AS Start , FORMAT((Activity.CreatedOn), 'DD-MMM-YYYY') AS CreatedOn , DATEDIFF('d',(Select CASE WHEN Activity.CreatedOn > qSWxSRLastUpdated.MaxOfCreatedOn THEN Activity.CreatedOn ELSE qSWxSRLastUpdated.MaxOfCreatedOn END), NOW()) AS MostRecentDate Now the

JavaScript switch case: anyway to force the order of the elements as they are written out?

我与影子孤独终老i 提交于 2020-01-16 14:35:09
问题 I've got results being returned to a Google Mapping application in the div sidebar. The results are names of businesses that belong to categories that the client wants returned in a certain order. And unfortunately it's not a straight alpha sort. So one category begins with F and the second one with a C and the last three are A's, for example. So I need my switch, which works, but naturally insists on dropping the values in alpha sorted (as they are returned from the DB that way) order as

Is it possible to use values from another table as the interval in a DATEADD function?

杀马特。学长 韩版系。学妹 提交于 2020-01-16 08:48:27
问题 I have a table of events containing a date (smalldatetime). I have a table of intervals (int) (days before) for when a reminder should be sent - DATEADD(D, *interval*, GETDATE()) . I'm trying to write an SQL statement to get all the events where a reminder should be sent today (based on GETDATE() from the DATEADD function. This is instead of me first getting all the intervals and running SQL in a loop, passing each interval as a parameter into the DATEADD function. Any ideas how I'd do this?

How to do a Select Case with Left function in VBA?

走远了吗. 提交于 2020-01-16 07:49:10
问题 I'm trying to do a Select Case with Left function ( contain(text in the cell) would be better but I don't know how to do that) but wasn't able to figure out how to do that. I tried the following: Sub siteadd() Dim x Dim Pl Dim Li Sheets("ort").Select Columns("F:F").Select Selection.TextToColumns Destination:=Range("F1"), DataType:=xlDelimited, _ TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _ Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _ :

case subquery in sql server 2008

吃可爱长大的小学妹 提交于 2020-01-15 14:14:08
问题 the followings statements gives an error print (case when exists (select count(*) from tblCustomerProductsDiscount PD where PD.cust_ID=138 and PD.pack_detl_ID = 1) then 0 end) Error: Subqueries are not allowed in this context. Only scalar expressions are allowed. 回答1: First of all, while your intention is quite clear, the script in its current form doesn't make sense, and here's why. You are checking for the existence of rows in the select count(*)... subselect, but the fact is, COUNT()

SQL 'case when' in hibernate Criteria

孤街醉人 提交于 2020-01-15 12:35:09
问题 How can I tranform the following query to a hibernate Criteria? select pr_name, count(*) from (select (case when serv.type=xyz then serv.nameA else serv.nameB end) as pr_name from db.serv serv where serv.date is null group by pr_name; I have got the following to handle the rest (except for the case part) currentSession.createCriteria(StoredData.class) .setProjection(projectionList() .add(groupProperty("pr_name"), "pr_name") .add(rowCount(), "count")) .add(isNull("date")) .setResultTransformer

Solr case insensitve

泪湿孤枕 提交于 2020-01-15 12:06:18
问题 Hallo, I'am implementing an autocompletion feature in Solr and have one problem. For autocompletion I am using <fieldType name="text_auto" class="solr.TextField" sortMissingLast="true" omitNorms="true"> <analyzer> <tokenizer class="solr.KeywordTokenizerFactory"/> <filter class="solr.LowerCaseFilterFactory" /> </analyzer> </fieldType> I thought that the LowerCaseFilter should make the Token Case insensitiv but that ist wrong. In fact in just lowercases the Token which means that a query like

Solr case insensitve

末鹿安然 提交于 2020-01-15 12:04:34
问题 Hallo, I'am implementing an autocompletion feature in Solr and have one problem. For autocompletion I am using <fieldType name="text_auto" class="solr.TextField" sortMissingLast="true" omitNorms="true"> <analyzer> <tokenizer class="solr.KeywordTokenizerFactory"/> <filter class="solr.LowerCaseFilterFactory" /> </analyzer> </fieldType> I thought that the LowerCaseFilter should make the Token Case insensitiv but that ist wrong. In fact in just lowercases the Token which means that a query like

Row_Number() CTE Performance when using ORDER BY CASE

六月ゝ 毕业季﹏ 提交于 2020-01-15 04:53:25
问题 I have a table I'd like to do paging and ordering on and was able to get a query similar to the following to do the work (the real query is much more involved with joins and such). WITH NumberedPosts (PostID, RowNum) AS ( SELECT PostID, ROW_NUMBER() OVER (ORDER BY CASE WHEN @sortCol = 'User' THEN User END DESC, CASE WHEN @sortCol = 'Date' THEN Date END DESC, CASE WHEN @sortCol = 'Email' THEN Email END DESC) as RowNum FROM Post ) INSERT INTO #temp(PostID, User, Date, Email) SELECT PostID, User

Row_Number() CTE Performance when using ORDER BY CASE

空扰寡人 提交于 2020-01-15 04:53:13
问题 I have a table I'd like to do paging and ordering on and was able to get a query similar to the following to do the work (the real query is much more involved with joins and such). WITH NumberedPosts (PostID, RowNum) AS ( SELECT PostID, ROW_NUMBER() OVER (ORDER BY CASE WHEN @sortCol = 'User' THEN User END DESC, CASE WHEN @sortCol = 'Date' THEN Date END DESC, CASE WHEN @sortCol = 'Email' THEN Email END DESC) as RowNum FROM Post ) INSERT INTO #temp(PostID, User, Date, Email) SELECT PostID, User