how can I convert int like ‘1984’ to date and display it as century SQL Oracle? Answer If the column is a date/time or timestamp:
Tag: oracle
count distinct if a condition is satisfied
I have a table which shows if a address_no has a telephone or not. To determine, i am looking at cell_phone and house_phone columns and want to write ‘no phone’ only when house_phone and cell_phone is …
SELECT Data with logic created date not greater than
I have three tables with detail structure and data like this : Table TBL_REFERRAL ID CREATED_DATE USER_NAME REFERRAL_CODE ——————————————————— 1 …
Display data of a column as a row in Oracle
First of all, I would like to thank you so much for your time in advance. I have a table as shown below: I would like to display the data from the above table as shown below: If no data is present within the COL_DESC for a row then the data from the COL_NAME column needs to be displayed. I
StartDate invalid identifier
I have two SELECT statment which I connect using UNION and I get error Since I create first one SELECT statment and run and I get result, and second also, so I run separatly and it works perfect. But when I use UNION I get error pusd2.StartDate invalid identifier. What is wrong here ? What I made wrong ? Tabl…
How to merge more than two select queries to single result set in oracle
I need to merge the result set of four queries into single result output. Example: I need the output in the below format Answer One option would be applying Conditional Aggregation during joining of the tables :
oracle sum by column without using union
I have this table: (supply table: how many products in storages) I should write a query to have this result: “Total_except_storage_30” has the total of every product in storages except storage number 30. For example first “total_except_storage_30” is for product_id 1000 in all storages…
DateAdd function in Oracle SQL
How can I convert DATEADD(week,-4,GETDATE())in the where clause ( in Oracle SQL) Trying to get data for prior 4 weeks Answer In Oracle, you would use: Or, if you prefer:
Randomly flagging records in an Oracle Table
Given a table of IDs in an Oracle database, what is the best method to randomly flag (x) percent of them? In the example below, I am randomly flagging 20% of all records. ID ELIG 1 0 2 0 3 0 4 …
Count one column by considering another column
This is my Audit table: I need to write 2 different queries and I have no idea how should I write them: How many invoices do have ONLY product 2 (+ Total price)? How many invoices do have diffrent products but product 2 as well (+ Total price)? the result I want looks like this: Answer If I understand correct…