In my company, each department has their own statuses for purchase orders. I’m trying to load only the pertinent POs for a specific user’s department. I keep getting errors. It seems like it should be correct, though. I initially attempted to use a Case statement, but it appears that SQL can only do a simple return from a case, so
Tag: conditional-statements
Alter SQL column based on comparison of number of elements
I have a table with columns (Id, Prod, Id) and I must create a (Flag) like this: This (Flag) is created by grouping by (Id2) and assigning 0 for the lowest (Id) and 1 otherwise. I tried using group by to no avail. How can I do that? Answer You can use a case expression with a windowed function: Example
LIKE group_concat with where clause
i am using Like in group concat & i want to get all modules attached to client even if it does not match to LIKE, i know that that i can do that with HAVING but i don’t want to use HAVING, any solution with WHERE or in join condition ? Any suggestions on how to get my expected result??
SQL conditions – select ID who have multiple values in a column
Having this COLORS table: How do I select the ID who have both COLOR RED & PINK? (Could be more than 2 colors) SELECT ID FROM COLORS WHERE COLOR IN (‘RED’) AND …
Sql conditional Join statement
I have this sample I want to code this case in sql : When i have a null value in “ASS_OT_Traveaux.CodeEquipement” it doesnt show any data Answer
How to use conditions with a RANK statement
The following piece of code does its job : it gives me the top 10 results for each category. SELECT * FROM ( SELECT *, RANK() OVER (PARTITION BY “pera_id” ORDER BY “surface” DESC) …
SQL How to select from multiple values in joined table
I have two tables A and B joined with a common id field. Table A has single entries per id. Table B has multiple entries per id. Table B has two columns “name” and “customertype”. …
Hive query conditional statement in same select query
Is there a way to get in one single hive query to do a if-else kind of setup. In the my data below I want to ensure that if Model is empty or having ‘-‘ I populate the Final column with Device else it should be populated with Model Can someone please help here. Answer Read about CASE operator syntax.
How to split a column into multiple columns by condition delimeter in SQL?
could anyone help me please? I have this column Column
John > Doe Doe > Writer
Jane > Doe > Chemical Engineer > Sovena
I want to my final result to be …
How to use aggregate functions in SQL Server
I have a situation where I have a Customer table and I need to locate document numbers from a column which is structured as a string where the first 4 characters represent the type of document (e.g.,’…