score:0
I believe you want the following:
case WHEN COUNT(Practice) is null THEN '0' ELSE COUNT(Practice) END AS 'Total Enquiries'
score:0
Hmmm . . . You should keep the types the same:
SELECT dc.dateasdate,
(case WHEN dc.dateasdate is null THEN 0 ELSE COUNT(Practice) END) AS TotalEnquiries,
dp.practice,
de.Origin
However, the date is showing as NULL
because the value is NULL
in the original data. What value do you want to show in this case?
EDIT:
You can use COALESCE()
:
SELECT COALESCE(dc.dateasdate, '2016-04-03')
(case WHEN dc.dateasdate is null THEN 0 ELSE COUNT(Practice) END) AS TotalEnquiries,
dp.practice,
de.Origin
. . .
However, I suspect that the LEFT JOIN
is not what you really want.
More questions
- Need date to show instead of being Null
- Order by DESC for DATE Need NULL values to show first
- Instead of NULL how do I show `0` in result with SELECT statement sql?
- Why does appending a NULL into a Date column result in the value 1900-01-01 being displayed?
- SQL - Select records equal to date, or show all if date is null
- Issues with pyodbc numeric values being labelled as 'None' instead of NULL or empty
- crystal reports - datetime group header does not show time, only date. need to display date AND time
- Need a total for each column and to show 0 for null data points
- I need to handle overlapping dates but if the end date is null then it to be assumed that the process has not stopped
- How to avoid null date record where there is record with given date else need to get record with null date
- How to Show Date with AM/PM instead of specifying time in SQL
- Check specific ID is exists in the table, show empty or null instead of showing No records found
- SSRS show a error template instead of the real report if a stored procedure returns a null value
- I needed to convert a null to a character string, and i need it to say current employee instead of null
- How to show NULL instead of 0 when using sum aggregate / pivoting
- Why is 1899-12-30 the zero date in Access / SQL Server instead of 12/31?
- bit type : default to '0' instead of NULL
- Using WHERE clause with BETWEEN and null date parameters
- The value is returned instead of NULL when using function with OUTER APPLY
- Show comma instead of point as decimal separator
- Show empty string when date field is 1/1/1900
- When to use separate date and time instead of a single datetime
- How to check if a column is being updated in an INSTEAD OF UPDATE Trigger
- Is it faster to check that a Date is (not) NULL or compare a bit to 1/0?
- How return a count(*) of 0 instead of NULL
- Why does SUM(...) on an empty recordset return NULL instead of 0?
- 'Domain/MachineName$' being used for authentication instead of 'Domain/UserName'
- SQL search for date between values or Min/Max if NULL
- Use 'ISNULL(x, 0) = 0' instead of (x is null OR x = 0)
- SQL Server Convert datetime to date without null
More questions with similar tag
- MS SQL Server - create unique key for user
- Modern alternative to DELETE ... WHERE ... NOT IN (...)?
- gitignore file for SQL Server project: SSIS / SSAS / SSRS?
- Efficient way to determine in which time window the sample stays constant in SQL Server 2014
- Merge rows if date columns are overlapping in TSQL
- SQL Server replacing parts of a string using regex
- My Slowly Changing Dimension in SSIS keeps changing when it's not supposed to
- SQL: Update a row and returning a column value with 1 query
- Using SQL Profiler can I pinpoint to one DB
- Query fix for a SQL View
- Sql backup to url - azure blob differential
- Selecting minimal dates, or nulls in SQL
- Unable to figure out JDBC ClassNotFoundException (JTDS driver)
- REPLACE function in T-SQL 2008 is different from T-SQL 2005
- SQL Case statements, making sub selections on a condition?
- Compare previous date and current date and update the table on basis on condition
- Why does Visual Studio start localdb and how can I stop that?
- Display data from an AlwaysEncrypted column in a NodeJS app?
- How to update specific values in a column with other values from same column in the same table? - SQL Server
- select distinct of different date in varchar format and display/group them in month and year only
- How do I assign the most recent value in a table as a variable in SQL Server
- Access Stored Procedure Parameters with Dynamic SQL
- Set local variable in rdlc expression
- T-SQL to get consecutive Rows
- Problems with sending notification emails from SQL Server 2008
- What tables were accessed last
- Stuffing data of one column when data in all other column same
- cannot connect on SQLserver with Docker on mac
- Changing not in clause to inner join
- Fetch week numbers with date range of each week for a whole year
Source:
stackoverflow.com