I need to print one query result as a single row
Hi,
I need to print one query result as a single row ,which gives more than one value (of subinventories)and also i would like to print the quantity of that particular subinventory at particular place.Please suggest how can i do this in the report builder?
Actually I need to print inventory report with subinventory break up.For that all subinventories of category code AB are taken as single row.Based on that subinventory value Quantity must be printed at that particular place.
For ex
Quantity
Item no Description Subinventory Code AB_Abc AB_Def AB_ghi
1 ***** 12 9
2 ****** 8 5
like that.I am waiting for the reply.Plz its some how urgent.
Thank you,
Similar Messages
-
How to display a 1 to many query result in a single row?
Hi,
I want to display a 1 to many relationship in a query in just one row. The current result is that I get more than 1 rows. How can I display it in one column with the additional attribute in a column, without repeating? Thank you.
Select s.student, t.teacher from student_table s, teacher_table t where s.id = t.student_id
Result
Student Teacher
John Doe Larry Woe
John Doe Mary Moe
I would rather get a result like this:
Result
Student Teacher 1 Teacher 2
John Doe Larry Woe Mary Woe
Edited by: Samantha on May 18, 2011 2:48 PMHi,
Will all Students have exactly two Teachers?
If not picture your sample with two more Students.
One having 1 Teacher
One having N Teachers
Think about N, what will it be? - How would you create a table with N columns?
If you can't easily answer above, re-consider what you are trying.
That said, it could still be done - even if all Students do not have exactly two Teachers - and is called Pivot a dynamic number of columns.
Examples are in FAQ
SQL and PL/SQL FAQ
Still a bad idea, with or without known number of teachers
Regards
Peter -
Function to concatenate all query results in a single row comma separeted
Hi All,
my version is Oracle 10.2.0.4.0
this is my query:
select distinct
table1.id
from table1,
table2,
table3
where table1.id = table2.id
and table2.id = table3.id
and table3.id = '761'
and result is:
61
18
68B
S05
S18
68
could someone provide me a function (or something else) in order to have a result like this:
61,18,68B,S05,S18,68
and call it from another query?
I appreciate your help.
Many thanks.
Alessandrouser12889282 wrote:
could someone provide me a function (or something else) in order to have a result like this:
61,18,68B,S05,S18,68
and call it from another query?But this is the wrong way to do it. Better use the original query as a subquery for your second query.
let me demonstrate it
select *
from someotherTable x
where x.FK_ID IN (select t1.id
from table1 t1
table2 t2,
table3 t3
where t1.id = t2.id
and t2.id = t3.id
and t3.id = 761 /* use numbers not strings for IDs! */
;Edited by: Sven W. on Jul 30, 2010 10:17 AM -
How to use one query results in another query
hi,
in help.sap I have founded that using variable type replacement path I can use one query results in another query. It is wrote there that I have to choose query name results I want to get in variable definition but I do not know where.
How I can do this?
Result I want to get is:
In one query I have material prices in another material quantities. I want to calculate inventory value (price * quantity). Moreover prices are on plant level, quantities on storage type level. Plant is atribute of storage type.
Can I do this?
Regards,
AndrzejHi Andrzej,
please check out this thread: Set parameters values depending on other parameters
I had a discussion about query results as input for another query in there.
For creating a workbook, just click on the save button after you ran your query in the bex.
Siggi
Message was edited by: Siegfried Szameitat -
Is there a way to combine their query results into a single function
say I have a bunch of functions that return a query:
<cffunction name="getDeals" access="remote"
returntype="query">
<cffunction name="getDeals2" access="remote"
returntype="query">
is there a way to combine their query results into a single
function that returns a struct of the various results?Umm, it's probably more suited to an array - effectively
making it into a list of queries. You'd then loop the array and
output each.
I use a similar approach when creating system messages to the
user. Most of my functions that are called do their bit, then at
the end call another function I call "messages". This function
grabs whatever my function sends and appends it to a messages
array.
This way enables me to output a long list of messages -
because I could be calling several functions at the same time. If I
just output a message from each function, each one would overwrite
the other. So I'd get one message at a time.
Immediately after it's output, I then destroy the message
array so that old messages aren't kept inside of it.
Mikey. -
Query results:every other record/row grey and white
Hello guys,
query results:every other record/row grey and white
how would you make every other record/rows a different color
just like the forums color. Lightest grey and white?
<cfquery name="Myqueryname"
datasource="#Request.MainDSN#">
SELECT
CompanyID,
CompanyName,
Address,
City,
State,
ZipCode,
Comments
FROM
Company
ORDER BY
CompanyName ASC
</cfquery>
<html>
<head>
<title>CF TUTORIALS</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>All CO Listings</h1>
<table>
<tr>
<td><b>ID</b></td>
<td><b>Name</b></td>
<td><b>Address</b></td>
<td><b>City</b></td>
<td><b>State</b></td>
<td><b>ZIP Code</b></td>
<td> </td>
</tr>
<cfoutput query="Myqueryname">
<tr>
<td>#CompanyID#</td>
<td>#CompanyName#</td>
<td>#Address#</td>
<td>#City#</td>
<td>#State#</td>
<td>#ZipCode#</td>
<td>
<a href=" ALL Emps.cfm?CompanyID=#CompanyID#">ALL
Emps</a>
<a href=" AddCO Form.cfm">AddCO</a>
<a href="
Editco.cfm?CompanyID=#CompanyID#">Editco</a>
<a
href="CoDeleteForm.cfm?CompanyID=#CompanyID#">Delete</a>
</td>
</tr>
</cfoutput>
</table>
</body>
</html>There is a cool tool in Coldfusion called MOD
This basically calculates the remainder of the row number
when divided.
I interpreted its use to something like this, which has
worked for me.
<cfoutput query="qry_requestedlist" maxrows="30"
startrow="1">
<cfset EvenRow=#CurrentRow# +1>
<cfif CurrentRow Mod 2 IS 1>
<tr>
<th class="grey" CurrentRow#</th>
<cfelse>
<th class="white">#CurrentRow#</th>
<tr>
</cfif>
</cfoutput>
I doubt this is precisely what you want but this is the sort
of thing. -
Need blnak line in query result
In sqlplus query result, i need a blank line between each row. how can I get it? solution please.
There are various ways...
If you actually want generated blank rows...
SQL> ed
Wrote file afiedt.buf
1 select decode(rn, 1, empno) as empno
2 ,decode(rn, 1, ename) as ename
3 ,decode(rn, 1, job) as job
4 ,decode(rn, 1, mgr) as mgr
5 ,decode(rn, 1, hiredate) as hiredate
6 ,decode(rn, 1, sal) as sal
7 ,decode(rn, 1, comm) as comm
8 ,decode(rn, 1, deptno) as deptno
9 from emp, (select rownum as rn from dual connect by rownum <= 2) r
10* order by emp.empno, r.rn
SQL> /
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
1111 WILLIS CLERK 7902 18-JAN-08 900 20
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10
30 rows selected.
SQL> -
Put one query result in two newspaper style columns per page
I have a query that returns about 1000 rows of data but I only need to see 3 fields so on a page it only takes up a couple inches of space. I want to make the data wrap so it prints down the left side column then continues the list on the right hand side (like a newspaper article flows) I have no idea how to make it look like this:
ROWONE DATE ROWFOUR DATE
ROWTWO DATE ROWFIVE DATE
ROWTHREE DATE ROWSIX DATE
Page 1
ROWSEVEN DATE ROWNINE DATE
ROWEIGHT DATE ROWTEN DATE
Page 2
Any ideas?
Message was edited by:
user463998Well, probably I'm not the best to give advice but it did work for me. I put a frame to fill the whole page, then the repeating frame in which I wanted my data, then added my columns to the repeating frame... edited the properties of the repeating frame to print down/across and it worked (though I had to resize the repeating frame to make it a bit smaller because I guess it has to be able to easily fit two wide before it'll print in the second column.)
-
Need help on retrieving query result - NPE
Hi, I could get results with the native query in my TOAD, but I can't get it working in my session EJB. I tried both native query and EJB ql. The query created fine, as soon as I try to retrieve results, it gets stuck.
My native query looks like this:
Query query = em.createNativeQuery("select sum(o.amount_reimbursed) from t_expenses o where o.employee_id = '999999911' " +
"and o.EXPENSE_ID in (select p.expense_id from T_Per_Diem_Xref p where p.expense_Type_Xref_Id=22 " +
"and p.expense_Id in (select e.expense_Id from T_Expenses e where e.employee_Id='999999911' " +
"and e.expense_date > to_date('01/01/2011', 'mm/dd/yyyy') and e.expense_date < to_date('12/31/2011', 'mm/dd/yyyy')))") ;
My EJB query looks like this:
Query query = em.createQuery("select sum(o.amountReimbursed) from TExpenses o where o.employeeId = ?1 " +
"and o.expenseId in (select p.expenseId from TPerDiemXref p where p.expenseTypeXrefId=?2 " +
"and p.expenseId in (select e.expenseId from TExpenses e where e.employeeId=?1 and e.expenseDate>=?3 and e.expenseDate<=?4))");
query.setParameter(1, employeeId);
query.setParameter(2, expenseType);
query.setParameter(3, fDay, TemporalType.TIMESTAMP);
query.setParameter(4, lDay, TemporalType.TIMESTAMP);
Either one, I get NPE at the line retrieve result.
// sumAmt = (Double)query.getSingleResult();
List list = query.getResultList();
if (list != null) {
long longAmt = (Long)list.get(0);
sumAmt = (Double)list.get(0);
As you can see, I tried to getSingleResult, or getResultList. also tried to convert the result to Double or Long. None worked.
Please help and thank you for your time.
SophiaFrank, thank you for your reply. I have this code in my session Facade EJB, and I get the NPE in my backing bean which calls this method. When I debug the code, it appears what really cuases the problem is in this code on the line I try to assign the query result to my variable 'sumAmt = (Double)query.getSingleResult();'. In the debug, when it reaches this line, it starts to give me all kinds of pop-up windows saying couldn't find this file or that file or packages. If I get a stack trace later, I will post it. Right now I am trying to fix something else.
Thanks, Sophia -
How to print sql query results
how to print sqlplus query results
Hi,
Spool sql.txt
Execute the query
Spool off
And find the sql.txt file in the current directory.
Regards
Jafar -
How to set query result to a single window
I am using SQL Developer 2.1063, and not happy with the default setting of result window. Everytimes when I run a query, the result appear in a new result window. Over a couple of hour I have tense or hundreds of result tabs in the low window. It is not quite fun to remove them one by one.
I am sure it can be set so that all result appear in one result window, as I am used to in the old SQ Developer version. But I failed to find it in Prefernces and in Help.-K- wrote:
This is fixed in the available 2.1.1.
Have fun,
K. K
I've just tested on 2.1.1 and i came to the same conclusion as user10369687
- if you check the box for "Preferences - Database - Worksheet - Automatically Freeze Result Tabs" or click the pin button or run as script (F5) or highlight the sql and run as script (F5) you always get new query result tab.
The option name suggest that if you check the box the same result tab will be used for different queries which is not true, is the oposite way.
If the option name is changed than the confusion will be cleared.
Dani -
Query results more than 200 rows.
Hi all:
I have a problem with a query that results more than 200 rows.
Only show in a table 201 rows and warning about this message: "Query has exceeded 200 rows. Potentially more rows exist, please restrict your query."
Is possible that the query show all results ???
thanks!Its still a warning. You can continue with work but definitely you can increase the value through the profile value. Anything within 500 wouldn't cause much performance issue.
--Shiv -
Query - Purchasing information in single row
Hi Experts,
I have a requirement to create a report which shows products with all POs in a single row. In many cases we will have several open PO at one time for the same product. For example - item SUFF2231-M will have:
PO
Qty
Due Date
42771
200
10/05/2014
42883
250
20/05/2014
43321
150
30/05/2014
43375
100
10/06/2014
43401
100
20/06/2014
We only need to see up to 5 PO for each product. Ideally I need to be read them on a single line like so:
ItemCode
PO1
Qty1
DueDate1
PO2
Qty2
DueDate2
PO3
Qty3
DueDate3
PO4
Qty4
DueDate4
PO5
Qty5
DueDate5
SUFF2231-M
42771
200
10/05/2014
42883
250
20/05/2014
43321
150
30/05/2014
43375
100
10/06/2014
43401
100
20/06/2014
Is this possibe using only SQL query?
Regards
GeoffHi Geoff,
You can use the ROW_NUMBER and CASE Functions to acheive this. Here with , i have give u a small idea with an ex:
Qry :
B.ItemCode,SUM(B.PO1)[PO1],SUM(B.POQty1)[POQty1],SUM(B.PO2)[PO2],SUM(B.POQty2)[POQty2] From
select Itemcode
CASE when Sno=1 Then DocNum End [PO1]
CASE When Sno=1 Then Qty End [POQty1]
CASE when Sno=2 Then DocNum End [PO2]
CASE When Sno=2 Then Qty End [POQty2]
From(
Row_Number() Over (Order By Opor.Docnum) [Sno], Opor.DocNum,POr1.ItemCode,sum(POr1.Quantity)[Qty] from OPOR join Por1 on Opor.DocEntry=por1.DocEntry
ItemCode='20002' group by oPor.DocNum,por1.ItemCode
A where A.Sno<=2)B Group By B.ItemCode
Result :-
ItemCode PO1 POQty1 PO2 POQty2
20002 18 1.000000 19 10.000000
Thanks,
Karthikeyan.P -
Hi Gurus,
I have been using the sq01 query to do complex calculations and have been successful in creating tons of queries. What I am stuck with right now is this situation. I created a query and the result is in multiple rows. Here's what it looks like
Col1 Col2 Col3 Col4 Col5
0014 0.00 12.00 0.00 1.00
0014 20080428 0.00 0.00 0.00
0014 0.00 0.00 5.00 0.00
0014 0.00 0.00 0.00 0.00
Here;s what I want it to look like
Col1 Col2 Col3 Col4 Col5
0014 20080428 12.00 5.00 1.00
Which means i dont want any rows that basically have 0.00 throught and for the key 0014 I want all the data on one single row.
Is there anyway we can do it using sq01.
Any suggestions will be appreciated. Thanks in advance
Kavita
Edited by: Kavita on Feb 18, 2009 7:44 PMHi,
Its not possible to have in single row.
this is same like Education infotype ,all the qualifications will show in different rows.
You wont get it in single row.
Bu try to Check Qucikviewer and join conditions...that might helpful to get it... -
Merging two results into a single row
Hi, Everyone... I think this is a weighted question and I feel like it's a bit difficult to phrase, so if it doesn't make sense - let me know and I'll try to clarify or provide some more concrete examples (if I can) :)
I have a few tables inner joined in my sql query - I'd post the entire query here but it's lengthy and will probably add a bit more confusion so let's start with theorizing - where the results sometimes generate more than one row. If more than one row exists, I'd like to take the lowest number in one field and the highest number in another field, and display them on a single row.
For instance, when I join the PERIOD and SCHEDULE tables, the PERIOD table might provide two rows like the following:
SCHEDULE_ID PERIOD_ID START_TIME END_TIME
123 100 32820 35640
123 101 35940 38760My final result should take the lowest START_TIME and the highest END_TIME, even if they exist is separate rows.
START_TIME END_TIME
32820 38760It doesn't seem easy to me so if someone can make sense of this - you deserve an award. :) If I can provide some more clarification, please let me know. Thanks for any help. Oracle 11g
Edited by: nage62587 on Sep 27, 2012 11:32 AMnage62587 wrote:
Thanks! I'll try that... I have more than these columns in the result and I'm thinking a Group By likely wouldn't work - I will try but in the event it doesn't, does anyone else have any other suggestions?Group by is the correct way to do this. You group several rows of output into one row. Then you decide which values from inside that group you want to see. This is certainly possible. There are more aggregation functions available than you might think, not only min/max, also min/max + KEEP, count(case expression) and so on.
Maybe you are looking for
-
Can't figure out how to finish restoring icloud to my new iphone 5s
Just left Apple store, and they started restoring my icloud. Choice between Later/Finish Restoring. I chose "Later" to get to messages. Now I'm home and can't figure out how to finish restoring. Went to settings, then icloud and could not find anyt
-
Porting a Verizon number from a family plan to a different carrier
Hello everyone, Basically, I have a line with Verizon under a family plan, I am not the owner of that plan, but I am looking to port my number to T-mobile since I don't think that the price-service ratio is not fair for the mediocre service that I ge
-
Does WebCenter Spaces support Internet Explorer 9?
Does WebCenter Spaces support Internet Explorer 9? Will it work in IE9 default view, or is compatibility view required?
-
I have an HP 4500 printer connected to airport extreme with usb. All our portable notebooks print via air but cannot get iPad to be recognized for printing. Do I really have to have one of the other HPs listed?
-
Chnaging user name using command line
We have 2 DB users (db1 and db2). in configuration tab, Services/JDBC/Connection Pools/bvdb on colsole, the user and password is listed. Usually we change DB user from one to other from console. I want to write script for it. I wanted to know the cam