Two rows from a record commig in single row
Dear All,
This is the query
SELECT ROWNUM,TYP,REF_ID , CODE,FRM_DT , FRM_NOTE
from TABLEA
where TYP='IQ'
AND REF_ID ='IQ1107273'
and (FRM_NOTE LIKE '%AP%' OR FRM_NOTE LIKE '%CL%')
ORDER BY FRM_DT
ROWNUM TYP REF_ID CODE FR_DT FR_NOTE
1 IQ IQ01 IR2460 24/07/2011 AP
2 IQ IQ01 IR2460 25/07/2011 CL
3 IQ IQ02 IR2461 23/07/2011 AP
4 IQ IQ02 IR2461 25/07/2011 CL
could i get this one single row
ROWNUM TYP REF_ID CODE FR_DT FR_NOTE ROWNUM TYP REF_ID CODE FR_DT FR_NOTE
1 IQ IQ01 IR2460 24/07/2011 AP 2 IQ IQ01 IR2460 25/07/2011 CL
3 IQ IQ02 IR2461 23/07/2011 AP 4 IQ IQ02 IR2461 25/07/2011 CL
-----------------------------------------------------------------------------------------------------------------------------------------------------------
SQL>WITH t1 AS (SELECT 't1c1_' || ROWNUM AS c1, 't1c2_' || ROWNUM AS c2, ROWNUM AS c3
2 FROM DUAL
3 CONNECT BY LEVEL <= 3),
4 t2 AS (SELECT 't2c1_' || ROWNUM AS c1, 't2c2_' || ROWNUM AS c2, ROWNUM AS c3
5 FROM DUAL
6 CONNECT BY LEVEL <= 3),
7 t3 AS (SELECT t1.c1 AS c11, t1.c2 AS c12, t2.c1 AS c21, t2.c2 AS c22, ROWNUM AS r
8 FROM t1, t2
9 WHERE t1.c3 = t2.c3)
10 SELECT a, b
11 FROM (SELECT c11 AS a, c21 AS b, r, 1 AS s
12 FROM t3
13 UNION ALL
14 SELECT c12, c22, r, 2 AS s
15 FROM t3)
16 ORDER BY r, s;
A B
t1c1_1 t2c1_1
t1c2_1 t2c2_1
t1c1_2 t2c1_2
t1c2_2 t2c2_2
t1c1_3 t2c1_3
t1c2_3 t2c2_3Urs
Similar Messages
-
Concatenate strings from a column into a single row
I am trying to string values from a column into a single row. I need a list of students (one row per student) with their phone number and they could have more than one number. I found a function that should do what I need but the syntax is for SQL Server, not SQL*Plus. I've tried several variations but can not come up with the correct syntax.
This is the SQL Server version:
CREATE FUNCTION dbo.GetPhoneList(@StudentID int)
RETURNS varchar(500) AS
BEGIN
DECLARE @StringList varchar(500)
SELECT @StringList = COALESCE(@StringList + ‘, ‘, ”) + Telephone.PhoneNumber
FROM Telephone t
WHERE t.StudentID = @StudentID
IF @StringList IS NULL
SET @StringList = ‘No Phone’
RETURN @StringList
END
SQL*Plus does not like the @ symbol, so I tried taking that out. I've put semi-colons where I think they should be, but I still get various error messages. Any suggestions?
Thanks.Hi,
What you want to do is called "String Aggregation"
You could write a PL/SQL funcrtion to do that for a specific column in a specific table, but [this page|http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2196162600402] has a couple of different generic solutions that will work on any tables and columns.
I recommend the first soluton, the user-defined function STRAGG, which you can copy from that page.
Once you have STRAGG installed, your query can be something like:
SELECT s.student_id
, NVL ( STRAGG (t.phone_number)
, 'No phone'
) AS phone_nums
FROM student s
LEFT OUTER JOIN telephone t ON s.student_id = t.student_id
GROUP BY s.student_id;On Oracle 10 (and up) you may have a similar function, WM_CONCAT (owned by WMSYS), already installed.
WM_CONCAT is not documented, so you may not want to use it in your Production applications.
It lokks like
Edited by: Frank Kulash on Feb 10, 2009 6:31 PM -
I need help figuring out how to take data from internet pages and enter it into one single row in an excel, or numbers if that is the easier way to go. I was also told access might be good to use. Basically I am going to chamber of commerce page and wanting to extract the member listing and enter in a database in a single line. The data is in different numbers of lines as you will see below (info edited to take out personal info). So I want to take the name of business, business owner, address, city, state, zip, and phone and put it into one line on a spreadsheet. I want to do this many times over. I think there is a way to do it through apple script and automator, but I have not been successful after 2 weeks of trying and searching. I have over 800 listings and I surely don't want to go through and do them one at a time. Any suggestions?
Data from website:
Westrock Coffee
Mr.
Collins Industrial Place
North Little Rock, AR 72113
Phone:
Send Email
Member Since: 2011
Sweet Creations by DJ
Ms. J
allace Bridge Road
Perryville, AR 72126
Phone:
Fax:
Send Email
Member Since: 2013
See Also Woman Owned and/or CEO
Premium Refreshment Service
Mr. E
est Bethany Road
North , AR 72117
I want it to look like this
Company name, owner name, address, city, state, zip, phone
How can I get the extra data out of the way and remove the format so that it will go into excel? Thanks for any help you can provide. I am not to savvy with code, but I got a friend who is an IT guy that can help. Thanks againSo, basically, create 800 individual entries, each one containing everything from business name through the phone (not fax) number, add some commas and spaces to entries, and then put each entry on a separate line?
1. Go to website page such as this one-- http://www.littlerockchamber.com/CWT/External/WCPages/WCDirectory/Directory.aspx ?ACTION=newmembers --which seems formatwise very close to what you're trying to scrape.
2. Cmd-A to select all. Cmd-C to copy it to clipboard.
3. Open freeware TextWrangler. Cmd-V to paste info from clipboard into a blank TW document.
4. Remove lines from top and bottom so that only membership list remains.
5. Process lines to remove everything from "Fax" line through "See Also" line. Only business name through phone number will remain in the file.
--A. TW > Text > Process Lines containing . . .
-----(check "Delete matched lines"; uncheck all others)
-----Enter "Send Email" in the search box.
-----Click Process.
--B. Repeat 5A for other lines to be removed
------Member Since
------See Also
------Fax
6. Insert markers to separate entries:
TW: Search > Find . . .
------(check "Wrap around" and "Grep")
------in Find box: \r\r\r\r
------in replace box: \r***
------Click Replace All
7. Remove remaining blank lines:
TW: Search > Find . . .
------(check "Wrap around" and "Grep")
------in Find box: \r\r
------in replace box: \r
------Click Replace All
8. Add comma and space at end of each line:
TW: Search > Find . . .
------(check "Wrap around" and "Grep")
------in Find box: $
------in replace box: , (comma space)
------Click Replace All
9. Remove all returns:
TW: Search > Find . . .
------(check "Wrap around" and "Grep")
------in Find box: \r
------in replace box: (leave blank)
------Click Replace All
10. Insert returns in place of markers:
TW: Search > Find . . .
------(check "Wrap around" and "Grep")
------in Find box: \*\*\*, (backslash asterisk backslash asterisk backslash asterisk comma space)
------in replace box: \r
------Click Replace All
11. Remove trailing comma and blank on each line:
TW: Search > Find . . .
------(check "Wrap around" and "Grep")
------in Find box: , $ (comma space dollar sign)
------in replace box: (leave blank)
------Click Replace All
Import this text file into Excel or Numbers. -
Put 2 relevant records in a single row
<p>Hello everybody,</p><p>I have a Attendance table, which has columns WorkDate. Schedule_IN_Time, Schedule_OUT_Time, Login_IN_Time, Login_IN_Time, Login_Type.</p><p>Now for every Login_Type = "I" or "O" there are two records. That means for a day say 07/10/2006 as Workdate there are two records like,</p><p>EmpID WorkDate Schedule_IN_Time Schedule_OUT_Time Login_IN_Time Login_OUT_Time Login_Type</p><p>1 07/10/2006 09:00 17:00 9:00 I</p><p>1 07/10/2006 09:00 17:00 17:15 O</p><p>NOW.. I want a report in Crystal report which will have a single record for a single Workdate..as folllows</p><p>EmpID WorkDate Schedule_IN_Time Schedule_OUT_Time Login_IN_Time Login_OUT_Time</p><p>1 07/10/2006 09:00 17:00 9:00 17:15 </p><p>Can you please help me out..I'm usng CrystalReport XI.</p><p>Thanks in advance.</p><p>sauren </p>
Once you group on these put summaries for Max on each of the values you want to display as one line.  Put them in the footer and suppress the details. That should give the desired results.
    - Kathryn Webster (Report Design Consultant)
          Kat's News: http://diamond.businessobjects.com/blog/279 -
