coalesce

COALESCE, IFNULL, or NZ() function that can be used in SQL Server and MS Access

三世轮回 提交于 2019-12-22 04:10:41
问题 I have a project that can use either SQL Server or MS Access as the data store. In one SELECT statement, I must perform a COALESCE operation on a single column and a single value, like this: SELECT COALESCE([Amount], 0) FROM PaymentsDue; I would like to write a single SQL statement that will execute correctly in both SQL Server and MS Access. The SQL Server version that is of immediate interest is 2008, although a solution applicable across versions would be preferred. Earlier today, someone

COALESCE, IFNULL, or NZ() function that can be used in SQL Server and MS Access

此生再无相见时 提交于 2019-12-22 04:10:15
问题 I have a project that can use either SQL Server or MS Access as the data store. In one SELECT statement, I must perform a COALESCE operation on a single column and a single value, like this: SELECT COALESCE([Amount], 0) FROM PaymentsDue; I would like to write a single SQL statement that will execute correctly in both SQL Server and MS Access. The SQL Server version that is of immediate interest is 2008, although a solution applicable across versions would be preferred. Earlier today, someone

Coalesce duplicate columns in spark dataframe

假装没事ソ 提交于 2019-12-22 00:25:33
问题 I have a spark data frame which can have duplicate columns, with different row values, is it possible to coalesce those duplicate columns and get a dataframe without any duplicate columns example : |name |upload| name| upload1| | null| null|alice| 101| | null| null| bob| 231| |alice| 100| null| null| | bob| 23| null| null| should become - |name |upload| upload1| | alice| null| 101| | bob | null| 231| |alice| 100| null| | bob| 23| null| 回答1: val DF1 = Seq( (None, None, Some("alice"), Some(101)

SQL语句——02、字符类型函数

坚强是说给别人听的谎言 提交于 2019-12-20 12:53:42
介绍字符型如下函数 ASCII('字符') 返回字符的ASCII码值 idle> select ASCII('a') from dual; ASCII('A') ---------- 97 idle> select ASCII('A') from dual; ASCII('A') ---------- 65 idle> CHR('n') 返回n的字符值 n是ASCII码数 idle> select chr(65) from dual; C - A idle> select chr(39) from dual; C - ' idle> 但是求单引号的ASCII码写法很特殊 两个单引带表一个单引 idle> select ASCII(''') from dual; ERROR: ORA-01756: quoted string not properly terminated idle> select ASCII('''') from dual; ASCII('''') ----------- 39 idle> LOWER(列名|表达式) 小写转换 idle> select lower('ABC') from dual; LOW --- abc idle> UPPER(列名|表达式) 大写转换 idle> select upper('abc') from dual; UPP ---

LINQ to SQL C# COALESCE

孤街醉人 提交于 2019-12-20 01:47:05
问题 Given the following table: Length | Width | Color | ID =========================== 18 | 18 | blue | 1 --------------------------- 12 | 12 | red | 1 --------------------------- I want to produce a single column/row: SIZES ================= 18 x 18, 12 x 12, I can do this in SQL as follows: DECLARE @SIZES VARCHAR(8000) SELECT @SIZES = COALESCE(@SIZES, '') + Convert(varchar(80), [Length]) + ' x ' + Convert(varchar(80), [Width]) + ', ' FROM table where ID = 1 GROUP BY [Length], [Width] ORDER BY

How to use coalesced memory access

六月ゝ 毕业季﹏ 提交于 2019-12-19 00:40:09
问题 I have 'N' threads to perform simultaneously on device which they need M*N float from the global memory. What is the correct way to access the global memory coalesced? In this matter, how the shared memory can help? 回答1: Usually, a good coalesced access can be achieved when the neighbouring threads access neighbouring cells in memory. So, if tid holds the index of your thread, then accessing: arr[tid] --- gives perfect coalescence arr[tid+5] --- is almost perfect, probably misaligned arr[tid

How to display a default value when no match found in a query?

泄露秘密 提交于 2019-12-17 19:52:05
问题 I want to display a default message when there is no data obtained from a query. For example Let us take a query select empname from employee where id = 100 If no data matches this search i want to get Unavailable as a result or the required result should display. So how should i write a SQL query to achieve this. I am using Oracle 10g. 回答1: SELECT COALESCE((SELECT empname FROM employee WHERE id = 100), 'Unavailable') FROM DUAL; You have to wrap the SELECT into another SELECT or no row will

How to get the first non-null value in Java?

為{幸葍}努か 提交于 2019-12-17 03:03:34
问题 Is there a Java equivalent of SQL's COALESCE function? That is, is there any way to return the first non-null value of several variables? e.g. Double a = null; Double b = 4.4; Double c = null; I want to somehow have a statement that will return the first non-null value of a , b , and c - in this case, it would return b , or 4.4. (Something like the sql method - return COALESCE(a,b,c) ). I know that I can do it explicitly with something like: return a != null ? a : (b != null ? b : c) But I

Combine rows / concatenate rows

倖福魔咒の 提交于 2019-12-16 20:04:21
问题 I'm looking for an Access 2007 equivalent to SQL Server's COALESCE function. In SQL Server you could do something like: Person John Steve Richard SQL DECLARE @PersonList nvarchar(1024) SELECT @PersonList = COALESCE(@PersonList + ',','') + Person FROM PersonTable PRINT @PersonList Which produces: John, Steve, Richard I want to do the same but in Access 2007. Does anyone know how to combine rows like this in Access 2007? 回答1: Here is a sample User Defined Function (UDF) and possible usage.

T-SQL COALESCE GROUPING SETS into single column without NULL duplicates

余生长醉 提交于 2019-12-14 03:53:29
问题 A thesaurus database where terms and categories are linked to each other and running SQL Server 2008. Based on this and this answers. Here is a sample: CREATE TABLE #term (termid VARCHAR(8), en VARCHAR(32), enscope VARCHAR(32)) CREATE TABLE #link (linkid VARCHAR(10), termid VARCHAR(8), reltype VARCHAR(2), refid VARCHAR(8)) CREATE TABLE #categorylink (code VARCHAR(3), termid VARCHAR(8)) INSERT INTO #term VALUES ('100', 'ABC', 'abc_scopenote') INSERT INTO #term VALUES ('120', 'DEF', 'def