FAQ Database Discussion Community


SQL create column with select in select and subtract this with another column, to create a new column

sql,sql-server,installation,isnull
I'm new at SQL and I have a question about my code as shown underneath: SELECT membernummer, name, c.ammount, c.terms, (select SUM(isnull(amount, 0)) from payments p where m.member_ID = p.member_ID and p.year = c.year) AS payed From member m INNER JOIN contribution c ON m.member_ID = c.member_ID where c.year =...

SQL Server ISNULL not working

sql-server,isnull
I have the following query for SQL server: SELECT SUM(ISNULL(CurrentVendorLastPurchCost, 0)) AS TheSum FROM VW_Report_AvailableInventory WITH(NOLOCK) The table that I am running it on is empty. Given the ISNULL clause, I would expect it to return 0. However, it returns NULL. I have had a look at a number of...

SSIS Conditional Split - No value return

ssis,conditional-statements,isnull,ssis-2012
I am using SSIS 2012 My statement: Select BOSP from MyTable Result is not NULL, it returns nothing as seen below. Problem now is in SSIS if the result is NOTHING like above I need to do something using the Conditional Split, but if there is data then I need...

IsNull function inside an IIf() not working - MS Access

mysql,date,ms-access,isnull
I have a field in a query that is checking how the user entered the date on the main form. I am trying to make it like a single entered date when the first text box is fill in and like a date range if an ending date is entered...

SQL Server - what's the difference between using ISNULL() in front of CONVERT() and within it?

sql-server,isnull
I got someone else's query to work with and trying to break it down to understand everything. In SELECT, most of the columns are called like below: CONVERT(VARCHAR,ISNULL(<column name>,''),100) Does it make a big difference if the ISNULL function was used like this: ISNULL(CONVERT(VARCHAR,<column name>,100),'') At first look for me...

using sql - Is not null in a select statement

sql,sql-server,null,isnull,ifnull
I can't seem to figure out how to use the opposite of isnull or ifnull statements in sql. I need to say if a.Error1 is not null -- then print the ' - ' and the + CHAR(13)+CHAR(10). Basically There should be no dash or no new line break if...

How to check for existence of null in a table column

sql-server,tsql,isnull
I have a table ( application) with the following columns: appID ssn fname lname What I want to do is scan the appID column is null exist. If there is one, then execute a stored procedure called NullFix.Any suggestion as to how to construct the SQL statement?...

How does Left Join / IS NULL eliminate records which are there in one table and not in the other?

mysql,sql,left-join,isnull
I am having a tough time to understand why does LEFT JOIN / IS NULL eliminate records which are there in one table and not in the other. Here is an example SELECT l.id, l.value FROM t_left l LEFT JOIN t_right r ON r.value = l.value WHERE r.value IS NULL...

Why do these queries return differently?

sql,sql-server,sql-update,subquery,isnull
I am working on a query which I am updating a user defined table that always has 1 row (it's part of a much larger operation). This table is populated by querying from a larger employee table based on employee ID. This query is working most of the time but...

Shorter CASE ISNULL(qry, '')='' THEN 'no' ELSE 'yes' END

sql,sql-server,case,isnull
Is there a shorter/better way to write this SQL statement? Edit: the inner sql select statement is a placeholder, the actual statement is more complex. SELECT CASE WHEN ISNULL((SELECT TOP 1 x FROM y), '') = '' THEN 'No' ELSE 'Yes' END AS BooleanValue It feels very kludgey because it...

Sybase Sql query not returning error

sql,null,sybase,isnull
While doing a query with multiples tables and multiples variables in a Sybase SQL query, the results weren't what i was expecting. My table is not complete and is not supposed to be, most of it can recieve NULL as a value (I know NULL is not a value but...