Need a query for export table data .....
Hi,
I need a query for exporting the data in a table to a file.
Can anyone help me ?
Thanking You
Jeneesh
SQL> spool dept.txt
SQL> select * from dept;
DEPTNO DNAME LOC
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
SQL> spool off
SQL> ed dept.txt
Similar Messages
-
Need a query for access tables
Hi
I need a query , help please:
table1:
id description serial
1 des1 ser1
2 des2 ser2
3 des3 ser3
table2:
id id1(id of table1) date
stat
1 1
2001 A
2 1
2008 N
3 2
2010 A
4 1
2012 F
==============
i need this data structure: (stat column must return for maximum date of id1 from table2)
id(from table1) serial(from table1) stat(from table2)
1 ser1
2012
2 ser2
2010
3 ser3
Nullmaybe you can try this.
declare @t1 table
(id int,[description] varchar(50),serial varchar(10))
declare @t2 table
(id int,id1 int,[date] char(4),stat char(10))
insert into @t1 values
(1,'des1','ser1'),
(2,'des2','ser2'),
(3,'des3','ser3')
insert into @t2 values
(1,1,'2001','A'),
(2,1,'2008','N'),
(3,2,'2010','A'),
(4,1,'2012','F')
select a.id,a.serial,max(b.date)
from @t1 a
left join @t2 b
on a.id = b.id1
group by a.id,a.serial
| SQL PASS Taiwan Page |
SQL PASS Taiwan Group
|
My Blog -
Need a query for monthly Report
Hello All,
I need a query for monthly report,
comp_code
emp_id
dept_id
work_day
100
A100
MECH
01/01/2013
100
A100
MECH
02/01/2013
100
A100
MECH
03/01/2013
100
A100
MECH
04/01/2013
100
A100
MECH
05/02/2013
100
A100
MECH
08/02/2013
100
A100
MECH
09/02/2013
100
A100
MECH
10/02/2013
100
A100
MECH
12/05/2013
100
A100
MECH
13/05/2013
100
A101
CIV
01/04/2013
100
A101
CIV
02/04/2013
100
A101
CIV
03/04/2013
100
A101
CIV
04/04/2013
100
A101
CIV
06/04/2013
100
A101
CIV
06/06/2013
100
A101
CIV
07/06/2013
100
A101
CIV
08/06/2013
100
A101
CIV
09/06/2013
100
A101
CIV
10/06/2013
100
A101
CIV
11/12/2013
100
A101
CIV
12/12/2013
100
A101
CIV
13/12/2013
100
A101
CIV
14/12/2013
Dear friends this the sample table of my report.In which table has contain list of employees with their working days(actual table has contain almost 5laks of records).
suppose user choose the date between 01/01/2013 and 31/12/2013 then the result should be like this.
comp_code
emp_id
dept_id
month
Total_work
100
A100
MECH
JANUARY
4
100
A100
MECH
FEBRUARY
2
100
A100
MECH
MARCH
0
100
A100
MECH
APRIL
0
100
A100
MECH
MAY
2
100
A100
MECH
JUNE
0
100
A100
MECH
JULY
0
100
A100
MECH
AUGUST
0
100
A100
MECH
SEPTEMBER
0
100
A100
MECH
OCTOBER
0
100
A100
MECH
NOVEMBER
0
100
A100
MECH
DECEMBER
0
100
A101
CIV
JANUARY
0
100
A101
CIV
FEBRUARY
0
100
A101
CIV
MARCH
0
100
A101
CIV
APRIL
5
100
A101
CIV
MAY
0
100
A101
CIV
JUNE
5
100
A101
CIV
JULY
0
100
A101
CIV
AUGUST
0
100
A101
CIV
SEPTEMBER
0
100
A101
CIV
OCTOBER
0
100
A101
CIV
NOVEMBER
0
100
A101
CIV
DECEMBER
4Hi,
If you want the output to include months where no work was done (with 0 in the total_work column) then you need to outer-join a "table" that has one row per month, and make it a partitioned outer join:
WITH got_end_points AS
SELECT TRUNC (MIN (work_day), 'MONTH') AS first_month
, TRUNC (MAX (work_day), 'MONTH') AS last_month
FROM table_x
, all_months AS
SELECT ADD_MONTHS (first_month, LEVEL - 1) AS a_month
, ADD_MONTHS (first_month, LEVEL) AS next_month
FROM got_end_points
CONNECT BY LEVEL <= 1 + MONTHS_BETWEEN (last_month, first_month)
SELECT t.comp_code
, t.emp_id
, t.dept_id
, m.a_month
, COUNT (t.work_day) AS total_work
FROM all_months m
LEFT OUTER JOIN table_x t PARTITION BY (t.comp_code, t.emp_id, t.ept_id)
ON t.work_day >= a.a_month
AND t.work_day < a.next_month
GROUP BY t.comp_code
, t.emp_id
, t.dept_id
, m.a_month
ORDER BY t.comp_code
, t.emp_id
, t.dept_id
, m.a_month
As posted, this include every month that is actually in the table. You can change the first sub-query if you want to enter first and last months.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
Point out where the query above is giving the wrong results, and explain, using specific examples, how you get the correct results from the given data in those places. If you changed the query at all, post your code.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002 -
How to Export Table Data to a excel sheet using OPENROWSET
Hi Team,
I would like to Export table data to a excel sheet by using "OPENROWSET" command in SQL Server but I am getting the
below error message
Column name or number of supplied values does not match table definition.
Please help me on how to export the table data to an excel sheet by using "OPENROWSET" in SQL ServerI know this is old so I assume you've fixed this. However, for anyone else looking at this forum, I'd recommend using a union or a table join.
Select a.1, a.2, a.3 from a <where clause>
union
Select b.1, b.2, b.3 from b <where clause>
or
use a type of join.
If both table selects return the same number of columns but different data just reference them as a variable like fred, and Ted
Select fred.1, fred.2, fred.3 from (Select a.1, a.2, a.3 from a) fred
union
Select Ted.1, Ted.2, Ted.3 from (Select b.1, b.2, b.3 from b) Ted
or again some type of join of these two sets
Select * from
(Select a.1, a.2, a.3 from a) a
INNER JOIN (Select b.1, b.2, b.3 from b) b ON b.1 = a.1
This would give you 6 columns of data a1-3, and b1-3
We don't know from your description what format your spreadsheet is in. These just give you the idea. Think of the sub-selects as a Table. It's just named "fred". Once your select holds all the data you need, then export the data to the spreadsheet. Use
the horsepower of the database before trying to do a multple update of the same spreadsheet.
Does this give you enough to fix what you were trying to do? -
Exporting table data to Excel sheet:
Hi All
My requirement is need to export table data to Excel sheet: for this
I was done all, but I'm getting 500 Exception please contact u r system admin msg at run time, also Jxl/Workbook class not found msg but I downloaded Jxl.jar file and its showing in navigator>Lib>jxl.jar. There is no error signals in coding part.
Thanks
PolakaHi,
Copy your jxl.jar and open it with winzip. See if there is Workbook.class file inside it in the folder jxl.
Try to download jxl.jar from this link
http://www.java2s.com/Code/Jar/JKL/Downloadjxljar.htm
and add.
Best Wishes
Idhaya R -
How can we export table data to a CSV file??
Hi,
I have the following requirement. Initially business agreed upon, exporting the table data to Excel file. But now, they would like to export the table data to a CSV file, which is not being supported by af:exportCollectionActionListener component.
Because, when i opened the exported CSV file, i can see the exported data sorrounded with HTML tags. Hence the issue.
Does someone has any solution for this ... Like, how can we export the table data to csv format. And it should work similar to exporting the data to excel sheet.
For youre reference here is the code which i have used to export the table data..
><f:facet name="menus">
><af:menu text="Menu" id="m1">
><af:commandMenuItem text="Print" id="cmi1">
><af:exportCollectionActionListener exportedId="t1"
>title="CommunicationDistributionList"
>filename="CommunicationDistributionList"
>type="excelHTML"/> ---- I tried with removing value for this attribute. With no value, it did not worked at all.
></af:commandMenuItem>
></af:menu>
></f:facet>
Thanks & Regards,
Kiran KonjetiHi Alex,
I have already visited that POST and it works only in 10g. Not in 11g.
I got the solution for this. The solution is :
Use the following code in jsff
==================
<af:commandButton text="Export Data" id="ctb1">><af:fileDownloadActionListener contentType="text/csv; charset=utf-8"
>filename="test.csv"
>method="#{pageFlowScope.pageFlowScopeDemoAppMB.test}"/>
></af:commandButton>
OR
<af:commandButton text="Export Data" id="ctb1">><af:fileDownloadActionListener contentType="application/vnd.ms-excel; charset=utf-8"
>filename="test.csv"
>method="#{pageFlowScope.pageFlowScopeDemoAppMB.test}"/>
></af:commandButton>
And place this code in ManagedBean
======================
> public void test(FacesContext facesContext, OutputStream outputStream) throws IOException {
> DCBindingContainer dcBindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
>DCIteratorBinding itrBinding = (DCIteratorBinding)dcBindings.get("fetchDataIterator");
>tableRows = itrBinding.getAllRowsInRange();
preparaing column headers
>PrintWriter out = new PrintWriter(outputStream);
>out.print(" ID");
>out.print(",");
>out.print("Name");
>out.print(",");
>out.print("Designation");
>out.print(",");
>out.print("Salary");
>out.println();
preparing column data
> for(Row row : tableRows){
>DCDataRow dataRow = (DCDataRow)row;
> DataLoaderDTO dto = (DataLoaderDTO)dataRow.getDataProvider();
>out.print(dto.getId());
>out.print(",");
>out.print(dto.getName());
>out.print(",");
>out.print(dto.getDesgntn());
>out.print(",");
>out.print(dto.getSalary());
>out.println();
>}
>out.flush();
>out.close();
> }
And do the following settings(*OPTIONAL*) for your browser - Only in case, if the file is being blocked by IE
==================================================================
http://ais-ss.usc.edu/helpdoc/main/browser/bris004b.html
This resolves implementation of exporting table data to CSV file in 11g.
Thanks & Regards,
Kiran Konjeti -
Export table data in a flat file without using FL
Hi,
I am looking for options where I can export table data into a flat file without using FL(File Layout) i.e., by using App Engine only.
Please share your experience if you did anything as this
ThanksA simple way to export any record (table/view) to an csv fiel, is to create a rowset and loop through all record fields, like below example code
Local Rowset &RS;
Local Record &Rec;
Local File &MYFILE;
Local string &FileName, &strRecName, &Line, &Seperator, &Value;
Local number &numRow, &numField;
&FileName = "c:\temp\test.csv";
&strRecName = "PSOPRDEFN";
&Seperator = ";";
&RS = CreateRowset(@("Record." | &strRecName));
&RS.Fill();
&MYFILE = GetFile(&FileName, "W", %FilePath_Absolute);
If &MYFILE.IsOpen Then
For &numRow = 1 To &RS.ActiveRowCount
&Rec = &RS(&numRow).GetRecord(@("RECORD." | &strRecName));
For &numField = 1 To &Rec.FieldCount
&Value = String(&Rec.GetField(&numField).Value);
If &numField = 1 Then
&Line = &Value;
Else
&Line = &Line | &Seperator | &Value;
End-If;
End-For;
&MYFILE.WriteLine(&Line);
End-For;
End-If;
&MYFILE.Close(); You can of course create an application class for generic calling this piece of code.
Hope it helps.
Note:
Do not come complaining to me on performance issues ;) -
Exporting table data to a CSV file
hello everyone,
i need help on exporting table data to a CSV file.
I have a div element containing the table which displays some data.
there is a "Export" button just above the table, which if clicked, will export the current data in the table to a .csv file.
can this be done in jsp? or i need to use servlet?
also how can i submit the table data only? (as my webpage contiain other data also)
can anyone provide with some sort of sample code?
thanks in advance!!oops!!
i just forgot..
when the user will click on the export button, i want to greet him with a "Save As"
popup, so that he can specify the filename and location to save the file.
thanks!! -
Exporting table data to MS-Excel Sheet(enhanced Web Dynpro Binary Cache)
Hi experts,
I am trying to implement the functionality of downloading the contents of a webdynpro screen to excel sheet. In order to implement the functionality of excel download i used the following blog.
[/people/subramanian.venkateswaran2/blog/2006/08/16/exporting-table-data-to-ms-excel-sheetenhanced-web-dynpro-binary-cache ]
In this blog they have used javaexcel api to implement the excel functionality. I face some problems
while implementing it.
i) The use of "Label label = new Label(0, 2, "A label record");
sheet.addCell(label); " is not supported. It says that a constructor for label with
(int, int, str) parameter is not available.
ii) Then i implemented it with "Label label = new Label("A label record"); " Then i deployed it. I got a runtime exception saying that " java.lang.ClassNotFoundException: jxl.format.CellFormat ".
This cellFormat is an interface available in the jar. I am using jexcelapi_2_6_9_1.4 version. Do i have to
download some other versions.
Please help. Thanks in advance.
Regards
RamananHi,
Please check the following steps while creating External Library DC:
1) creating an Extneral library DC
2) import the JARs to the libraries folder of the External Library DC project
3) Right-click on each of the JARs imported to the project and add them to the public part.
This DC is now ready to be used as a build-time reference that will allow CBS to build the "main" Web Dynpro application that will use the external libraries. Next, we have to create a new Web Dynpro DC to hold the class files here are the steps:
1) Create a new Web Dynpro DC
2) Create a new public part, selecting the "Can be packaged into other build results" option
3) Rename the JARs as Zip files and extrct the full content (folders and class files) to your root folder
4) Import the folders and files to the src/packages folder
5) Expand the public part node that was created and select the "Entities" node, right-click it and choose Edit
6) In the Entity Type list select the "Folder" option then in the selected entities tree pick each of the folders that you imported in step 5 (above)
7) Now do a DC build and a DC deploy of the project
Then check-in, activate, and release any activities you have associated with creating these two projects. In the DC perspective, refresh the Active DCs and Inactive DCs to ensure that both new DCs appear in the Active list. Now we have to setup the references to these DCs in our main Web Dynpro application. To do this, follow these steps:
1) Open the Web Dynpro perspective and right click the Used DCs node then choose "Add Used DC.."
2) Pick the public part of the External Library DC that we created (first) and set it to have a Build Time dependency
3) Again, right click the Used DCs node and choose "Add Used DC.." then choose the public part of the Web Dynpro DC that we created and give it a Run Time dependecy (weak) and click finish.
4) Now, due to what I think is a bug. You must right click on the Web Dynpro "used DC" that you just added in the previous step, and set the run time dependency again (it seems to revert to the default values for some reason)
5) Now do a DC build and a DC deploy on the "main" web dynpro application.
6) Check-in, activate, and release any activities associated with adding these references and then others on your team may use the classes in the external libraries within the Web Dynpro project.
Regards.
Rajat -
How to export table data to excel in albpm
Hi,
we have an requirement to export table data to excel .
we have to create an jsp in that jsp we have to have text fileds,we have to enter data to field after that we have to click on save once u click on save that data has to enter in below table and we should provide link to export that table data to excel.
this is our totatl requirement.can u please suggest me how to do,i dont have any idea..
Regards,
Sharmila
Edited by: user12171025 on Nov 5, 2009 8:44 PMHi Daniel
Please have a look at below docs :-
/people/subramanian.venkateswaran2/blog/2006/08/16/exporting-table-data-to-ms-excel-sheetenhanced-web-dynpro-binary-cache
http://wiki.sdn.sap.com/wiki/display/WDJava/ExporttoExcel(WithoutthirdpartyAPIs)
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d01854fd-1579-2c10-63ad-dd62edca2381?quicklink=index&overridelayout=true
Regards
Arun Jaiswal -
Hello, i use af:exportCollectionActionListener component to export table data to Excel.
there are 100 000 rows in my table. But only 65 535(may be is consilience that ushort = 0 to 65535) rows was exported.
what are problems? Anybody know?
Edited by: Beliansky Alexander on Sep 5, 2012 7:02 AMIf i am not wrong thats a limit of excel. Not sure but.Google
taken from "http://msdn.microsoft.com/en-us/library/office/ff700514.aspx"
"Starting in Excel 2007, the "Big Grid" increases the maximum number of rows per worksheet from 65,536 to over 1 million, and the number of columns from 256 (IV) to 16,384 (XFD). "
Edited by: in the line of fire on Sep 5, 2012 6:06 PM -
Hi Gurus,
I am wondering if anyone can offer some advice in regards to export table data from a source and import it to another system.
We have a development environment (say, Banner_dev) and a production one (say, Banner_Prod). We routinely perform database refresh from Banner_Prod to Banner_dev, using Oracle Rman cloning. However, the developers are not happy with this approach saying that other things (such as packages, functions, procedures) get overwritten.
We (DBAs) have been asked to see if we can use export/import approach so that only data within a schema will be exported and imported, leaving other objects untouched in Banner_Dev when we refresh the database from Banner_Prod to Banner_Dev.
Is this doable with Oracle Data Pump? If it is, how can we accomplish this?
Thanks!You might consider a layered, scripted approach that takes into account the differences between the production and development environments. You might want to take into account things like differences between table DDL, data upgrading, coordinating code and so forth. The ideal is to be able to say "hey everybody, we're going to push this button tonight, be sure your work is saved into this system that will refresh everything."
Of course, I'm used to doing this with exp/imp because of various app and dba requirements (like, I really don't want to use the same schema name between dev and prod) and the scripts have been refined over time, but there isn't any reason you couldn't have a general post-clone procedure. Describe it in terms that developers see as beneficial to them. -
How to export table data with coloring of cell according to value.
Hi all,
I am using jdeveloper 11.1.1.6
i want to export table data with lot of formatting. like with coloring of cell according to value and so many.How to do that?Hi,
like with coloring of cell according to value and so many.How to do that?
Answer is, you can't
Frank -
Help needed in Exporting tables data through SQL query
Hi All,
I need to write a shell script(ksh) to take some of the tables data backup.
The tables list is not static, and those are selecting through dynamic sql
query.
Can any body tell help me how to write the export command to export tables
which are selected dynamically through SQL query.
I tried like this
exp ------ tables = query \" select empno from emp where ename\= \'SSS\' \"
but its throws the following error
EXP-00035: QUERY parameter valid only for table mode exports
Thanks in advance,Hi,
You can dynamically generate parameter file for export utility using shell script. This export parameter file can contain any table list you want every time. Then simply run the command
$ exp parfile=myfile.txt -
Javascript for exporting form-data from spawned pages in csv-table
Hello,
I need your help with a problem concerning acrobat.
I created a form. The user can spawn new pages from a template.
The fields have the format Pn.templatename.fieldname, for example: P0.form.kosten1
The user fills the form, saves the file and sends it to me.
Now I have to get a CSV- or Excel-Table from this Data.
The Export-Function doesn't work, because of the different fieldnames.
Does Javascript work?
Perhaps I can create a 2-dimensional array and then write it to a csv-file??
Has anyone a good Idea?
Thank you for helping.
Many greetings,
ThomasThe only way I've found to do this is to open the form in Acrobat, click Forms, mouse over Manage Form Data, then click Export Data. Your only options are to save as .xml or .xdp. I saved my data as .xml. I was then able to import the .xml file into excel by clicking Data, mousing over xml, clicking Import... and browsing to the Acrobat generated .xml file. I know this is convoluted but it's the only way I've found to get the data into a spreadsheet. Acrobat exports the data as filename_data.xml, i.e. a form named contacts will export it's data as contacts_data.xml. Be aware, I've only tested this on a form that had a table in it and nothing else. If your table is part of a form with other fields in it I have no idea how the other data will look after exporting.
Maybe you are looking for
-
Edit in Adobe Photoshop CC 2014
When in Lightroom 5 and I select "edit in Adobe Photoshop CC 2014" it doesn't create a copy in tif or psd format (or jpg format) like it did in previous versions. A box use to pop up allowing me to set the file type, color space etc then in Lightroo
-
Quiery about 12.0.3 Patchset
Dear all, We had Installed R12 v3 succesfully and and we have applied Support Diagnostic Patches. 6280873 6265820 but I have checked the about oracle application screen shows the 12.0.0 version as application version why? and We have checked in the d
-
When I sign into the support forums. My user id shows up as Andymkrob. I did not set this up and would like to change it. I work for Morgan Keegan and I assume some one in our IT department named Rob set this up. I always use Andy16H. I would re
-
Syncing contacts from ipad to itunes
I would like to sync contacts from ipad to my iphone and itunes
-
Address Book's window moves down 3 pixels every time you start the app.
I want to confirm that this is not an isolated issue and to make a bit more noise because Apple didn't fix this in the 10.5.3 update. The problem is that the Address Book's window moves down 3 pixels from it's previous position every time you start t