Discussions
Categories
- 197K All Categories
- 2.5K Data
- 546 Big Data Appliance
- 1.9K Data Science
- 450.8K Databases
- 221.9K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 552 MySQL Community Space
- 479 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.1K ORDS, SODA & JSON in the Database
- 556 SQLcl
- 4K SQL Developer Data Modeler
- 187.2K SQL & PL/SQL
- 21.4K SQL Developer
- 296.3K Development
- 17 Developer Projects
- 139 Programming Languages
- 293K Development Tools
- 110 DevOps
- 3.1K QA/Testing
- 646.1K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 158 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.2K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 19 Java Essentials
- 162 Java 8 Questions
- 86K Java Programming
- 81 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 205 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 468 LiveLabs
- 39 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 175 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 233 Portuguese
Export query result to Excel file

Hello together,
i have to work with a database now i got the problem that i have only readersonly function so i got no possibility to add an additionaly column. Now i got an idea where i want to export my query result to an excel file or into a R-file. So if there a way to export this would be great.
This is my little Code:
select reporting_dt, contract_id, sum(RATING_CONTRACT_CLASS_CD_1) - lag(sum(RAting_contract_class_cd_1), 1, 0) over (partition by contract_id order by reporting_dt ) as delta
from database
where reporting_dt>='31.12.2019' and RATING_CONTRACT_CLASS_CD_1!='U'
group by reporting_dt, contract_id
order by delta asc
);
Would be great if you could help me.
Thank you
Answers
-
lemalhu wrote:Hello together, i have to work with a database now i got the problem that i have only readersonly function so i got no possibility to add an additionaly column. Now i got an idea where i want to export my query result to an excel file or into a R-file. So if there a way to export this would be great. This is my little Code:select reporting_dt, contract_id, sum(RATING_CONTRACT_CLASS_CD_1) - lag(sum(RAting_contract_class_cd_1), 1, 0) over (partition by contract_id order by reporting_dt ) as deltafrom databasewhere reporting_dt>='31.12.2019' and RATING_CONTRACT_CLASS_CD_1!='U'group by reporting_dt, contract_idorder by delta asc);Would be great if you could help me. Thank you
It is certainly possible to have Excel pull data from an external data source like Oracle database. Several of the business analysts at my org do so.
As for needing to add another column, why don't you discuss this with your DBA or app support team? It sounds like you are trying to solve your issue all by yourself instead of working with others.
-
Why export to an Excel file? What is that going to achieve?
When you say read only, you mean you can't add columns to tables? Can you create views?
By the way, if reporting_dt is a date, then you shouldn't be comparing to a string '31.12.2019' - that is NOT a date, you are relying on implicit conversion to a date. You should do
reporting_dt >= to_date('31.12.2019', 'dd.mm.yyyy')
-
SQL*Developer can export to Excel.
Also, Oracle supplies an Excel plugin to fetch/update REST enabled tables (via ORDS).
If "REPORTING_DT" is a DATE data type column, that is not how you compare DATEs. Do not rely on implicit conversions. Use the TO_DATE() (with format) or the ANSI SQL keyword DATE (and correct date format).
MK
-
Hi,
Whenever you have a problem, start by explaining exactly what the problem is.
Don't mistake a solution for a problem. Adding an additional column to a table, exporting data to a spreadsheet, and the query you posted all look like possible solutions to some problem. The first thing you have to explain is what the problem is.
Post CREATE TABLE and INSERT statements for a little sample data in any existing tables.
lemalhu wrote:...where reporting_dt>='31.12.2019' and ...
Use DATE columns for dates, and don't try to compare DATEs to strings, such as '31.12.2019'.
-
So sorry for my unclear formulation.
I spoke with some guys in our company and they told me for me its not possible to join anything in this database because im only there for an internship.
So they said i have to try it in R. So my idea was to export my results in SQL to R and join the necessary colmn there.
Thanks for your help im new in this business and at the moment its quite hard to learn everything, so sorry for some miscomunication at the beginning
-
With sqlplus you can do
spool yourtextfile.txt
your statement goes here
spool off
The output is written into the file as it woulb be display on the screen.
There are several options to customize this output like set feedback off etc.
For those you might take a closer look into the docs on sqlplus.
Furthermore there is this newe version of sqlplus called sqlcl with seems to be qit more handy for this kind of task, e. g. it offers an export function for csv inherently.