Tag case

[Solved] SQL, SUM + CASE [closed]

Never use commas in the FROM clause. Always use proper, explicit JOIN syntax. Then, you cannot nest aggregation functions, so this should be sufficient: SELECT o.ID_DOSSIER, SUM(CASE WHEN ID_TYPE IN (‘0’, ‘1’) THEN TTL * -1 WHEN ID_TYPE IN (‘2’,…

[Solved] Assig multiple columns in a case statement?

Your sample desired output isn’t all clear in my opinion, but maybe this is what you want? SELECT [FileName], CASE WHEN [FileName] LIKE ‘ATE_%’ THEN CAST(SUBSTRING([FileName],5,5) AS NVARCHAR(100)) WHEN [FileName] LIKE ‘%Adhoc%’ THEN CAST([FileName] + ‘ ‘ + [SheetName] AS…

[Solved] PHP case errors [closed]

Your code is not clear enough ! because the CASE statement is used after using the switch statement but as i see their were no switch statement in your code so i don’t know if this is a type or…

[Solved] Query SyntaxError [closed]

Either use single quotes, like q = “select tbuc.csId, tbuc.uId, tbuc.cId, tbui.role_type, tbuc.time as login_date” + “, tbuc.sessId, (case when tbui.role_type=”ROLE_USER” then 1 else 0 end) ” + “as assignment_submitted FROM tb_user_click tbuc, tb_user_info tbui WHERE ” + “tbui.user_id =…

[Solved] SQL server SELECT CASE large script [closed]

Try This , Create another table like this CREATE TABLE [dbo].[Table_1]( [Col2] [nvarchar](50) NULL, [CaseVal] [nchar](10) NULL ) ON [PRIMARY] Insert all the Distinct data what you have. Then write a sql like below SELECT b.Col1, b.Col2, a.CaseVal TargetAliasColumnName FROM…

[Solved] from keyword not found where expected in case statement

Looks like there is comma missing. Also you need to use the entire case statement in group by not the column name alone SELECT To_date(To_char(BATCH_CREATION_TIME,’YYYY/MM/DD’),’YYYY/MM/DD’) AS CREATION_DATE, Sum(Decode(CDR_ACTUAL_COUNT,NULL,0,CDR_ACTUAL_COUNT)) AS CCOLLECTED, Sum(Decode(CDR_ACTUAL_COUNT,NULL,0,CDR_ACTUAL_COUNT)) – Sum(Decode(CDR_PARSE_ERROR_COUNT,NULL,0,CDR_PARSE_ERROR_COUNT)) – Sum(Decode(CDR_DISCARD_COUNT,NULL,0,CDR_DISCARD_COUNT)) AS COLLECTED, Sum(Decode(VALIDATION_CNR_COUNT,NULL,0,VALIDATION_CNR_COUNT)) + Sum(Decode(VALIDATION_CE_COUNT,NULL,0,VALIDATION_CE_COUNT))…

[Solved] Function in a switch case loop [closed]

No, you cannot. Functions cannot be generally declared inside another function. You can only define them. The language was designed like that. Also see these: Function Declaration and Function Prototypes C – Functions Declaring a function – function prototypes I…