I have this query: It is giving me o/p as Id A B NULL NULL NULL I don’t want to have NULL values in my output, I only want to compare in A and B, is it possible in case statement. Answer A case expression can only manipulate the value of an expression, not remove rows from the result. If
Tag: sql
sql SUM: change null with 0
I have a query like this: And another like this: I want to select from those tables, with condition But I also want to change the null record which appears with 0, I’ve tried COALESCE but it still doesn’t give me the right result. Answer In general you would first set NULL values to 0 and then SUM…
import from excel to sql server: The ‘Microsoft.ACE.OLEDB.12.0’ provider error
I want to import data from excel to sql server, but I got error: The ‘Microsoft.ACE.OLEDB.12.0’ provider is not registered on the local machine. op: windows 10 64 bit excel: 32 bit There is no …
what is the difference between Coalesce and nullif
I am currently working on an SSRS report that will need to display a Dr’s ID based on either their DEA number or NPI number. I need to be able to do a coalesce on DEA and NPI to find the non-unknown one, which I will then add code to the SSRS report that will display a hover over stating
How to fold table rows with duplicated ID’s in T-SQL
I’ve googled for a while but haven’t found an aswer so I request your help. I have a subquery which returns me these values: And I need to make it look like this: Answer
Table shows DISTINCT information when I tell it not to?
For some reason I keep getting an output with DISTINCT information. I am trying to understand JOINS and I am not sure why I am getting this output: MANUFACTURE MODEL …
Access Run Time Error 3464 data type mismatch in criteria expression
What is wrong with that code? I can’t figure out why I keep getting this error. Answer Wouldn’t MovieId be a numeric? If so, no quotes:
Laravel using where clause on a withCount method
I am trying to do a where clause on withCount method of laravel’s eloquent query builder using this piece of code. and this code is giving me this error. SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘upvotes_count’ in ‘where clause’ (SQL: select , (select count() from u…
rails – shouldn’t I use default values in rails migration
I am not sure whether I should ask this question on SO or not. But I have to as I don’t have clear idea about my doubt. I was told not to set default values in rails migrations and use null values instead in a code review by our CTO. And his explanation is like this once the database gets
SQL/Regex Challenge/Puzzle: How to remove comments from SQL code (by using SQL query)?
Requirements Single-lines comments (e.g. — my comment) should be removed. Multi-line comments (e.g. /* my comment */) should be removed. The content of strings literals (e.g. ‘this is a multi-line comment: /* my comment */’) should be ignored. The content of identifiers (e.g. “– …