sql-null

How to compare fields with Null values in Access

旧时模样 提交于 2021-02-11 14:32:46
问题 I have a query that looks at one tables field and matches the second table's field. It looks to see if the fields don't match each other. If there's no match the second table's field must replace the first tables field. I have this working EXCEPT when there's a null value in either of the two tables field. I tried using isNull() on the first table and it does select values that aren't null but if I apply the same function to the second table I get nothing in return. UPDATE [NAVAIR

SQL Server group by absorb null and empty values

泄露秘密 提交于 2021-01-28 02:54:35
问题 I have this data: Id Name amount Comments ------------------------------- 1 n1 421762 Hello 2 n2 421 Bye 3 n2 262 null 4 n2 5127 '' Each name may or may not have extra rows with null or empty comments. How can I group by name and sum(amount) such that it ignores/absorbs the null or empty comments in the grouping and shows me only 2 groups. Output I want: Id Name sum(amount) Comments ------------------------------------ 1 n1 421762 Hello 2 n2 5180 Bye I can't figure this out. I hoped that

SQL Server group by absorb null and empty values

核能气质少年 提交于 2021-01-28 00:02:27
问题 I have this data: Id Name amount Comments ------------------------------- 1 n1 421762 Hello 2 n2 421 Bye 3 n2 262 null 4 n2 5127 '' Each name may or may not have extra rows with null or empty comments. How can I group by name and sum(amount) such that it ignores/absorbs the null or empty comments in the grouping and shows me only 2 groups. Output I want: Id Name sum(amount) Comments ------------------------------------ 1 n1 421762 Hello 2 n2 5180 Bye I can't figure this out. I hoped that

How to make LAG() ignore NULLS in SQL Server?

醉酒当歌 提交于 2021-01-04 02:54:46
问题 Does anyone know how to replace nulls in a column with a string until it hits a new string then that string replaces all null values below it? I have a column that looks like this Original Column: PAST_DUE_COL 91 or more days pastdue Null Null 61-90 days past due Null Null 31-60 days past due Null 0-30 days past due Null Null Null Expected Result Column: PAST_DUE_COL 91 or more days past due 91 or more days past due 91 or more days past due 61-90 days past due 61-90 days past due 61-90 days

NULL NOT IN (Empty_Relation) of SQL query shows different behaviors on different engines

随声附和 提交于 2020-02-25 01:18:58
问题 I try a query which test NULL NOT IN Empty_Relation on Postrgresql, Spark and I got different results. select count(*) from (select 1) where null not in (a empty relation) Postgresql outputs 1. The other outputs 0. I understand the NULL behaviour of NOT IN, but my the subquery is empty relation, this situation seems more interesting. There are a lot of posts discussing NOT IN but I don't find anything related to NOT IN Empty_Relation. So my question is more like does ANSI SQL define this

How to OR null value in Apache Solr query?

走远了吗. 提交于 2019-12-21 03:56:15
问题 The last option to solve this for me was to ask StackOverflow. I am trying to create a Solr query to get documents that have a specific value on one of its fields OR that does not have a value... Theorically, this query should have worked. Here is some information: Query: (name: john) --> Result count: 15383 //Johns Query: (name: {* TO *}) --> Result count: 61013 //People that have a name Query: -(name: {* TO *}) --> Result count: 216888 //People that do not have a name Now, when I use first

MySQL, better to insert NULL or empty string?

做~自己de王妃 提交于 2019-12-17 02:26:27
问题 I have a form on a website which has a lot of different fields. Some of the fields are optional while some are mandatory. In my DB I have a table which holds all these values, is it better practice to insert a NULL value or an empty string into the DB columns where the user didn't put any data? 回答1: By using NULL you can distinguish between "put no data" and "put empty data". Some more differences: A LENGTH of NULL is NULL , a LENGTH of an empty string is 0 . NULL s are sorted before the

Selecting columns that are not all null

六眼飞鱼酱① 提交于 2019-12-13 10:31:46
问题 So I have a query that looks like this - select case when @subType = 1 or @subType = 2 then id end as Id, case when @subType = 3 then name end as name case when @subType = 3 or @subType = 2 then address end as address from table So the issue I have is, that if @subType is 3, then the column named ID will all be null. I then don't want to return this entire column. Conversely to that, if @subType is 2, then name would all be null so I don't want that entire column. 回答1: The only way you could

Hdp, Hive, Lateral view and null: disappearing rows

点点圈 提交于 2019-12-11 06:16:41
问题 Since the upgrade from hdp 3.1.0 to 3.1.4, I have some issue in Hive I do not understand. Note that I am only using ORC transactional tables. For instance this query: with cte as ( select e.id , '{}' as json from event e ) -- select count(*) from cte select id , lv.customfield from cte lateral view outer json_tuple(cte.json, 'customfield') cv AS `customfield` It worked perfectly before the upgrade. Now, even if the CTE returns a certain number of rows, using the lateral view will just drop