Skip to content

Tag: oracle

PLSQL Selecting from table using an array into a variable

I am trying to select some records from a table using an array into the variable init_av_days but its not working out. init_av_days is to be committed to another table after this select query. How best do you suggest i do this? Answer init_av_days is to be committed to another table after this select query Be…

How to aggregate with join

I am very new to SQL and I was wondering if someone could help me find the quantity on hand (dqty-sqty) for each iname? This is what I’ve been trying to do so far but the total quantity that I get is wrong: Thanks so much! Answer you need to take the sum of the delivered and sold items individually

List of values as table

I’m looking for a smarter way to have a list of values as a table in Oracle. What I do nowadays is select ‘value1’ as val from dual union select ‘value2’ from dual What I’m hoping for is some …

Update row if exists or insert

I’m working on a web based PHP form that’s currently connect to an Oracle database. I’m trying to get the functionality working so that after a user submits the form it’ll check if a row exists based on the Job Number, if it does then update, otherwise insert the values. It’s bri…

SQL CASE Expression

I need to write a sql statement(Oracle) where I can withdraw data from two diff tables and check for a condition and return a certain string. My statement goes like this, When I run this I get a error: “FROM keyword not found where expected”and points to the c in line 2. and if I change the from t…

How to allow only numbers in (Oracle SQL)

I want to add a integrity constraint which only lets numeric data be added to the Unit_Price. Also, I have a email column in another table, how can I make it so a @ sign is required. Furthermore, if they dont enter email then it should be ‘ ‘unknow@gmail.con’ as default? Edit: Sorry the datatype was sup…

Oracle SQL closest date to given date

i have a table with a column for categories, date and price. Like this: So there are (almost) always two dates per group with two different prices. Now i need to write an SQL Statement to get the closest date per group to a given date(f.e. 05.05.2019). Group 1 has two dates an the SQL statement needs to Selec…