score:2
Accepted answer
If you need to pick up "first" IDType you can do it with one of window function, say ROW_NUMBER
SELECT * FROM
(
SELECT t.* , ROW_NUMBER() OVER (ORDER BY IDType ) rn
FROM table1 t
WHERE IDType IN (1,2,4,5,6,7,8,9,10,11,12,13,15,16,17,18,19)
) a
WHERE rn =1;
Updated to add partition by employee_id
(assuming table has employee_id
field)
SELECT * FROM
(
SELECT t.* , ROW_NUMBER() OVER (PARTITION BY t.employee_id ORDER BY IDType ) rn
FROM table1 t
WHERE IDType IN (1,2,4,5,6,7,8,9,10,11,12,13,15,16,17,18,19)
) a
WHERE rn =1;
score:1
In SQL Server COALESCE does not have explicit limitation about quantity on parameters.
Your reading your problem it sounds like a logic problem, that you must have resolve using the Case (Transact-SQL).
COALESCE (Transact-SQL) is to resolve null issues.
More questions
- Limit of arguments on Coalesce SQL function?
- SQL filtering with COALESCE or window function
- Have an upper limit for SUM() function sql
- SQL Performance using a COALESCE Function
- SQL Server: more than two tables for coalesce function
- SQL Server COALESCE function with WHERE clause
- Incosistency between MS Sql 2k and 2k5 with columns as function arguments
- Labview and SQL stored procedure - Procedure or function StoreTemp has too many arguments specified
- Trouble using COALESCE function in sql
- SQL Server stored procedure or function has too many arguments specified, when trying to pass 2 arguments in C#
- Procedure or function has too many arguments SQL server
- Function has too many arguments specified in Sql query
- Function vs. Stored Procedure in SQL Server
- Is there a Max function in SQL Server that takes two values like Math.Max in .NET?
- Simulating group_concat MySQL function in Microsoft SQL Server 2005?
- How to create a SQL Server function to "join" multiple rows from a subquery into a single delimited field?
- Equivalent of LIMIT and OFFSET for SQL Server?
- LIMIT 10..20 in SQL Server
- How to implement LIMIT with SQL Server?
- How to report an error from a SQL Server user-defined function
- How to check if a function exists in a SQL database?
- LEN function not including trailing spaces in SQL Server
- C# equivalent of the IsNull() function in SQL Server
- SQL function as default parameter value?
- Aggregate function in an SQL update query?
- COALESCE Function in TSQL
- How do I use the CONCAT function in SQL Server 2008 R2?
- SQL Row_Number() function in Where Clause
- SQL Server function to return minimum date (January 1, 1753)
- SQL Coalesce with empty string
More questions with similar tag
- How to create sequential number column index on table with data
- Append Values to JSON object in SQL 2016 / Modify JSON object (SQL Server JSON Data)
- Can you do an SQL INNER JOIN statement that has more than one INNER JOIN condition?
- How to get Sub string Using Sql Server 2008?
- Update not yielding correct results
- Building a view column out of separate columns
- sql server cmdlet (sqlps) and remote server
- Split values into separate rows
- How do you model custom attributes of entities?
- select single row of multiple records in One to Many relation tables
- How to do I connect to a SQL Server instance from PHP 7 on an AWS Amazon Linux EC2 instance?
- Optimizing performance of flexible Linq to Entity criteria when retrieving rows from huge database
- Updating database in Transaction from List<T>
- Error handling in SqlBulkCopy
- Is this an efficient sql server query?
- Failed To Create Assembly in MS SQL SERVER
- IsSystemObject attribute of smo
- Update multiple columns of a table using aggregate values from another table
- Extracting data from XML Array using SQL
- use case to 'Name and Extension', 'Full Qualified' and 'Name Only' options in foreach file enumerator in ssis
- .Net Application Installation 2012 with database
- Getting Balance from Subtracting Total Amount from a Number of Balance
- Setting sqlcmd variable using tsql variable
- VB.Net: Escape singles quotes in query string that uses a variable with single quotes
- How to validate a login in Azure SQL databases
- There is already an object named 'tableName' in the database
- Group by Datetime with a condition
- Spring Data JDBC with Azure SQL: After saving the identifier must not be null
- SQL Query to get count of one status + all other status as one
- Programmatic Comparison of SQL Server Versions using TSQL
Source:
stackoverflow.com