How 2 read two files from 2 diff. directories, using single adapter
How 2 read two files from 2 diff. directories in same system, using single file adapter.
you can use advanced selection for source file
see
http://help.sap.com/saphelp_nw04/helpdata/en/e3/94007075cae04f930cc4c034e411e1/frameset.htm -
How to display the vertical coloumns(records) in a single row?
Hi all,
I need a requirement in SAP where in the internal table records are in vertical placement as follows:
1 2 3 4 5 | a1 b1 c1 d1 e1
1 2 3 4 5 | a2 b2 c2 d2 e2
1 2 3 4 5 | a3 b3 c3 d3 e3
and so on..........
now as per the requirement I need all the records to be displayed in a single row in the output as follows:
1 2 3 4 5 | a1 b1 c1 d1 e1 | a2 b2 c2 d2 e2 | a3 b3 c3 d3 e3 |.....so on
Any pointers on this would be of great help.
thanks in advance,
Vamsee.Loop at itab.
at new f1.
write : itab-f1. <--- here don't give '/' .. which will write in new line ...
endif.
write : itab-f2, <--- here don't give '/' .. which will write in new line ...
itab-f3,
itab-f4,
itab-f5,
itab-f6.
at end of f1.
write :/ ''.
endat.
endloop. -
Adding Two Addresses From One Record in an Address Book Group
I have a Group in Address Book to which I send a weekly newsletter. People here in the community were kind enough to tell me how to edit the group and choose which email -- some want their "home" email, others prefer I use "work" -- from individual records I use.
Now ...
One of the recipients would like me to send to both his home and his work email.
When I right click on the group and go into "Edit Distribution List ..." I see the record and the various emails for each person with the bold email address being the one Mail picks up. But it seems I can only choose one email per record.
Any ideas how to get my Group to house (and let me email to) both the work and the home emails for the same person?
I'm using Address Book 5.0.3 (883) and Mail 4.5 (1084) with OS X 10.6.8
ThanksRather than dragging the card in from the Address Book, start typing the person's name. Mail will give you a pop-up menu on choices. Pick one. Then repeat and pick the other. This is less convenient if you want to put someone in a group and send to both addresses in the group... in that case, V.K.'s solution is the best you'll do.
-
How to populate rows from another table in new blank rows of other table
I have to convert an oracle form 6i to Jdeveloper application. In forms 6i we use create a cursor for other table and then populate the current table data block row using create record and assigning its values from cursor and then issuing next record until all cursor records are written in data block. After some manual editing we save the whole form and then all block records are saved as new rows in table.
Now how to create this functionality in jdeveloper application.
Kindly help.two steps-
1. get row from first VO.iterate them - like below -
DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding dcIteratorBindings = bindings.findIteratorBinding("ViewObj1Iterator");
HSSFRow excelrow = null;
// Get all the rows of a iterator
oracle.jbo.Row[] rows = dcIteratorBindings.getAllRowsInRange();
int i = 0;
for (oracle.jbo.Row row : rows) {
row.getAttribute(colName).toString()); // by this you can get row attribute value..
2. inside iteration create row for VO 2 for example-
ViewObject employee= findViewObject("EmployeeVO");
// Create a row and fill in the columns.
Row row = employee.createRow();
row.setAttribute("Name", "Vinay");
row.setAttribute("EmpId", 1);
//Insert row in to the default row set
employee.insertRow(row);
Read more: http://www.techartifact.com/blogs/2012/12/creating-new-row-of-view-object-in-adf-techartifact.html#ixzz2iL978UOD
http://www.techartifact.com/blogs/2012/12/creating-new-row-of-view-object-in-adf-techartifact.html -
How to display mutliple rows of database data in a single row
We are using XML Publisher 5.6.2. We have a requirement, where we need to display a multiple database rows for a single column in a single row.
Basically say a database column has 5 rows
A1
A2
A3
A4
A5
We want to display in the output in a single cell as
A1 A2 A3 A4 A5
Thanks,
- Vasu -Look at this blog,
http://blogs.oracle.com/xmlpublisher/2007/05/24#a325 -
Concatinating a field from several records into a single string
Using Crystal Reports 11
I have a table of EMS/Fire runs, with a related table of fire trucks that respond on each run. My report is grouped by EMS/Fire run, and then the details section shows each truck, something like this....
Run #1 | 123 E Main St | Structure Fire
E123
E124
E125
L123
L342
R153
Run #2 | 455 S High St | Fire Alarm
E322
E233
L122
What I would like to do is hide the details section, and instead in the footer section of each group, have a "text field" that combines all of the trucks into 1 line, something like this...
Run #1 | 123... | Stru... | E123, E124, E125, L123...
Run #2 | 455... | Fir... | E322, E233, L122
Basically the logic would be:
For Each RecordInThisGroup
If Maximum(TruckNumberField) = TruckNumber Field Then
TruckNumberField
Else
TruckNumberField & ", "
Next RecordInThisGroup
Is there a way to loop through all the records in the group?
Thanks for any insight!
JasonHi Jason,
This can't be done in the Detail section but we can do it in the Group Footer. Seeing as you already are grouping on the EMS/Filre run this is good. We can use a running total to do this.
1) Create a formula and drop it into the Group Header. This will reinitialize the running total for each group:
WhilePrintingRecords;
StringVar Run := "";
You can suppress this formula so you don't see it when you run the report
2) Now create another formula that will go into the Detail section. This is the formula that will build the string:
WhilePrintingRecords;
StringVar Run;
Run := Run & & ", " & {table.TRUCK};
You can hide the detail section or format this formula to be suppressed so you don't see it.
3) The last formula goes into the GroupFooter section and will display the string:
WhilePrintingRecords;
StringVar Run;
Good luck,
Brian -
Trying to convert multiple rows into multipe columns within a single row
I am trying to convert data from multiple rows into multiple columns. Let me see if I can paint the picture for you.
Here is a sample of the table i am trying to read from:
Company Name Account
1 Sam 123
1 Sam 234
1 Joe 345
1 Sue 789
1 Sue 987
1 Sue 573
I am trying to put this into a View that would have the data represented as such:
Company Name Acct1 Acct2 Acct3 Acct4
1 Sam 123 234 <null> <null>
1 Joe 345 <null> <null> <null>
1 Sue 789 987 573 <null>
Many thanks in advance for your help!test@XE> --
test@XE> with t as (
2 select 1 as company, 'Sam' as name, 123 as account from dual union all
3 select 1, 'Sam', 234 from dual union all
4 select 1, 'Joe', 345 from dual union all
5 select 1, 'Sue', 789 from dual union all
6 select 1, 'Sue', 987 from dual union all
7 select 1, 'Sue', 573 from dual)
8 --
9 select company,
10 name,
11 max(case when rn = 1 then account else null end) as acct1,
12 max(case when rn = 2 then account else null end) as acct2,
13 max(case when rn = 3 then account else null end) as acct3,
14 max(case when rn = 4 then account else null end) as acct4
15 from (select company,
16 name,
17 account,
18 row_number() over (partition by company, name order by 1) as rn
19 from t)
20 group by company, name;
COMPANY NAM ACCT1 ACCT2 ACCT3 ACCT4
1 Joe 345
1 Sam 234 123
1 Sue 573 789 987
3 rows selected.
test@XE>
test@XE>isotope -
Hi,
I have three records in table can I put three records in a single row in alv report,
Please suggest,
rewarded highly
thanks in advance
cheersHi Ray
Why don't you create an internal table with fields of the tables (lfa1, lfb1 and lfm1) you need to read and display?
A vendor has to have the company data if he used by accounting, if he has only org data, It should mean that vendor is used only as partner.
Anyway every org can belong to only one company code and every vendor can belong to several companies (I don't know your organization) so the output table should be:
DATA: BEGIN OF T_OUTPUT OCCURS 0,
<LFA1 FIELDS> LIKE LFA1-.....
<LFB1 FIELDS> LIKE LFB1-.....
<LFM1 FIELDS> LIKE LFM1-.....
END OF T_OUTPUT.
LOOP AT T_LFA1.
MOVE-CORRESPONDING T_LFA1 TO T_OUTPUT.
You should append one record for every org
LOOP AT T_LFM1 WHERE LIFNR = T_LFB1-LIFNR.
Check if this org. belong to company vendor
READ TABLE T_T024E WITH KEY EKORG = T_LFM1-EKORG.
IF NOT T_T024E-BUKRS IS INITIAL.
LOOP AT T_LFB1 WHERE LIFR = LFA1-LIFNR.
AND BUKRS = T_T024E-BUKRS.
You should append one record for every company
MOVE-CORRESPONDING T_LFB1 TO T_OUTPUT,
T_LFM1 TO T_OUTPUT.
APPEND T_OUTPUT.
DELETE: T_LFB1, T_LFM1.
ENDLOP.
ENDIF.
ENDLOOP.
Now you elaborate the org without company:
LOOP AT T_LFM1 WHERE LIFNR = LFA1-LIFNR.
and here you can elaborate the company with out org:
LOOP AT T_LFB1 WHERE LIFNR = LFA1-LIFNR.
MOVE-CORRESPONDING T_LFB1 TO T_OUTPUT,
T_LFM1 TO T_OUTPUT.
APPEND T_OUTPUT.
DELETE: T_LFB1, T_LFM1.
ENDLOOP.
and at the end you can elaborate the last vendor
companies:
LOOP AT T_LFB1 WHERE LIFNR.
MOVE-CORRESPONDING T_LFB1 TO T_OUTPUT.
ENDLOOP.
ENDLOOP.
Max
Check if org. belong to company
IF SY-SUBRC = 0.
MOVE-CORRESPONDING T_LFM1 TO T_OUTPUT.
APPEND T_LFM1.
DELETE T_LFM1
ENDIF.
If vendor haven't company data
ENDLOOP.
ENDLOOP.
Max -
Merge two rows & show in a single row in table results
Hi, I need to merge 2 rows having 3 columns in a single row in table view
The cols are currently shown as :
Project NO-------(Current_Month) Revenue----------(Prior_Month) Revenue
123123 10000
20000
Revenue is a single column with revenue for diffreent Period.
10000 is for May
20000 is for April
Project NO for both are same, just the periods are different. if I am not displaying Period i need to merge the 2 rows & show as
Project NO-------(Current_Month) Revenue----------(Prior_Month) Revenue
123123 10000 20000
Please let me know how we can acheive this??
thanx
Pankaj123123 is the project number..
the above is not getting displayed properly....as the blank spaces are removed...
Please consider this -
Joining query with single row result
dear all,
i have two tables
create table item(item_id number primary key,
item_desc varchar2(200));
create table item_properties(item_id number references item(item_id),
property_name varchar2(20),
property_value varchar2(100));i insert the following records
insert into items values(1,'CPU');
insert into item_properties values(1,'RAM','2gb');
insert into item_properties values(1,'PROCESSOR','2ghz');
insert into item_properties values(1,'HARDDISK','2ghz');
commit;now i want a query which produce the following results
item_id RAM PROCESSOR HARDDISK
1 2gb 2ghz 2TBHow to generate this result?
i have create a query but it generate multiple rows, instead i need in a single row like above.
select i.item_id,p.property_value from items i , item_properties p
where i.item_id=p.item_id and i.item_id=1;Kind thanks.
Edited by: Maahjoor on May 7, 2013 12:22 AMselect i.item_id,
max(decode(p.property_name,'RAM',p.property_value)) ram,
max(decode(p.property_name,'PROCESSOR',p.property_value)) processor,
max(decode(p.property_name,'HARDDISK',p.property_value)) hd
from items i , item_properties p
where i.item_id=p.item_id
and i.item_id=1
group by i.item_id;Or pivot in 11g
with details as
select i.item_id,p.property_name,p.property_value
from item i , item_properties p
where i.item_id=p.item_id
and i.item_id=1
select *
from details
pivot
max(property_value) for property_name in ('RAM','PROCESSOR','HARDISK')
);Edited by: jeneesh on May 7, 2013 1:04 PM -
Updating, Adding, or Deleting rows from a query
So, I've got this page that originally was made of four
different forms. It worked great. But, then the client asked that I
"idiot proof" the page.
Originally, I had a form that enclosed a one-line table (with
Add & Clear buttons on the end) that took seven fields and
"added" a new record to the "tbljob" table.
That was followed with another form that created a table from
the results of a cfquery and listed all the rows from tbljob (with
Update/Delete buttons on the end of each row).
This worked fine when it was two separate forms. Now, I'm
trying to use only one "form" while displaying the two tables. The
buttons are now done with Javascript (so there are dialog boxes).
The problem is that I am getting a CF error message because the
insert, update, and delete commands are trying to pass the contents
of the fields as comma-delimited lists rather than the single data
item that is actually in each field. I am passing a hidden field
with each row that contains the "job_id".
I know the problem is that I'm not identifying each row as
being unique. I guess it's like I'm passing an "array" of data
rather than just a "row".
Basically, I just want to be able to display a blank row for
adding records followed by multiple rows from a query. The blank
row needs to have "Add" and "Cancel" buttons at the end and the
multi-row part has to have "Update" and "Delete" buttons on the end
of each row and manage the appropriate records.
It's got me stumped. TIA.What you can do is try using <cfloop> to insert, update
and delete your information.
For instance deleting the information try this.
<!---- Delete Jobs---->
<cfloop index="JobIDs" list="#Job_ID#" delimiters=",">
<cfquery name="delteall" datasource="dbsource">
DELETE
FROM table
Where job_Id = #JobIDs#
</cfquery>
</cfloop>
Do the same for your inserting and updating.
Because what CF see is job_id = 1,2,3,4,5,6,7,8,9
SO you are looping over a list = #job_id# and delimiter is "
, " and we are calling the index JobIDs. JobIDs are the values - 1
2 3 4 5 6 ....
I hope this helps. As for the displaying of the images, use
if then statements:
<cfif isdefined("edittable") and edittable eq '"y">
Then display the query and outputs for the editing options
<cfelseif isdefined("deletetable") and addtable eq "y">
The dispaly the query and outputs for adding options
<cfelse>
Then display the query for outputing the delete options
</cfif>
So your link will have soemthing of this sort <a
href="samepage.cfm?deletetable=y">Add Table</a>
Hope this helps,
Sevor Klu
Maybe you are looking for
-
TDS line items are not getting reflected in J1INCHLN
Hi Experts, While generating TDS challan we are not getting advance line items in J1INCHLN screen We made one advance payment which included 2 payment line items and two different tax codes, while generating TDS challan its is showing only one TDS li
-
XI file sender: filename validation to stop processing a file twice
Hello folks, I have a file sender adapter for a text file with name convention that includes a date - e.g. orders_YYYYMMDD.txt. We have a business requirement to ensure that we don't post the same file more than once. The file can be huge, so it's no
-
Hi, I need to check whether the incoming file is already processed or not. The files are been placed on XI server. If the file with same file name comes then i dont want to process it. I am polling for files on xi server using file adapter. r
-
Can anyone explain this error and how to solve it?
When I create a text table and activate it at last, the system gives me a warning as this: Exactly one field LANGUAGE of LANG type: Select as text language Message no. DT199 I don't know what it means. Can anybody explain it? Thank you very much
-
I can't load my photos from my iphone to my Macbook, please help!
I connected my iphone threw itunes and tried to download my photos to iphoto by selecting 'Import to Library-' in the Menu Bar under File. I got these directions form the "iphone User's Guide" that a family member found for me off the Internet. I am