Query to format result
SQL> select * from a;
T S
TEACHER1 STUDENT1
TEACHER1 STUDENT2
TEACHER1 STUDENT3
TEACHER2 STUDENT1
TEACHER2 STUDENT2
I'm trying to format the result to be
Teacher All Students
TEACHER1 STUDENT1, STUDENT2, STUDENT3
TEACHER2 STUDENT1, STUDENT2
Any help is greatly appreciated.
this might be of help.
SQL> select * from teacher_student;
TEACHER STUDENT
TEACHER1 STUDENT1
TEACHER1 STUDENT2
TEACHER1 STUDENT3
TEACHER2 STUDENT1
TEACHER2 STUDENT2
SQL> select ts.teacher,
2 substr(max(substr(sys_connect_by_path(ts.student,', '),3)),1,60) as student
3 from (select teacher, student,
4 row_number() over (partition by teacher order by teacher, student) rnum
5 from teacher_student) ts
6 start with ts.rnum = 1
7 connect by ts.rnum = prior rnum + 1
8 and prior ts.teacher = ts.teacher
9 group by ts.teacher;
TEACHER STUDENT
TEACHER1 STUDENT1, STUDENT2, STUDENT3
TEACHER2 STUDENT1, STUDENT2
SQL>
Similar Messages
-
Bex Query getting Freezed while formatting results
Hi Friends,
I am running a BEx Query with one year data selection but it's getting freezes while formatting results. But when i deselect the 'Format after refresh' option in the query properties..then query is running fine.
Could you please let me know if there is any reason for this?
Regards,
MaheshHi,
Just generate your query once with program RSR_GEN_DIRECT_ALL_QUERIES.
By selecting your multiprovider .
Thanks,
Ranjan -
How To Make Search Query Showing the Result As List of Buttons.
Can some one give me an idea how to start to make a Search Query showing the results as list of buttons.. i have already have my buttons with names. i just dont know how to make a search query.
this is my on screen keyboard i made..
im making a system that the result were a list of buttons.. showing like this
This was supposed to be the output of the query that i need to do..
Please help me.. i just need a idea or tips how to make this one.Here is code I posted recently for another question
Public Class Form1
Const BUTTON_SIZE As Integer = 20
Const SPACE As Integer = 5
Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
Dim buttons As New List(Of List(Of MyRadioButton))
For row = 1 To 6
Dim newRow As New List(Of MyRadioButton)
buttons.Add(newRow)
For col = 1 To 6
Dim button As New MyRadioButton()
button.row = row
button.col = col
button.Height = BUTTON_SIZE
button.Width = BUTTON_SIZE
button.Left = col * (BUTTON_SIZE + SPACE)
button.Top = row * (BUTTON_SIZE + SPACE)
button.Name = String.Format("radGr1{0}_{1}", row.ToString(), col.ToString())
Me.Controls.Add(button)
newRow.Add(button)
AddHandler button.CheckedChanged, AddressOf Radio_Change
Next col
Next row
End Sub
Private Sub Radio_Change(ByVal sender As Object, ByVal e As System.EventArgs)
Dim button As MyRadioButton = CType(sender, MyRadioButton)
Dim row As Integer = button.row
Dim col As Integer = button.col
End Sub
End Class
Public Class MyRadioButton
Inherits RadioButton
Public row As Integer
Public col As Integer
End Class
jdweng -
CAML Query returning no result
I have this CAML query running fine on my local dev machine, but on live production machine, it returns zero result.
<Where>
<And>
<Geq><FieldRef Name='Created' /><Value Type='DateTime'>[Today-60Day(s)]</Value></Geq>
<And>
<Contains><FieldRef Name='Author' /><Value Type='User'>Phil Smith</Value></Contains>
<And>
<IsNotNull><FieldRef Name='Customer' /></IsNotNull>
<Or>
<IsNotNull><FieldRef Name='_x0031_Quantity' /></IsNotNull>
<Or>
<IsNotNull><FieldRef Name='_x0032_Quantity' /></IsNotNull>
<Or>
<IsNotNull><FieldRef Name='_x0033_Quantity' /></IsNotNull>
<IsNotNull><FieldRef Name='_x0034_Quantity' /></IsNotNull>
</Or>
</Or>
</Or>
</And>
</And>
</And>
</Where>
I even run it in CAML Query builder on Live machine and it does return result, but it's just in code, it's not returning anything. The code is as follow:
spQuery.Query = String.Format("<Where>" +
"<And>" +
"<Geq>" +
"<FieldRef Name='Created' />" +
"<Value Type='DateTime'>[Today-60Day(s)]</Value>" +
"</Geq>" +
"<And>" +
"<Contains>" +
"<FieldRef Name='Author' />" +
"<Value Type='User'>{0}</Value>" +
"</Contains> " +
"<And>" +
"<IsNotNull><FieldRef Name='Customer' /></IsNotNull>" +
"<Or>" +
"<IsNotNull><FieldRef Name='_x0031_Quantity' /></IsNotNull>" +
"<Or>" +
"<IsNotNull><FieldRef Name='_x0032_Quantity' /></IsNotNull>" +
"<Or>" +
"<IsNotNull><FieldRef Name='_x0033_Quantity' /></IsNotNull>" +
"<IsNotNull><FieldRef Name='_x0034_Quantity' /></IsNotNull>" +
"</Or>" +
"</Or>" +
"</Or>" +
"</And>" +
"</And>" +
"</And>" +
"</Where>", myWeb.CurrentUser.Name);
SPListItemCollection result = oPriceList.GetItems(spQuery);
if (result.Count > 0)Instead of "<Value Type='DateTime'>[Today-60Day(s)]</Value>", Could you try with the following:
<Value Type='DateTime'><Today OffsetDays="-60"/></Value>"
Also,
it is better to debug the code and see the value of caml string during runtime (rather than seeing the values in caml buider).
Thanks Arut -
Same query giving different results
Hi
I m surprised to see the behaviour of oracle. I have two different sessions for same scheema on same server. In both sessions same query returns different results. The query involves some calculations like sum and divisions on number field.
I have imported this data from another server using export / import utility available with 9i server. Before export every thing was going fine. Is there some problem with this utility.
I m using Developer 6i as the front end for my client server application. The behaviour of my application is very surprizing as once it shows the correct data and if I close the screen and reopen, it shows wrong data.
I m really stucked with the abnormal behaviour. Please tell me the possiblities and corrective action for these conditions.
Regards
Asad.There is nothing uncommitted in both the sessions. But still different results are returned.
I m sending u the exact query and result returned in both sessions.
Session 1:
SQL> rollback;
Rollback complete.
SQL> SELECT CC.CREDIT_HRS,GP.GRADE_PTS
2 FROM GRADE G, COURSE_CODE CC, GRADE_POLICY GP
3 WHERE G.COURSE_CDE=CC.COURSE_CDE
4 AND G.SELECTION_ID=45 AND G.GRADE_TYP=GP.GRADE_TYP
5 AND G.TERM_PROG_ID=17 AND GP.TERM_ID=14
6 /
CREDIT_HRS GRADE_PTS
3 4
4 3.33
4 3.33
3 4
3 4
3 4
3 4
7 rows selected.
SQL>
SESSION 2:
SQL> rollback;
Rollback complete.
SQL> SELECT CC.CREDIT_HRS,GP.GRADE_PTS
2 FROM GRADE G, COURSE_CODE CC, GRADE_POLICY GP
3 WHERE G.COURSE_CDE=CC.COURSE_CDE
4 AND G.SELECTION_ID=45 AND G.GRADE_TYP=GP.GRADE_TYP
5 AND G.TERM_PROG_ID=17 AND GP.TERM_ID=14
6 /
CREDIT_HRS GRADE_PTS
3 4
4 3.33
3 4
3 4
3 4
3 4
6 rows selected.
SQL>
U can see in session 1, seven rows are returned while in session 2 six rows are returned. I have issued a rollback before query to be sure that data in both sessions is same. -
Passing Parameters to SQL Query and Displaying Result
The user enters a serial number in a text box and then pushes a button to get info about the serial number. I do this with two regions. The first region has the text box and the button. The second region is a Report type region and contains the following SQL:
select case
when "WARRANTYSTATUS"."OUTOFWARRANTYDATE" >= sysdate then
'Serial Number '||"WARRANTYSTATUS"."SERIALNUMBER"||' is in warranty.'
else
'Serial Number '||"WARRANTYSTATUS"."SERIALNUMBER"||' is out of warranty.'
end as "The result is:"
from "WARRANTYSTATUS"
where "WARRANTYSTATUS"."SERIALNUMBER" in (:P1_SERIALNUMBER)
For a single serial number of the form CU5-0799 every thing works. I am a little suprised this works because the SERIALNUMBER in the WARRANTYSTATUS table is of type varchar2 which means the serial number in the where clause must be surrounded by single quoties. Not sure where the single quoties are being added.
However, what I like to do is to enter more that one serial number, seperated by commas, in the same text box, and then the query return a result for each serial number. What I would like to enter is:
CU5-0799, CU5-07132, CU5-89345
The problem is this string of three serial numbers will needs to be have single quotes around each serial number at the level of the sql statement. So the question is how do I make this work?? Thanks for the help in advance.Bob,
If you would change your OTN handle to something more mnemonically friendly, that would help us. Thanks.
This topic is addressed fully, with various techniques described, here: Re: Search on a typed in list of values .
I am a little suprised this works because the SERIALNUMBER in the WARRANTYSTATUS table is of type varchar2 which means the serial number in the where clause must be surrounded by single quoties.
Not true. Quotes are used for literals, not bind variables.
Scott -
Hello,
Is it possible to submit a list item and at same time query/search the results if parameters are matched.
Example - user logon to site enter search parameters and hit submit button. Once done parameters gets saved in list and shows search results on page. I have been asked to do this with
SP designer and InfoPath doesn’t work due items limits.
Please suggest.
Thanks,
Manish
ManishHi Manish,
may i ask if you need,
when user account click the login button, it will be authenticate the user and then it will show search result page?
may i know how the keyword of words to be put? is it together with the user account box, password and keyword?
or it will be like, after user authenticate, it will redirect to search page, so that user may use the search page to input the keyword?
Regards,
Aries
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. -
Same Query returning different result (Different execution plan)
Hi all,
To day i have discovered a strange thing: a query that return a different result when using a different execution plan.
The query :
SELECT *
FROM schema.table@database a
WHERE column1 IN ('3')
AND column2 = '101'
AND EXISTS
(SELECT null
FROM schema.table2 c
WHERE a.column3 = SUBSTR (c.column1, 2, 12));where schema.table@database is a remote table.
when executed with the hint /*+ ordered use_nl(a c) */ these query return no result and its execution plan is :
Rows Row Source Operation
0 NESTED LOOPS (cr=31 r=0 w=0 time=4894659 us)
4323 SORT UNIQUE (cr=31 r=0 w=0 time=50835 us)
4336 TABLE ACCESS FULL TABLE2 (cr=31 r=0 w=0 time=7607 us)
0 REMOTE (cr=0 r=0 w=0 time=130536 us)When i changed the execution plan with the hint /*+ use_hash(c a) */
Rows Row Source Operation
3702 HASH JOIN SEMI (cr=35 r=0 w=0 time=497839 us)
22556 REMOTE (cr=0 r=0 w=0 time=401176 us)
4336 TABLE ACCESS FULL TABLE2 (cr=35 r=0 w=0 time=7709 us)It seem that when the execution plan have changed the remote query return no result.
It'is a bug or i have missed somthing ?
PS: The two table are no subject to insert or update statement.
Oracle version : 9.2.0.2.0
System version : HP-UX v1
Thanks.H.Mahmoud wrote:
Oracle version : 9.2.0.2.0
System version : HP-UX v1Hard to say. You're using a very old and deprecated version of the database, and one that was known to contain bugs.
9.2.0.7 was really the lowest version of 9i that was considered to be 'stable', but even so, it's old and lacking in many ways.
Consider upgrading to the latest database version at your earliest opportunity. (or at least apply patches up to the latest 9i version before querying if there is bugs in your really low buggy version) -
Problem of running the jump query from the result line
Dear expert,
I have a problem when running a jump query from the result line. Apparently, the values of the caracteristics haven't been sent to the jump target. However, the configuration in RSBBS seems to be good as the jump works well from the other lines.
Does anyone have some ideas on that?
Thanks in advance!Hi,
If you are supposed to bring across characteristic values to your target, then you will not be able to jump from the result line. The configuration expects that the values of the characteristic marked as being used in the jump are filled with unique values. When you use the result line as a source for your jump, the values in the result line will most likely be based on the sum of multiple characteristic values.
Hth,
-Jacob -
Can i query from a results which got from another query?
if i query a container and i get a results,then if i want to query in the results,can i?and how to do it?
thanks a lot!Hi Turingcat,
In the dbxml shell you can use contextQuery. Here is an example on a test container holding the following documents:
dbxml> getDocuments
4 documents found
dbxml> print
<doc><node><aa>1</aa><bb>2</bb></node><node><aa>3</aa><bb>4</bb></node><node><aa>5</aa><bb>6</bb></node></doc>
<doc><node><aa>1</aa><bb>2</bb></node><node><aa>3</aa><bb>4</bb></node></doc>
<doc><node><aa>1</aa><bb>2</bb></node><node><aa>3</aa><bb>4</bb></node><node><aa>5</aa><bb>6</bb></node><node><aa>7</aa>
<bb>8</bb></node></doc>
<doc><node><aa>1</aa><bb>2</bb></node></doc>, that first retrieve all the documents that have a <bb>6</bb> node:
dbxml> query "for $i in collection('mnodes.dbxml')/doc where $i/node/bb=6 return $i"
2 objects returned for eager expression 'for $i in collection('mnodes.dbxml')/doc where $i/node/bb=6 return $i'
dbxml> print
<doc><node><aa>1</aa><bb>2</bb></node><node><aa>3</aa><bb>4</bb></node><node><aa>5</aa><bb>6</bb></node></doc>
<doc><node><aa>1</aa><bb>2</bb></node><node><aa>3</aa><bb>4</bb></node><node><aa>5</aa><bb>6</bb></node><node><aa>7</aa>
<bb>8</bb></node></doc>and afterwards, queries the result set and retrieves the document(s) that has a <aa>7</aa> node:
dbxml> contextQuery "let $s:= . where $s/node[aa=7] return $s"
1 objects returned for expression 'let $s:= . where $s/node[aa=7] return $s'
dbxml> print
<doc><node><aa>1</aa><bb>2</bb></node><node><aa>3</aa><bb>4</bb></node><node><aa>5</aa><bb>6</bb></node><node><aa>7</aa>
<bb>8</bb></node></doc>Now, using the APIs, C++ or Java, you can achieve this functionality by obtaining a result set (either through an XmlQueryExpression.execute() call or an XmlManager.query() call), and than constructing an XmlQueryExpression which will be used while iterating the result set to query against each XmlValue context item (the XmlQueryExpression.execute() forms of the method with an XmlValue &contextItem parameter).
Regards,
Andrei -
LIMIT IN QUERY TO LIMIT RESULTS
I was reading the article here:
http://www.inquiry.com/techtips/oracle_pro/10min/10min1200/10min1200-3.asp
I am working from an oracle 8i database with a few thousand records in it.
Can you help me out here? I tried the example method, and it appears to me that it is only returning sets of data
that are below the ROWNUM I request. For example, if I use .... WHERE ROWNUM<100 ... It looks like it only gets data from the first 100 rows of the table instead of a count of the query's result row numbers.
When I put a very loose term into the search, it should return the max, 100 lines, but only returns 87. I know one query produces 156 results, but this limit cuts off at 60.
I really would like to be able to show 30 results per page and have users click 'next page' to view the next 30. It seems absurd to me that with Postgress, or MySQL I can do this very easily with ... LIMIT 100,30 .... Oracle DB does not have the capability? I don't know.
Please, if you know you can help. (PLEASE!)Perhaps a less offensive way to put it might have been simply to ask, "does anyone know how to do this in Oracle as I am relatively inexperienced in this environment" instead of "It seems absurd to me that with Postgress, or MySQL I can do this very easily with ... LIMIT 100,30 .... Oracle DB does not have the capability?". The implication is clearly that these other environments are superior, which is offensive, especially when avowed by someone who has demonstrated his limited knowledge of Oracle.
-
Hi All,
We are using SQL Server 2012. We have Table1 like below.
Table1:
SecurityKey
Description
PID
110
qqq
1
111
ddd
1
112
fff
1
113
vvvv
1
114
bbb
1
115
ggg
1
116
hhhh
1
One of the third party system adds records into the following table like this.
Table2
ID
MasterID
Type
Amount
SecurityKey
Date
TransNum
1
110
Buy
600
0
01/13/2014
2178
2
111
Buy
100
110
01/13/2014
2179
3
112
Buy
200
110
01/13/2014
2180
4
113
Buy
300
110
01/13/2014
2181
5
114
Sell
100
110
01/14/2014
6
115
Sell
200
110
01/14/2014
7
116
Sell
300
110
01/14/2014
In above table, primary key is combination of ID, MasterID and Type. All ‘Buy’ type transactions are entered into Table2 by Vendor system by running scheduled job. SecurityKey 110 has child records. So, in Table2, 111, 112, 113 belong to 110. Next day, another
system creates exact matching ‘Sell’ transactions to all buy transactions except for parent (here record with MasterID 110). When ‘Sell’ transactions are created, TransNum is not populated.
I need to write a select query in such a way that I need to get all ‘Buy’ Transactions for a particular date and get corresponding ‘Sell’ Transactions with TransNum populated.
The result set should look like this.
2
111
Buy
100
110
01/13/2014
2179
3
112
Buy
200
110
01/13/2014
2180
4
113
Buy
300
110
01/13/2014
2181
5
114
Sell
100
110
01/14/2014
2179
6
115
Sell
200
110
01/14/2014
2180
7
116
Sell
300
110
01/14/2014
2181
How can I write select query to get result set above by applying ‘Buy’ transaction TransNum to
corresponding ‘Sell’Transaction. I see only amount and SecurityKey as joining columns.
Thanks,
Spunny;With CTE
AS
SELECT ROW_NUMBER() OVER (PARTITION BY SecurityKey,Type ORDER BY MasterID) AS Seq,*
FROM Table2
WHERE SecurityKey > 0
SELECT t1.ID,
t1.MasterID,
t1.Type,
t1.Amount,
t1.SecurityKey,
t1.[Date],
COALESCE(t1.TransNum,t2.TransNum) AS TransNum
FROM CTE t1
INNER JOIN CTE t2
ON t1.SecurityKey = t2.SecurityKey
AND t1.Seq = t2.Seq
AND t2.Type = 'Buy'
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
Unable to access Query Rules and Result Sources in SSA
I have access to our Search Service Application (SSA) within Central Administration. I am able to get to all of the options within Search Administration except for Query Rules and Result Sources. Does this require farm admin access or is there
something special that needs to be done for access to these two areas? I can get to all of the Diagnostics, Crawling, and the other Queries and Results options without issue. Our farm admin has been looking at it, but we have not been able to determine
why my access is not allowing me to get to those options. Any info you may have about this will be much appreciated.
Thanks!
BrianHi scalawagd,
This issue seems to be about permissions. Please add the user into the search service administrator group and give him full control, compare the result. You can try to give the user permission like the screenshot:
Best Regards,
Wendy
Wendy Li
TechNet Community Support -
SQL Query -How2bring multiple results into one field using Formatted Search
Hi Everyone
i am trying to bring in the results of the field dbo.Lot_ITEM.LOT using a formatted search into a row level using the following query:
SELECT dbo.LOT_ITEM.LOT
FROM dbo.DLN1 INNER JOIN dbo.LOT_ITEM ON dbo.DLN1.ItemCode = dbo.LOT_ITEM.ITEM
WHERE dbo.LOT_ITEM.ITEM=$[DLN1.ItemCode]
however the result of the dbo.Lot_ITEM.LOT field could be more then one value depending on how many lots are assigned for that item
(for example this query would be similar to assigning batch/serial numbers to an item being despatched - as you can choose multiple batches/serials depending on the quantities available and required and then move from the left to the right side of the selection window) if that makes sense!
is it possible to bring in the multiple results into one field? and how can i amend the above query to include this?
Thankyou in advance :o)
Edited by: Asma Bi on Apr 23, 2008 7:22 PM
Edited by: Asma Bi on Apr 23, 2008 7:24 PMHi Suda
Thanks for replying :o) but im not sure about the query?
just to simplify it (as the query im working with is to do with 3rd party addons) i have used the serial/batchs field instead and used standard demo database fields from SBO 2005 sp01:
SELECT dbo.ixvSerialNoFact.SRI1_IntrSerial
FROM dbo.DLN1 INNER JOIN
dbo.ixvSerialNoFact ON dbo.DLN1.DocEntry = dbo.ixvSerialNoFact.SRI1_BaseEntry
WHERE dbo.ixvSerialNoFact.ItemCode='g1000' and dbo.ixvSerialNoFact.SRI1_BaseEntry = '193'
The above brings me the relevant results but when i change it to be used in a formatted search:
SELECT dbo.ixvSerialNoFact.SRI1_IntrSerial
FROM dbo.DLN1 INNER JOIN
dbo.ixvSerialNoFact ON dbo.DLN1.DocEntry = dbo.ixvSerialNoFact.SRI1_BaseEntry
WHERE dbo.ixvSerialNoFact.ItemCode=$[dln1.itemcode] and dbo.ixvSerialNoFact.SRI1_BaseEntry = $[dln1.DocEntry]
i cant seem to get it to work - now this may be because the serial number is not allocated until teh record is added to the system, however when this happens i am unable to go back in and manually trigger the query as the delivery note rows cannot be selected!
i think as what im originally wanting an answer for is same as this example, im wanting to know if this is even possible?
Thanks
Edited by: Asma Bi on Apr 24, 2008 3:53 PM
Edited by: Asma Bi on Apr 24, 2008 3:55 PM -
Can query output the result into excel with a fix format?
Hi Expert,
My user giving me a requirement for new reports. They do not want the standard SAP report format but they want the result to be populate into a excel template with their own fix format. Can BW generate the report like this? Or it is out of the functionality of BW. FYI, I'm using SAP BI 7.0.
Thanks!
Regards.Hi Ang,
You have a way to do through the Bex Analyzer.
Please get the excel template in that please use a analysis design item in the place of the query result display.
Then after adding the analysis item then please assign a DP (data provider) with the query you have created.
After that please save the work book in your roles or fav's.
Note: some important settings has to be changed for the workbook.
In workbook settings, tick mark the property "REFRESH upon open of work book"
With Regards,
Ravi
Maybe you are looking for
-
I want all pages to open in a new window when I click on a link, and do not want tabs.
I just downloaded Firefox on my Mac laptop. I don't like using tabs, but prefer new web pages to open in a new window. What command do I use to achieve that?
-
UTL_FILE vs Oracle Tables
Hi Oracle Gurus, I have a question, My team is using UTL_FILE to write process logs to physical files. My thinking is that if they use Direct tables to Insert process log its going to be faster compared to UTL_FILE. Am I right to think so? Thanks, Fa
-
Vendoru3000defined in company code
Hello: I am stopped ay MIRO there is an error message"Vendor is not defined in company code XXXX" Can anyboby advice me how to do this?
-
Hello Folks, I am trying to implement the java client proxies for one of my requirements... i have used the guides provided for the java client proxies in SDN and trying to implemented the same (Mine is asynchronous..) so far I ha
-
MPEG format in Premiere Pro CS5.5
Hello, I have an issue about file format compatibility in CS 5.5. I have 2 type MPEG file format, XDCAM HD 422, 1080i If Video ID is 768, adobe premiere not support this file, but if the video ID is 512, CS 5.5 can read this file. This is the file p