CASE statement Questions

1

Case Statements SQL
I’m running a query that returns a specific status code. However, within my query that specific status doesn’t always exist and I get a null value. I would like to return another status when that is the case. I can’t seem to get the case statement to work.

Answer Question   |  March 24, 2010  2:15 PM
CASE statement, SQL
asked by:
15 pts.

ms sql query problem with a case statement
[strong]This code works: SELECT     passengers.*, passship.passship_name AS name, passship.passship_speed AS speed, passship.passship_size AS cargo, hyperjump.hops AS hops, ROUND((passengers.pass_engers * passengers.pass_price) / (hyperjump.hops * passship.passship_speed), 0) AS ptprofit                        FROM         passengers INNER JOIN                       hyperjump ON passengers.pass_terms = hyperjump.startsystem AND passengers.pass_system = hyperjump.endsystem CROSS JOIN                       passship WHERE     (passship.passship_name = ‘Rinkratt’) ORDER BY ptprofit DESC, [...]

Answer Question   |  October 18, 2009  3:02 AM
CASE statement, MSSQL, SQL
asked by:
20 pts.

Making two records into one
I was not sure on how to word the title of my questions, so it is better if I simply give you my query and result: SELECT DISTINCT PJ.EMPL_NUM, (CASE WHEN PAY_TYPE = 1 THEN RATE ELSE 0 END) AS REG_RATE, (CASE WHEN PAY_TYPE = 3 THEN RATE ELSE 0 END) AS OVR_RATE FROM dbo.tblPayrollFlashJobDetail [...]

Answer Question   |  May 26, 2009  7:16 PM
CASE statement, SQL Records
asked by:
15 pts.

empty fields in a query
I have a column with answers that people responded to different questions about themseleves. I have another column with the question id that the answer corresponds to. i want to display the answers in separate columns based on which question it corresponds to. Each column should be filled with the answers to the specific question. [...]

Answer Question   |  May 8, 2009  4:20 PM
CASE statement, NULL, SQL Query
asked by:
60 pts.

Oracle SQL question
I want to create a SQL script in Oracle that will run one of two possible SQL scripts based on what the user enters in the Parameter request. Since I’m unable to use IIF and If Then like I can in SQL Server, is there another way to do this? I have tried using case [...]

Answer Question   |  April 22, 2009  2:39 AM
CASE statement, IF THEN statement, IIF statement, Oracle developers, Oracle development, Oracle SQL, SQL
asked by:
5 pts.

Nested Case statement in Oracle BI
I am trying to create a nested case statement in Oracle BI (9.0.4) the statement works when I do it in Oracle SQL*Plus but will not let me keep the whole script in the Calculation.What do I need to doo to have this work in Oracle BI? The statement is as follows: select emp_name, (CASE [...]

Answer Question   |  September 30, 2008  6:35 PM
CASE statement, Oracle BI (business intelligence), Oracle SQL
asked by:
5 pts.

Switch/Case statment in access
how i can use Switch/Case Satatment in Mic. Access 2003, am working on database as follow: Field Name: Directions in this field i need to write codes like: TAm Field Name: Translation here i need to read TAm as T=Take, Am= Morning. the problem i have more than 200 codes, which they have to be [...]

Answer Question   |  August 25, 2008  11:10 AM
Access 2003, CASE statement, Database programming, Microsoft Access
asked by:
15 pts.

How Do I assign a value if a value in the field is empty
In my script (that is not working yet) I want to make sure if “full_value” (a field) is empty in a particular record then the value zero will be inserted. This is working in Access, but I’m trying to rebuild the query in SQL. Thank you. SELECT DISTINCT oas_balance.cmpcode, oas_balance.el1, oas_balance.el2, oas_balance.full_value, CASE WHEN balcode [...]

Answer Question   |  August 13, 2008  12:31 AM
CASE statement, SQL, SQL Query
asked by:
50 pts.

I want to return multiple value in the THEN clause of CASE statement
I want to return multiple value in the THEN clause of CASE statement. SELECT c.company_code, c.com_inactive_flag, e.emp_no FROM company c, employees e WHERE c.com_code = e.com_code AND e.emp_status in ( (CASE c.com_inactive_flag WHEN ‘N’ THEN ‘A’ WHEN ‘Y’ THEN ‘B,C’ END) If the flag is N all those employees will be retrieved whoe has status [...]

Answer Question   |  August 11, 2008  4:08 AM
CASE statement, SQL
asked by:
5 pts.

Which Is More Optimized
Which Conditional Statemnt Is More Efficient in VB.NET 2005 IF ELSE OR Switch Case ?

Answer Question   |  August 8, 2008  11:30 AM
CASE statement, IF ELSE statement, VB.NET, Visual Basic 2005
asked by:
70 pts.

CASE sintaxis error in SELECT
In the middle of a large storage procedure I have a working SELECT 01 (see below) which at a couple of points uses CASE statement. I need to expand the most inner CASE to get SQL Server check for several values instead of one. Currently CASE I am talking about looks like (it is in [...]

Answer Question   |  July 19, 2008  7:46 PM
CASE statement, SELECT statement, SQL Server 2005, T-SQL
asked by:
5 pts.

Order by using case statement SRS 2000
I am using a case statement to order data on a SRS report, when the statement is ran, it returns the correct order, but when I save the RDL and preview it, it returns to ascending order. How do I correct this?

Answer Question   |  September 20, 2008  6:38 PM
CASE statement, SQL Server Reporting Services, SRS 2000
asked by:
5 pts.

Using Case Statement Inside SQL Join
Hi, I am trying to convert dynamic sql into static sql due to permission issue, I faced a challange when i am trying to convert this part of code given below -- join to ADDR_DETAIL SET @join_sql = 'inner join ADDR_DETAIL on ADDR_DETAIL.GRP_CONTACT_ID = pm.GRP_CONTACT_ID AND ' IF (@ChannelEntity = '') OR (@ChannelEntity IS NULL) [...]

Answer Question   |  March 17, 2008  11:08 AM
CASE statement, JOIN statement, SQL, T-SQL
asked by:
5 pts.

ms sql case statement
I have written a case statement in MS SQL that is returning a single phone number for a single id. This is valid as the database contains multiple phone numbers attached to the same id number, with differentiation based on phone type. Once I have found the prefered phone number, I do not want to [...]

Answer Question   |  March 6, 2008  7:08 PM
CASE statement, SQL
asked by:
5 pts.

How to use subselect in a case statement
Getting error… “Token EXISTS was not valid….” on case statement… ,case when g.GFGSTS = ’2′ and not exists (select a.GFTSEQ from GFTP010 a where a.GFCSQ# = g.GFCSQ# and a.GFGSTS = ’3′ ) then count(*) end as Void#

Answer Question   |  January 17, 2008  3:11 PM
CASE statement, SQL, SQL Subselect
asked by:
5 pts.

1