About 50 results
Open links in new tab
  1. sql - Case in Select Statement - Stack Overflow

    Jan 7, 2013 · Using a SELECT statement with a searched CASE expression. Within a SELECT statement, the searched CASE expression allows for values to be replaced in the result set …

  2. How do I perform an IF...THEN in an SQL SELECT?

    Sep 15, 2008 · The CASE expression cannot be used to control the flow of execution of Transact-SQL statements, statement blocks, user-defined functions, and stored procedures. If your …

  3. sql - How to write a select inside case statement - Stack Overflow

    I have a stored procedure that contains a case statement inside a select statement. select Invoice_ID, 'Unknown' as Invoice_Status, case when Invoice_Printed is null then '' else 'Y' end …

  4. case statement in select query in sql - Stack Overflow

    i need to set the column value of the destination table based on the two values of the select statement, some thing like the below example. insert into table table_name ( value1, value …

  5. sql - How do I execute different SELECT statements based on a …

    Jul 2, 2010 · Just put opening and closing bracket around select statement resolve you problem . select case when char_length('19480821')=8 then (select count(1) from Patient ) when …

  6. sql - Select inside CASE THEN - Stack Overflow

    Aug 25, 2015 · SELECT (CASE WHEN ISNULL(s.rate, 0) = 0 THEN (SELECT TOP 1 pr.rate FROM ProjectRates pr WHERE (pr.projectID = p.ID) AND (pr.effectiveDate < GETDATE()) …

  7. create select statement based on case statement in sql

    Jun 23, 2010 · Based on your case statement you can build a SELECT statement using a variable and then use sp_executesql to run it. The one thing to be aware of is that you need to make …

  8. How can I SELECT multiple columns within a CASE WHEN on SQL …

    Nov 22, 2016 · Here is the example of my query: SELECT ActivityID, Hours = (CASE WHEN ActivityTypeID <> 2 THEN FieldName = (Some Aggregate Sub Query), FieldName2 = (Some …

  9. sql - How to use select statement in CASE WHEN ELSE statement …

    May 6, 2015 · Hi you try with below query. select decode(pr_user_id,null,null,user_id),case when pr_user_id IS NOT NULL then user_name else 'NO PR_USER' end as primary_user_name …

  10. Best way to do nested case statement logic in SQL Server

    A simplified example: SELECT col1, col2, col3, CASE WHEN condition THEN CASE WHEN condition1 THEN CASE WHEN condition2 THEN calculation1 ELSE calculation2 END ELSE …

Refresh