null

Why null values are not ranking same in mysql?

£可爱£侵袭症+ 提交于 2019-12-13 03:35:55
问题 Yesterday I asked a question about ranking students by their points. [Rank users in mysql by their points ] I actually solved my problem with the help I've recieved from other question (thanks to everyone who helped me). Meanwhile I figured out something accidently. If I try to rank my students by their points and if points column was empty (NULL) my query didn't gave an error also it sorted ranks like 1-2-3-4 but all values were NULL this is the query I've tried select er.*, (@rank := if(

Best practice to check if a variable exists in plpgsql?

夙愿已清 提交于 2019-12-13 02:57:40
问题 For instance I've got a stored procedure to import data from csv files and write the read data into a SQL table. I've got a table defined as below: CREATE TABLE person (id int, name text, age int, married boolean); First I check if the record exist already, if exists I do update, if doesn't - insert. Each field of record may have a different type, so the result of a SQL command are assigned to a list of scalar variables: SELECT name, age, married INTO v_name, v_age, v_married [..] Let's

Counting non-null columns in a rather strange way

五迷三道 提交于 2019-12-13 02:33:01
问题 I have a table which has 32 columns in an Oracle table. Two of these columns are identity columns the rest are values I would like to get the average of all the value columns, which is complicated by the null (identity) columns. Below is the pseudocode for what I am trying to achieve: SELECT ((nvl(val0, 0) + nvl(val1, 0) + ... nvl(valn, 0)) / nonZero_Column_Count_In_This_Row) Such that: nonZero_Column_Count_In_This_Row = (ifNullThenZeroElse1(val0) + ifNullThenZeroElse1(val1) ...

MySQL ODBC Parameter issue

ⅰ亾dé卋堺 提交于 2019-12-13 02:13:35
问题 Okay, so I'm getting a weird error with this function. It's saying: Exception Details: System.Data.Odbc.OdbcException: ERROR [HY000] [MySQL][ODBC 5.1 Driver][mysqld-5.0.27-community-nt]Column 'CommentNumber' cannot be null But I can verify that the variable commentnumber is indeed getting a value. If I put a Response.Write right before the command.Parameters.Add("@CommentNumber", commentnumber);" line I get 1 returned (which is correct). public string commenter(string commentnumber, string

Use Java exceptions internally for REST API user errors?

穿精又带淫゛_ 提交于 2019-12-13 02:06:49
问题 We have a REST API that works great. We're refactoring and deciding how to internally handle errors by the users of our API. For example the user needs to specify the "movie" url parameter which should take the value of "1984", "Crash", or "Avatar". First we check to see if it has a valid value. What would be the best approach if the movie parameter is invalid? return null from one of the internal methods and check for the null in the main API call method throw an exception from the internal

What's the difference between (null) vs <null>?

落花浮王杯 提交于 2019-12-13 01:43:44
问题 I was getting random crashes in my app until I narrowed it down to a particular method. In that method I expect an NSString as a parameter. This NSString can sometimes be nil in which case the method ends and no harm is done. When I run my method's parameter through NSLog(@"%@", myString) I found that I get one of these: The contents of an actual NSString (null) <null> The first two are expected and handled by my method. The third one, <null> , crashes my app with -[NSNull length]:

Select the last value of each column, with a single query

不羁岁月 提交于 2019-12-13 01:07:45
问题 Having the following data (blank means NULL): ID ColA ColB ColC 1 15 20 2 11 4 3 3 How can I get the last not-NULL values of each column in a single query? So the resulting for the given data would be: ColA ColB ColC 11 3 20 I have not found much, the function that seemed to do something similar to what I describe was COALESCE , but it does not work as expected in my case. 回答1: Looks like you would have to run a separate query per column with plain SQL. For a small table and only 3 columns,

Mongoid: ActiveModel Numericality Validation, allow_nil does not work

送分小仙女□ 提交于 2019-12-13 00:54:22
问题 I've defined a Mongoid model with an Integer field for which i validate numericality like this # source.rb class Source field :code, type: Integer validates_numericality_of :code, allow_nil: true The purpose of allow_nil is to validate fields which are present & ignore nil values. But here, allow_nil completely bypasses the numericality check object = Source.new object.code = "ABC" object.valid? => true object => #<Source _id: 50d00b2d81ee9eae46000001, _type: nil, code: 0> In activerecord,

sporadic unwanted null entries in database $_GET

爷,独闯天下 提交于 2019-12-13 00:42:47
问题 I have a little temperature protocoling web app, where degrees get adjusted on a page and saved in a database. It works, but sometimes sporadic errors occur from users which I can't reproduce! Sometimes there are null-entries in the database and I don't know how and why. It "nulls" the hole row (several temperatures per day are selectable). If e.g. no temp got selected in a div string "NA" should be handed to the db. This bug is so resilient, I don't know where else to turn to. Ajax increases

WITH ROLLUP GRAND TOTAL AND SUBTOTAL

放肆的年华 提交于 2019-12-13 00:27:33
问题 I have a script that produces a result set that is almost there! I'm trying to get subtotals and grand totals. I get sub totals on the year column and a grand total at the end. My goal is to get the final result to state "grand total" instead of subtotal. Please note that my final row, 'location' also returns as null due to the rollup function. SELECT YEAR, COUNT(ACCOUNTS) AS 'ACCOUNTS', SUM(BALANCE) as 'BAL', LOCATION AS 'LOCATION' FROM ACCOUNT A WHERE C.CREATE BETWEEN DATEADD(DAY,DATEDIFF