coalesce

Using ISNULL vs using COALESCE for checking a specific condition?

故事扮演 提交于 2019-12-27 11:06:11
问题 I know that multiple parameters can be passed to COALESCE , but when you want to to check just one expression to see if it doesn't exist, do you use a default or is it a better practice to use ISNULL instead? Is there any performance gain between the two? 回答1: This problem reported on Microsoft Connect reveals some differences between COALESCE and ISNULL : an early part of our processing rewrites COALESCE( expression1, expression2 ) as CASE WHEN expression1 IS NOT NULL THEN expression1 ELSE

SparkSQL分区OutOfMemory

我的梦境 提交于 2019-12-27 01:20:54
由于SparkSQL默认200个分区,为了处理小文件决定使用reparation和coalesce重分区,代码如下 (一)df_1.coalesce(1).createOrReplaceTempView(“table_tmp”) 竟然报错。。 Job aborted due to stage failure: Task 1 in stage 8.0 failed 4 times, most recent failure: Lost task 1.3 in stage 8.0 (TID 642, svldl061.csvw.com, executor 8): org.apache.spark.SparkException: Task failed while writing rows. 查看执行过程 具体原因有待研究?? (二)df_1.repartition(1).createOrReplaceTempView(“table_tmp”) 运行成功了!!! 查看执行过程(和上面几乎一样,不过少了Coalesce这关键一步!!!) 区别在于coalesce第八步只有1个分区,repartition第八步有200个分区。 来源: CSDN 作者: lhxsir 链接: https://blog.csdn.net/lhxsir/article/details/103720096

Coalescing date ranges in postgres to eliminate overlaps

别说谁变了你拦得住时间么 提交于 2019-12-25 03:44:48
问题 If I have a postgres table a: member | start | end ---------+------------+------------ 1 | 2015-01-01 | 2015-05-01 ---------+------------+------------ 1 | 2015-03-01 | 2015-06-01 ---------+------------+------------ 2 | 2015-01-01 | 2015-05-01 ---------+------------+------------ 2 | 2015-06-01 | 2015-08-01 How would I coalesce dates to eliminate overlapping ranges like this: member | start | end ---------+------------+------------ 1 | 2015-01-01 | 2015-06-01 ---------+------------+------------

Select latest available value SQL

谁说我不能喝 提交于 2019-12-25 02:18:47
问题 Below is a test table for simplification of what I am looking to achieve in a query. I am attempting to create a query using a running sum which inserts into column b that last sum result that was not null. If you can imagine, i'm looking to have a cumulative sum the purchases of a customer every day, some days no purchases occurs for a particular customer thus I want to display the latest sum for that particular customer instead of 0/null. CREATE TABLE test (a int, b int); insert into test

Coalescing results in Linq

回眸只為那壹抹淺笑 提交于 2019-12-24 11:19:12
问题 have looked through many posts here on SO, and haven't found any that address this. Just a note that all code presented here is simplified but representative of the real code. I have a data table that describes some properties of coverage plans. The query to bring back the best match looks something like this: select coalesce ( (select c.PercentOfCoverageA from CoveragePlans c where c.coverage = :COVERAGE and c.plancode = :PLANCODE and c.statecode = :STATECODE), (select c.PercentOfCoverageA

Postgresql coalesce and set-valued function called in context that cannot accept a set

微笑、不失礼 提交于 2019-12-24 08:43:52
问题 I have these two similar queries but in the first case it works Ok but in the second fails CREATE OR REPLACE FUNCTION XmlNodes(xmlData xml, selector TEXT) RETURNS TABLE(r xml) AS $$ SELECT unnest(xpath(selector, xmlData)); $$ LANGUAGE SQL; with tmp (x) AS( SELECT r from XmlNodes('<Data> <RegDeletedItem Id="a60ded3d-2d2f-4f57-91d5-0091579bddb9" /> <RegDeletedItem Id="4295e41c-0a09-4601-984a-eac7a9e91fe1" /> </Data>', '/Data/RegDeletedItem')), sel (y) AS ( select CAST(unnest(xpath('

Coalesce operator - usage (c#) [closed]

走远了吗. 提交于 2019-12-24 00:59:49
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 8 years ago . Ive seen an increasing number of pieces of code that use the coalesce operator in a (to me anyway) slightly odd manner, thoughts on this usage? e.g. doing: string foo = null; void bar(){ foo = foo??"hello"; }

COALESCE with NULL

左心房为你撑大大i 提交于 2019-12-23 07:22:57
问题 I found this snippet of SQL in a view and I am rather puzzled by it's purpose (actual SQL shortened for brevity): SELECT COALESCE(b.Foo, NULL) AS Foo FROM a LEFT JOIN b ON b.aId=a.Id I cannot think of a single reason of the purpose of coalescing with null instead of just doing this: SELECT b.Foo AS Foo FROM a LEFT JOIN b ON b.aId=a.Id Or at the very least don't include the NULL explicitly: SELECT COALESCE(b.Foo) AS Foo FROM a LEFT JOIN b ON b.aId=a.Id I don't know who authored this (so I

MySQL query: How to properly identify and retranslate comma-separated result values to the original notions using CONCAT_WS and COALESCE

半世苍凉 提交于 2019-12-23 05:38:14
问题 there are many discussions about string-based results being saved in a comma-separated fashion within a MySQL database table. I do not want to extend this here with my own philosophical comments, I just want to start by saying that this issue is well known to me, but not right the topic now. The topic is that I have such a situation to evaluate. The data are saved as string-based cyphers. Each of these cyphers denotes a medical complication after a specific type of surgery has been performed.

How do I count individual text count from a column from all records [duplicate]

爱⌒轻易说出口 提交于 2019-12-23 03:28:21
问题 This question already has answers here : SQL String: Counting Words inside a String (3 answers) Closed 2 years ago . I need to display count of each text occurrence on all rows from a particular column. See result below: Here I have a set of Tags, I need to display count each tag as column in the name 'Total' What I have done is: DECLARE @tags VARCHAR(8000) DECLARE @tot INT select @tags = coalesce(@tags + ',' , ' ') + Labels from addNew select @tot = count(@tags) select a.Labels as Tags,@tot