This is a code for comparing three numbers and to print the greatest value. When i try to run this pl sql code in oracle it says Can u tell me where it is wrong???I would be very grateful Answer You have 3 errors (typos): You need the DECLARE keyword before you start declaring variables. n2:=&n2: should b…
Facing issue while writing SQL in pyspark
I am trying to convert below SQL code to pyspark. Can someone please help me Here, util, count, procs are column names. while coding in pyspark, i can create a new column ‘col’ like this: Answer You can use when for doing the equivalent of update:
Redshift SQL — transposing rows by id into columns
I am using Redshift SQL. I would like to transpose the distinct rows of “Id1” in “Table” into columns. Thus the output should be like the bottom most table, providing weights as columns for each “Id2”.Or Alternatively, concatenate weights into one column. Any guidance on fu…
Oracle View loop on specific tables only
I got many tables of which some end with digits (date). Due to technical reasons I had to create a view on every table (just a workaround) The current state is something like: All it does is creating views for every table which begins with ‘XXX_’. Its almost what I need. But now, sometimes tablena…
Create an array in Snowflake
I want to create an array constructed from two timestamps. After that, use this as a range to find the difference between the first element and the second element. The goal is to find the time difference between timestamps within business hours (9 am to 17 pm). What should be the right approach here? Can I cr…
Arithmetic overflow error while converting varchar to decimal datatype
I am trying to convert varchar(14) to Decimal(14,2). My code is something like I am only getting Arithmetic overflow error message when the value of @varchar_variable is large (like ‘10000000000189’) Why am I getting this error message for larger values ? Are values like 10000000000189 out of rang…
How to prevent duplicate entry key when update
Problem explain I won’t update the last primary key of the 3 primary key concatenate. But the problem is sometimes the first and second primary key was the same for multiple records. And in this case, when I set my new value I have a duplicate entry key even I use sub-request to avoid that problem. Some…
VB.NET cmd.CommandText is not working properly with sql update
This is my subtract button, it will just subtract the qty in my database but the math logic is wrong, for example, If I said 12-2 it updates the qty to 6 Any of this 5 “cmd.CommandText is not working properly, it add and subtracts but the qty it updates to the database is wrong, it produces a wrong outp…
SQL/Presto: how to choose rows if the values match with another table’s
I have 2 tables: table 1: table 2: I want to add a column for table 2 such that if cnt in table1 for a task is the same as cnt2 for a task in table2. If there is no match, mark it as ‘no match’ desired result: I started from a query like the one below to pick tasks
Query on how to replace numerical data from a string/column
I have values in my column as below. Can anyone help me with how to replace any numeric data present in a column or string to blank using SQL Server query? Below is the column data. How do I replace the numbers to blank and display only underscores. Answer You could approach this by counting the number of und…