split line based on delimeter SQL


 
Thread Tools Search this Thread
Top Forums Web Development split line based on delimeter SQL
# 1  
Old 09-05-2011
Tools split line based on delimeter SQL

I have a SQL query

Code:
SELECT 
BLAH_ID,
BLAH_CODE,
DATEFORMAT(CALENDAR_DATE, 'MM-DD-YYYY') AS CALENDAR_DATE_STR,
HOURS,
'N',
FROM blah_tmp_tbl order by CALENDAR_DATE_STR,BLAH_ID,BLAH_CODE;
OUTPUT TO 'MyExport.CSV' quote '' FORMAT ASCII;

That gets me the below output;

Code:
111111,104,07-24-2011,3.15,N,
222222,020 140,07-24-2011,10.00,N,

I would like to split the lines with multiple BLAH_CODE entries like this when performing the SQL query

Code:
111111,104,07-24-2011,3.15,N,
222222,020,07-24-2011,10.00,N,
222222,140,07-24-2011,10.00,N,


Last edited by pludi; 09-06-2011 at 06:02 AM..
# 2  
Old 09-05-2011
Code:
awk '
BEGIN { FS = OFS = "," }
$2 ~ / / {
  n = split($2, v, / +/)
  for (i=1; i<=n; i++) {
    $2 = v[i]
    print
  }
  next
} 
1          
' INPUTFILE

# 3  
Old 09-06-2011
Is there a way to do it inside SQL

I know that AWK can modify the data. However, do you know if there is a way to get it from the original SQL query?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Split a line into multiple lines based on delimeters

Hi, I need help to split any lines that contain ; or , input.txtAc020 Not a good chemical process AC030 many has failed, 3 still maintained AC040 Putative; epithelial cells AC050 Predicted binding activity AC060 rodC Putative; upregulated in 48;h biofilm vs planktonic The output... (8 Replies)
Discussion started by: redse171
8 Replies

2. Shell Programming and Scripting

How to split a file based on pattern line number?

Hi i have requirement like below M <form_name> sdasadasdMklkM D ...... D ..... M form_name> sdasadasdMklkM D ...... D ..... D ...... D ..... M form_name> sdasadasdMklkM D ...... M form_name> sdasadasdMklkM i want split file based on line number by finding... (10 Replies)
Discussion started by: bhaskar v
10 Replies

3. Shell Programming and Scripting

Split line of file from delimeter.

I have a below file. INPUT FILE select * from customer MERGE INTO Archive; delete from Employee; using select * from customer; delete from employee; select * from Employee; insert into employee(1,1); OUTPUT FILE select * from customer MERGE INTO Archive delete from Employee using... (5 Replies)
Discussion started by: Mohin Jain
5 Replies

4. Shell Programming and Scripting

Put delimeter in data based on value

Hi Friends, I have a file as below source.txt 12345JackYKing32N 1235 JulyYoig 31N i am using cut command for cutting the fields cut -c 1-5 source.txt 12345 1235 like above i have to use each time to cut all the fieds manually. I have a file(pre.txt) which tells... (3 Replies)
Discussion started by: i150371485
3 Replies

5. Shell Programming and Scripting

Return all characters to the left of the last delimeter of each line

Hello, Working on a ksh script and a little stumped... how can I return all characters to the left of the last delimeter per line in a file, skipping any lines without that delimeter? ie, sample.txt: Once_upon-a-Midnight_dreary_while I pondered, weak_and weary over many a quaint and... (4 Replies)
Discussion started by: MoreCowbell
4 Replies

6. Shell Programming and Scripting

Split a file into multiple files based on line numbers and first column value

Hi All I have one query,say i have a requirement like the below code should be move to diffent files whose maximum lines can be of 10 lines.Say in the below example,it consist of 14 lines. This should be moved logically using the data in the fisrt coloumn to file1 and file 2.The data of first... (2 Replies)
Discussion started by: sarav.shan
2 Replies

7. Shell Programming and Scripting

How to merge 2 files based on delimeter in perl?

Hi, I have 2 files. a.txt & b.txt # a.txt contains the following text. apple grapes # b.txt contains the following text. banana pine My question is. (1 Reply)
Discussion started by: vanitham
1 Replies

8. Shell Programming and Scripting

Need Awk command to get part of string based on delimeter

HI, Need awk command to get date and time alone from Input : "15:29:15 28.08.2010|SCHEDULE: Started program POSG1" Output expected : "15:29:15 28.08.2010" Please help. (9 Replies)
Discussion started by: shanneykar
9 Replies

9. Shell Programming and Scripting

Split a line based on : using sed

Hi, i have a file say file1 having following data /abc/def:ghi/jkl/ some other text Now i want to extract only ghi/jkl/using sed, can some one please help me. Thanks Sarbjit (2 Replies)
Discussion started by: sarbjit
2 Replies

10. Shell Programming and Scripting

Split File Based on Line Number Pattern

Hello all. Sorry, I know this question is similar to many others, but I just can seem to put together exactly what I need. My file is tab delimitted and contains approximately 1 million rows. I would like to send lines 1,4,& 7 to a file. Lines 2, 5, & 8 to a second file. Lines 3, 6, & 9 to... (11 Replies)
Discussion started by: shankster
11 Replies
Login or Register to Ask a Question