The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Openmocha javascript server-side 0.9 iBot UNIX and Linux RSS News 0 03-05-2008 03:50 AM
AWK how to strip from right hand side angelolamberti Shell Programming and Scripting 5 01-17-2008 08:31 AM
Server side scripting paladyn_2002 Shell Programming and Scripting 1 04-20-2004 12:04 PM
Having a Unix system installed side to side with Windows? Pcslider UNIX for Dummies Questions & Answers 14 01-29-2002 06:21 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-07-2007
prasee prasee is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 8
How to print two sql query outputs side by side in excel

Hi,
I have to sql queries like
select sno,sname from temptable;
select deptno,dname from depttable;

In excel i want to specify the column number to which my output should be displayed.
please help me in this...
thanks in advance...
  #2 (permalink)  
Old 09-07-2007
manas_ranjan's Avatar
manas_ranjan manas_ranjan is offline
Registered User
  
 

Join Date: Jul 2007
Location: Amsterdam
Posts: 177
could you please elaborate on the following line

i want to specify the column number to which my output

but as per the subject line , you can write a single query where these 4 columns can be accessed , as follows,

select temp.sno,
temp.sname,
dept.deptno,
dept.dname
from temptable temp ,
depttable dept
;

  #3 (permalink)  
Old 09-07-2007
prasee prasee is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 8
How to print two sql query outputs side by side in excel

Hi Ranjan Thanks for your prompt reply....
i am using following script..to spool my output in to CSV.
I want to print these two queries output side by side.Is it possible??

spool /apps/ssta/dic_feedfiels/PrimarySecondaryHANDSETsales$tdate.CSV

select ' output1' from dual;

select circle_id,distributor_code,count(*) primary_stock
from table1
where item='HS'
and sale_date between TRUNC(TRUNC(TRUNC(SYSDATE,'MONTH'),'MONTH')) and TRUNC(SYSDATE)
group by circle,code;

select null from dual;
select null from dual;
select null from dual;
select null from dual;

select 'output2' from dual;

select circle_id,distributor_code,retailer_name,count(*)
from table2
where sale_date between TRUNC(TRUNC(TRUNC(SYSDATE,'MONTH'),'MONTH')) and TRUNC(SYSDATE)
group by circle,code,name;

spool off
EOF
  #4 (permalink)  
Old 09-07-2007
manas_ranjan's Avatar
manas_ranjan manas_ranjan is offline
Registered User
  
 

Join Date: Jul 2007
Location: Amsterdam
Posts: 177
I am not sure on the below formatted one, but please try this out and let us know,

select A.* ,
B.*
from (select circle_id,distributor_code,count(*) primary_stock
from table1
where item='HS'
and sale_date between TRUNC(TRUNC(TRUNC(SYSDATE,'MONTH'),'MONTH')) and TRUNC(SYSDATE)
group by circle,code) A,
(select circle_id,distributor_code,retailer_name,count(*)
from table2
where sale_date between TRUNC(TRUNC(TRUNC(SYSDATE,'MONTH'),'MONTH')) and TRUNC(SYSDATE)
group by circle,code,name) B ;
  #5 (permalink)  
Old 09-07-2007
prasee prasee is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 8
hi ranjan,
second query output is repeating for every row returned for first query.

instead of printing side by side can we print these two outputs in different sheets in same excel....

please help me out.....
  #6 (permalink)  
Old 09-07-2007
manas_ranjan's Avatar
manas_ranjan manas_ranjan is offline
Registered User
  
 

Join Date: Jul 2007
Location: Amsterdam
Posts: 177
hey prasee,

just let me know what xactly u need ???
i can optimized the query in order to return the o/p(no duplicate), in single excel sheet.

but even i am not sure how you are going to export the 2 different queries o/p to a single excel sheet with different tabs ????

can u let me know, whether table1 and table2 are same????
  #7 (permalink)  
Old 09-08-2007
prasee prasee is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 8
Hi ranjan,
table1 and table2 are different and we can not join those two tables.
I want to put two outputs in same excel but as output1 is very long so i want to print output2 side to it.
is there any other way to print in other sheets of excel.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:59 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0