[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’, ‘3’) THEN TTL END) FROM ope o JOIN actor a ON o.ID_ACTION = a.ID_ACTION GROUP … Read more

[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 NVARCHAR(100)) WHEN [FileName] LIKE ‘AdvantageData%’ THEN [SheetName] END AS ABTALookUp, CASE WHEN [FileName] LIKE ‘ATE_%’ … Read more

[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 not Then the using of the case must be look like this : switch(VARIABLE_NAME) { … Read more

[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 = tbuc.uId and tbuc.csId = tbui.class_section_id;” Or escape the double quotes, like q = “select tbuc.csId, … Read more

[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 Table_1 a inner join [dbo].[Table1] b on a.col2=b.Col2 1 solved SQL server SELECT CASE large … Read more

[Solved] C Looping a switch using Y/N options. Choosing N doesn’t close the program

change scanf(“%s”, &input); to scanf(” %c”, &input); and get rid of getchar()s at the end. It will work as you wanted. %c specifier reads a char character, but it does not omit whitespace characters. Putting space onto scanf’s format will deal with whitespaces and read first non-whitespace char. To be more clear, see what man … Read more

[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)) + Sum(Decode(VALIDATION_CR_COUNT,NULL,0,VALIDATION_CR_COUNT)) + Sum(Decode(VALIDATION_NCR_COUNT,NULL,0,VALIDATION_NCR_COUNT)) AS ERRORED, Sum(Decode(VALIDATION_RNC_COUNT,NULL,0,VALIDATION_RNC_COUNT)) + Sum(Decode(VALIDATION_RV_COUNT,NULL,0,VALIDATION_RV_COUNT)) AS PROCESSED , CASE WHEN CDR_SOURCE_TYPE … Read more