query error in unix


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting query error in unix
# 1  
Old 08-01-2012
query error in unix

Hi all ,
am using unix aix and
Am getting the syntax error on 'UNION'..
can anybody tell me the solutions..
Code:
INSERT INTO table1
(
Type
, num_items
, num_letters
, total_value
)
(select
type='1',
num_items,
num_letters=count(*),
total_value=sum(letter_value)
from
table2
where
num_items = 1
group by
num_items)
UNION
( select
type='2',
num_items,
num_letters=count(*),
total_value=sum(letter_value)
from
table2
where
num_items = 2
group by
num_items)
UNION
( select
type='3',
num_items,
num_letters=count(*),
total_value=sum(letter_value)
from
table2
where
num_items = 3
group by
num_items) ;


Last edited by Franklin52; 08-01-2012 at 08:17 AM.. Reason: Please use code tags for data and code samples
# 2  
Old 08-01-2012
You already made a thread for this, which I already tried to answer, too!

Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Running a SQL Query from UNIX

Hi, Could you please help me on this. I have bulk of queries written in text file. I want to use those queries and want to execute from UNIX. I don't want to run this file as a sql file as this file will change every week. I want to run it in my environment as bulk sql statement from text... (1 Reply)
Discussion started by: abhii
1 Replies

2. UNIX for Dummies Questions & Answers

UNIX Query About wc -l output

I was performing the wc -l operation in one data file the result is less when i was giving -nu on the view of the file. while giving wc -l the count is 5023 after setting line numbers in view of file is giving 5024. Can anyone help on this.... (5 Replies)
Discussion started by: abhii
5 Replies

3. UNIX for Dummies Questions & Answers

Forming a query in unix level

Hi, I will execute a query in sqlplus and redirect to a file. The file will contains the date value such as 2011-04-12 02:00:00. i want to make the content of the file such as, select * from table where col1>to_date('2011-04-12 02:00:00','yyyy-mm-dd HH24:MI:SS'). Apar from the bold... (1 Reply)
Discussion started by: pandeesh
1 Replies

4. Shell Programming and Scripting

issue with the query output in unix

I am running a query with contains blank spaces in between in the output. But when I open and read the file in UNIX i am not able to cursor the balnk spaces instead it is moving like tabs. Please help suppose my query - Select ' '||text from tab1; the cursor should move to 1st and... (1 Reply)
Discussion started by: sbmk_design
1 Replies

5. Shell Programming and Scripting

Unix script to run a query

Hi , I need help in creating the shell script for querying using a loop. I haev written the code as follows . But i am getting an error : Line doesn't required '(' . i have chagned but am getting again #!/bin/ksh ##checking the Command Line Parameter if test $1 = "" then ... (3 Replies)
Discussion started by: ramji_leo
3 Replies

6. UNIX for Dummies Questions & Answers

Query in unix

hi .. i m in gr8 confusion for eg two number of files 1 & 2 1 contains following a b c 2 gives a b d e on executing following command diff 1 2 | grep ">" | sed 's/>//g' >output.dat in output.dat i get following data d e (3 Replies)
Discussion started by: Dana Evans
3 Replies

7. Shell Programming and Scripting

General UNIX Query

Hi all, I am having putty in my system.But I dont have access to any UNIX Servers.Is there any default or common UNIX Server so that anyone can access and be familiar with UNIX and Shell scripting. I want to work and practice in UNIX..Thats why I am asking this question. Kindly give me... (2 Replies)
Discussion started by: dave_nithis
2 Replies

8. UNIX for Dummies Questions & Answers

Query in Unix

hello folks i was executing few shell scripts using another login id , those were working fine ,these shell scripts basically call oracle stored procs now when i copied those shell scripts files to another user location n logged into that user's unix id , it is showing errors ...:( the oracle... (3 Replies)
Discussion started by: Dana Evans
3 Replies

9. Shell Programming and Scripting

sql query variable not exactly unix

I know htis isnt exactly unix.... but hopefully someone can help me or direct me someplace to get help. I can run sql queries in scripts against my informix db using: dbaccess mydb myquery.sql >> sql.output I need to write my script to select based on todays date. Its very... (5 Replies)
Discussion started by: MizzGail
5 Replies

10. UNIX for Advanced & Expert Users

Unix Date query

Hi there, I am trying to do the following in Unix (Solaris 2.7): 1...Find the actual date 7 days ago in format (dd-mmm-yyyy) and with the weekday prefably, 2...Find the date 5 days after the above in the same format. How can I do this in Unix instead of accessing our Oracle database and... (5 Replies)
Discussion started by: csong2
5 Replies
Login or Register to Ask a Question