SQ01 results in a single row
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 PM
Hi,
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...
Similar Messages
-
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, -
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. -
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 -
Outputting Results in a single row from a Table
Afternoon folks,
I have a scenario in hand and I was hoping to get some pointers. I could write a PL/SQL program and all would be fine. I was hoping if there was a way to do it in SQL and not have to create a whole new sub-program for this. I already have a PL/SQL program that populates a table. I want to use that data now and output it in a certain manner.
Any help is greatly appreciated and this is not something I need to solve by tonight. :)
Script to create table and insert records into it:
drop table FLIGHT_ROUTES;
CREATE TABLE FLIGHT_ROUTES
(FLIGHT_NO VARCHAR2(7),
ROUTE_ID NUMBER,
DAY_OF_OPERATION NUMBER,
ORIGIN VARCHAR2(3),
DESTINATION VARCHAR2(3),
STOPVER VARCHAR2(3),
ROUTE_TYPE VARCHAR2(1)
REM INSERTING into FLIGHT_ROUTES
Insert into FLIGHT_ROUTES (FLIGHT_NO,ROUTE_ID,DAY_OF_OPERATION,ORIGIN,DESTINATION,STOPVER,ROUTE_TYPE) values ('UX-1001',1,1,'SFO','LAX',null,'D');
Insert into FLIGHT_ROUTES (FLIGHT_NO,ROUTE_ID,DAY_OF_OPERATION,ORIGIN,DESTINATION,STOPVER,ROUTE_TYPE) values ('UX-1001',1,2,'SFO','LAX',null,'R'); -- Record 2
Insert into FLIGHT_ROUTES (FLIGHT_NO,ROUTE_ID,DAY_OF_OPERATION,ORIGIN,DESTINATION,STOPVER,ROUTE_TYPE) values ('UX-2001',2,1,'SFO','JFK',null,'D');
Insert into FLIGHT_ROUTES (FLIGHT_NO,ROUTE_ID,DAY_OF_OPERATION,ORIGIN,DESTINATION,STOPVER,ROUTE_TYPE) values ('UX-2001',2,2,'SFO','JFK','ORD','D');
Insert into FLIGHT_ROUTES (FLIGHT_NO,ROUTE_ID,DAY_OF_OPERATION,ORIGIN,DESTINATION,STOPVER,ROUTE_TYPE) values ('UX-2001',2,3,'SFO','JFK','DEN','R'); -- Record 5
Insert into FLIGHT_ROUTES (FLIGHT_NO,ROUTE_ID,DAY_OF_OPERATION,ORIGIN,DESTINATION,STOPVER,ROUTE_TYPE) values ('UX-3001',3,1,'LAX','JFK','YYZ','D');
Insert into FLIGHT_ROUTES (FLIGHT_NO,ROUTE_ID,DAY_OF_OPERATION,ORIGIN,DESTINATION,STOPVER,ROUTE_TYPE) values ('UX-3001',3,2,'LAX','JFK','YYC','D');
Insert into FLIGHT_ROUTES (FLIGHT_NO,ROUTE_ID,DAY_OF_OPERATION,ORIGIN,DESTINATION,STOPVER,ROUTE_TYPE) values ('UX-3001',3,3,'LAX','JFK','YUL','D');What I would like to do is output the results by Flight Number, Origin1, Destination1, Origin2, Destination 2 and Origin 3, Destination 3. The maxium number combinations per Flight is 3. The other condition is that the listing should only show the Origin and Destinations and Stopover if it's a Day time Flight. If its a Red Eye, then don't show that option. So, Record 2 would be completely omitted here as it's a Red Eye flight and Record 5 would be omitted for Origin/Destination/Stopover 3 for flight UX-2001.
Flight_No Origin1 Destination1 Stopover 1 Origin2 Destination2 Stopver2 Origin3 Destination3 Stopover3
============================================================================================================================================================
UX-1001 SFO LAX
UX-2001 SFO JFK SFO JFK ORD
UX-3001 LAX JFK YYZ LAX JFK YYC LAX JFK YULEdited by: Roxyrollers on Sep 9, 2011 3:59 PM
Edited by: Roxyrollers on Sep 9, 2011 3:59 PM
Edited by: Roxyrollers on Sep 9, 2011 4:00 PMHi,
Assuming that day_of_operation is what determines whether a row is 1, 2 or 3:
WITH got_r_num AS
SELECT f.*
, ROW_NUMBER () OVER ( PARTITION BY flight_no
ORDER BY day_of_operation
) AS r_num
FROM flight_routes f
WHERE route_type != 'R'
SELECT flight_no || ',' ||
MAX (CASE WHEN r_num = 1 THEN origin END) || ',' || -- Origin 1
MAX (CASE WHEN r_num = 1 THEN destination END) || ',' || -- Destination 1
MAX (CASE WHEN r_num = 1 THEN stopver END) || ',' || -- Stopover 1
MAX (CASE WHEN r_num = 2 THEN origin END) || ',' || -- Origin 2
MAX (CASE WHEN r_num = 2 THEN destination END) || ',' || -- Destination 2
MAX (CASE WHEN r_num = 2 THEN stopver END) || ',' || -- Stopover 2
MAX (CASE WHEN r_num = 3 THEN origin END) || ',' || -- Origin 3
MAX (CASE WHEN r_num = 3 THEN destination END) || ',' || -- Destination 3
MAX (CASE WHEN r_num = 3 THEN stopver END) AS csv_text -- Stopover 3
FROM got_r_num
GROUP BY flight_no
ORDER BY flight_no
;Output:
CSV_TEXT
UX-1001,SFO,LAX,,,,,,,
UX-2001,SFO,JFK,,SFO,JFK,ORD,,,
UX-3001,LAX,JFK,YYZ,LAX,JFK,YYC,LAX,JFK,YULThis does not assume that origin1 is always on the same row with day_of_operation=1. Origin1 will be from the row with the lowest day_of_operation, not counting red-eyes. Likewise, origin2 will be from the row with the 2nd lowest day_of_operation, whether that value is 2 or not.
If your data is such that the row with day_of_operation=n will necessarily be the nth lowest one, not counting red-eyes, then you don't need the sub-query got_r_num; just use your real table (with the condition WHERE route_type != 'R'), and use day_of_operation where I used r_num. (This is what Solomon's solution, which I just saw, does.)
Edited by: Frank Kulash on Sep 9, 2011 4:47 PM
Edited by: Frank Kulash on Sep 9, 2011 4:53 PM -
How to avoid word wrap in the BW Report so that result fits in single row
Hello Colleagues
I have a report which shows Material number versus Revenue. In the row, material is displayed with Technical name and description.
Here, the view of the report shows the description in single line. While, in the report, description of the report runs 3 to 4 lines though description contains 5 to 6 words (which can fit easily into single line).
Let me know how to restrict each row descrption into single line.
Regards,
Ningarajuno answers opened new thread to make more clear
-
Template:Multiple field result in a single row, comma separated
Hello,
without* having to write a function in Pl/SQL, is it possible, when I have this query,
select
"DOSSIER"."ID" as "DOSSIERID",
"DOSSIER"."TITLE" as "TITLE",
"DVD"."ID" as "DVDID",
"DVD"."NAME" as "DVDNAME",
"DVD"."ID_DOSSIER" as "DVD_ID_DOSSIER",
"ELEMENTS"."ID" as "ELEMENTSID",
"ELEMENTS"."NAME" as "ELEMENTSNAME",
"ELEMENTS"."ID_DVD" as "ELEMENTS_ID_DVD"
from "DOSSIER" "DOSSIER",
"DVD" "DVD",
"ELEMENTS" "ELEMENTS"
where "DVD"."ID_DOSSIER"="DOSSIER"."ID"
and "ELEMENTS"."ID_DVD"="DVD"."ID"
and "DOSSIER"."TITLE" = 'FIGARO'**Instead of having this result ( with break in the template)*
FIGARO C2008-203 12l10201.tif
12l10202.tif
12l11101.tif
12l11102.tif
12l11201.tif
12l11202.tif
12l12101.tif
12l12102.tif
C2008-204 12l12202.tif
12l13101.tif
12l13102.tif
12l13201.tif
12l13202.tif
12l14101.tif
12l14102.tif
12l14201.tif
12l14202.tif
12l15101.tif
12l15102.tif
12l15201.tif
C2008-205 12l15202.tif
12l16101.tif
12l16102.tif
12l16201.tif
12l16202.tif
12m01101.tif
12m01102.tifhaving this result, WITH the element only, comma separeted??? ( I can have from 0 to 500 elements)
FIGARO
DVD: C2008-203
Elements: 12l10201.tif, 12l10202.tif, 12l11101.tif, 12l11102.tif, 12l11201.tif, 2l11202.tif, 12l12101.tif, 12l12102.tifthanks, RoselineThis should help you http://tkyte.blogspot.com/2007/03/stringing-them-up.html
-
Returning results as a single-row sub query.
Hi,
This is my current query
WITH car as (SELECT 'FORD' make FROM DUAL UNION SELECT 'TOYOTA' make FROM DUAL UNION SELECT'BMW' make FROM DUAL UNION SELECT 'FIAT' make FROM DUAL)
SELECT * FROM CARWhich returns:-
BMW
FIAT
FORD
TOYOTAHowever the actual output required:-
'BMW, FIAT, FORD, TOYOTA'i.e. all returned on one row.
Any ideas on how to do this??
Thanks in advance!
DavidHi,
Or: use row_number() and connect by:
SQL> select ltrim(sys_connect_by_path(make,', '),', ') make
2 from (
3 WITH car as (SELECT 'FORD' make FROM DUAL union
4 SELECT 'TOYOTA' make FROM DUAL UNION
5 SELECT'BMW' make FROM DUAL UNION
6 SELECT 'FIAT' make FROM DUAL
7 )
8 SELECT make
9 , row_number() over (order by make) rn
10 FROM CAR
11 )
12 where connect_by_isleaf = 1
13 connect by rn = prior rn + 1
14 start with rn = 1
15 order by make
16 ;
MAKE
BMW, FIAT, FORD, TOYOTA
1 row selected.Edited by: hoek on Jun 5, 2009 12:56 PM
But how could I even think I'd type faster than Lightnin' Blushadow? ;) -
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 -
thanks
Edited by: 786304 on May 25, 2011 12:22 PMBluShadow .
I agree your opinion.
I resurrect it from google cache.
Hi All,
I have two queries as follows
Select
Xrc.Profile_Nbr Var_Profile_Nbr,
xsr.Profile_Nbr Var_Profile_Nbr,
Nvl(Ppa.First_Name,' ') Var_First_Name,
Nvl(Ppa.Last_Name,' ') Var_Last_Nmae,
Nvl(Ppa.Last_Name2,' ') Var_Last_Name2,
Nvl(Ppa.Middle_Name,' ') Var_Middle_Name,
Nvl(Pfl.Display_Name,' ') Var_Display_Name,
Nvl(Addr.Street1,' ') Var_Street1,
Nvl(Addr.Street2,' ') Var_Street2,
Nvl(Addr.City,' ') Var_City ,
Nvl(Addr.State_Name,' ') Var_State_Name,
Addr.Post_Code Var_Post_Code,
Nvl(Cnt.Cntry_Name,' ') Var_Country,
Phn.Phone Var_Phone_Nbr,
Nvl(To_Char(Ppa.Birthdate,'MON/DD/YYYY'),' ') Var_Birthdate,
Nvl(Ppa.Occupation,' ') Var_Occupation,
Nvl(Ppa.Country_Of_Nationality,1) Var_Country_Of_Nationality,
Nvl(Ppa2.First_Name,' ') Var_First_Name,
Nvl(Ppa2.Last_Name,' ') Var_Last_Nmae,
Nvl(Ppa2.Last_Name2,' ') Var_Last_Name2,
Nvl(Ppa2.Middle_Name,' ') Var_Middle_Name,
Nvl(Pfl2.Display_Name,' ') Var_Display_Name,
Nvl(Addr2.Street1,' ') Var_Street1,
Nvl(Addr2.Street2,' ') Var_Street2,
Nvl(Addr2.City,' ') Var_City ,
Nvl(Addr2.State_Name,' ') Var_State_Name,
Addr2.Post_Code Var_Post_Code,
Nvl(Cnt2.Cntry_Name,' ') Var_Country,
Phn2.Phone Var_Phone_Nbr,
Nvl(To_Char(Ppa2.Birthdate,'MON/DD/YYYY'),' ') Var_Birthdate,
Nvl(Ppa2.Occupation,' ') Var_Occupation,
Nvl(ppa2.COUNTRY_OF_NATIONALITY,1) var_COUNTRY_OF_NATIONALITY
From
V_Xact_Receiver Xrc, V_Person_Profile Ppa, V_Profile Pfl,V_Phone Phn,V_Address Addr,V_Country_Lu Cnt
,V_Xact_sender xsr, V_Person_Profile Ppa2, V_Profile Pfl2,V_Phone Phn2,V_Address Addr2,V_Country_Lu Cnt2
Where Xrc.Xact_Hdr_Nbr=71138142
and xsr.Xact_Hdr_Nbr=71138142
And xrc.Profile_Nbr=Ppa.Profile_Nbr
And Ppa.Profile_Nbr=Pfl.Profile_Nbr
And Pfl.Profile_Nbr=Phn.Profile_Nbr
And Pfl.Profile_Nbr=Addr.Profile_Nbr
And Phn.Country_Nbr=Cnt.Country_Nbr
And Xsr.Profile_Nbr=Ppa2.Profile_Nbr
And Ppa2.Profile_Nbr=Pfl2.Profile_Nbr
And Pfl2.Profile_Nbr=Phn2.Profile_Nbr
And Pfl2.Profile_Nbr=Addr2.Profile_Nbr
And Phn2.Country_Nbr=Cnt2.Country_Nbr;
and
SELECT
Nvl(Dlu.Id_Type_Desc,' ') Var_Ident_Type_Desc,
Nvl(D.Id_Number,' ') Var_Id_Number,
Nvl(To_Char(D.Id_Issue_Date,'MON/DD/YYYY'),' ') Dte_Id_Issue,
Nvl(To_Char(D.Id_Expiration_Date,'MON/DD/YYYY'),' ') Dte_Id_Expiration,
Nvl(To_Char(Id_Expiration_Date,'MON/DD/YYYY'),' ') Dte_Id_Expiration,
Nvl(D.Id_Issue_Place,' ') Var_Issue_Loc,
Nvl(Pfl.Occupation,' ') Var_Occupation,
Nvl(To_Char(Pfl.Birthdate,'MON/DD/YYYY'),' ') Dte_Birth,
Nvl(To_Char(Pfl.Country_Of_Nationality,'MON/DD/YYYY'),' ') Var_Country_Of_Nationality
FROM V_PROFILE_IDENT D,
V_ID_TYPE_LU DLU,
V_Country_Lu Clu,
V_Xact_sender Xsr,
v_person_profile pfl
Where Xsr.Xact_Hdr_Nbr='71138142'
And D.Profile_Nbr = Xsr.Profile_Nbr
and D.Profile_Nbr=pfl.Profile_Nbr
And D.Id_Type_Nbr = Dlu.Id_Type_Nbr
And D.Country_Nbr = Clu.Country_Nbr(+)
And D.Is_Valid = 'Y'
and rownum<=3;
The first query it returns the result in a single row
The second query it returns the output in 3 rows
while i was club these two it gives the result in 3 rows
but have to get the result in a single row with all appropriate values side by side if the values are same get the values one only
and the query club as
Select
Xrc.Profile_Nbr Var_Profile_Nbr,
xsr.Profile_Nbr Var_Profile_Nbr,
Nvl(Ppa.First_Name,' ') Var_First_Name,
Nvl(Ppa.Last_Name,' ') Var_Last_Nmae,
Nvl(Ppa.Last_Name2,' ') Var_Last_Name2,
Nvl(Ppa.Middle_Name,' ') Var_Middle_Name,
Nvl(Pfl.Display_Name,' ') Var_Display_Name,
Nvl(Addr.Street1,' ') Var_Street1,
Nvl(Addr.Street2,' ') Var_Street2,
Nvl(Addr.City,' ') Var_City ,
Nvl(Addr.State_Name,' ') Var_State_Name,
Addr.Post_Code Var_Post_Code,
Nvl(Cnt.Cntry_Name,' ') Var_Country,
Phn.Phone Var_Phone_Nbr,
Nvl(To_Char(Ppa.Birthdate,'MON/DD/YYYY'),' ') Var_Birthdate,
Nvl(Ppa.Occupation,' ') Var_Occupation,
Nvl(Ppa.Country_Of_Nationality,1) Var_Country_Of_Nationality,
Nvl(Ppa2.First_Name,' ') Var_First_Name,
Nvl(Ppa2.Last_Name,' ') Var_Last_Nmae,
Nvl(Ppa2.Last_Name2,' ') Var_Last_Name2,
Nvl(Ppa2.Middle_Name,' ') Var_Middle_Name,
Nvl(Pfl2.Display_Name,' ') Var_Display_Name,
Nvl(Addr2.Street1,' ') Var_Street1,
Nvl(Addr2.Street2,' ') Var_Street2,
Nvl(Addr2.City,' ') Var_City ,
Nvl(Addr2.State_Name,' ') Var_State_Name,
Addr2.Post_Code Var_Post_Code,
Nvl(Cnt2.Cntry_Name,' ') Var_Country,
Phn2.Phone Var_Phone_Nbr,
Nvl(To_Char(Ppa2.Birthdate,'MON/DD/YYYY'),' ') Var_Birthdate,
Nvl(Ppa2.Occupation,' ') Var_Occupation,
Nvl(Ppa2.Country_Of_Nationality,1) Var_Country_Of_Nationality,
Nvl(Dlu.Id_Type_Desc,' ') Var_Ident_Type_Desc,
Nvl(D.Id_Number,' ') Var_Id_Number,
Nvl(To_Char(D.Id_Issue_Date,'MON/DD/YYYY'),' ') Dte_Id_Issue,
Nvl(To_Char(D.Id_Expiration_Date,'MON/DD/YYYY'),' ') Dte_Id_Expiration,
Nvl(To_Char(Id_Expiration_Date,'MON/DD/YYYY'),' ') Dte_Id_Expiration,
Nvl(D.Id_Issue_Place,' ') Var_Issue_Loc,
Nvl(Pfl3.Occupation,' ') Var_Occupation,
Nvl(To_Char(Pfl3.Birthdate,'MON/DD/YYYY'),' ') Dte_Birth,
Nvl(To_Char(Pfl3.Country_Of_Nationality,'MON/DD/YYYY'),' ') Var_Country_Of_Nationality
From
V_Xact_Receiver Xrc, V_Person_Profile Ppa, V_Profile Pfl,V_Phone Phn,V_Address Addr,V_Country_Lu Cnt
,V_Xact_sender xsr, V_Person_Profile Ppa2, V_Profile Pfl2,V_Phone Phn2,V_Address Addr2,V_Country_Lu Cnt2
V_Profile_Ident D,
V_Id_Type_Lu Dlu,
V_Country_Lu Clu,
V_Xact_receiver Xrc2,
v_person_profile pfl3
Where Xrc.Xact_Hdr_Nbr=71138142
And Xsr.Xact_Hdr_Nbr=71138142
and xrc2.Xact_Hdr_Nbr=71138142
And xrc.Profile_Nbr=Ppa.Profile_Nbr
And Ppa.Profile_Nbr=Pfl.Profile_Nbr
And Pfl.Profile_Nbr=Phn.Profile_Nbr
And Pfl.Profile_Nbr=Addr.Profile_Nbr
And Phn.Country_Nbr=Cnt.Country_Nbr
And Xsr.Profile_Nbr=Ppa2.Profile_Nbr
And Ppa2.Profile_Nbr=Pfl2.Profile_Nbr
And Pfl2.Profile_Nbr=Phn2.Profile_Nbr
And Pfl2.Profile_Nbr=Addr2.Profile_Nbr
And Phn2.Country_Nbr=Cnt2.Country_Nbr
And D.Profile_Nbr = Xrc2.Profile_Nbr
and D.Profile_Nbr=pfl3.Profile_Nbr
And D.Id_Type_Nbr = Dlu.Id_Type_Nbr
And D.Country_Nbr = Clu.Country_Nbr(+)
And D.Is_Valid = 'Y'
and rownum<=3;
regards, -
Club Multiple rows into single row
Hi,
Iam facing this problem. Iam having this table client_details with columns as
client -- group -- group_code
1234 ------ X ------ code1
1234 ------ Y ------ code2
5555 ------ X ------ code3
5555 ------ Y
Now when I Query this table for a particular client, I require both the group_code for this client (it can be null also). But I require the result in a SINGLE row.
The group will be either X or Y only.
Can anyone help me out pls
tnx
Cheoops
SQL> select client, max(decode("GROUP", 'X', GROUP_CODE)) X, max(decode("GROUP", 'Y', GROUP_CODE)) Y from client_details group by client;
CLIENT X Y
1234 code1 code2
5555 code3 -
The attached file is work inprogress, with some dummy data sp that I can test it out without having to connect to equipment.
The second tab is the one that I am having the problem with. the output array from the replace element appears to be starting at the index position of 1 rather than 0 but that is ok it is still show that the new data is placed in incrementing element locations. However the main array that I am trying to build that is suppose to take each new calculation and place it in the next index(row) does not ap
pear to be working or at least I am not getting any indication on the inidcator.
Basically what I am attempting to do is is gather some pulses from adevice for a minute, place the results for a calculation, so that it displays then do the same again the next minute, but put these result in the next row and so on until the specifiied time has expired and the loop exits. I need to have all results displayed and keep building the array(display until, the end of the test)Eventually I will have to include a min max section that displays the min and max values calculated, but that should be easy with the min max function.Actually I thought this should have been easy but, I gues I can not see the forest through the trees. Can any one help to slear this up for me.
Attachments:
regulation_tester_7_loops.vi 244 KBI didn't really have time to dig in and understand your program in depth,
but I have a few tips for you that might things a bit easier:
- You use local variables excessively which really complicates things. Try
not to use them and it will make your life easier.
- If you flowchart the design (very similar to a dataflow diagram, keep in
mind!) you want to gather data, calculate a value from that data, store the
calculation in an array, and loop while the time is in a certain range. So
theres really not much need for a sequence as long as you get rid of the
local variables (sequences also complicate things)
- You loop again if timepassed+1 is still less than some constant. Rather
than messing with locals it seems so much easier to use a shiftregister (if
absolutely necessary) or in this case base it upon the number of iterations
of the loop. In this case it looks like "time passed" is the same thing as
the number of loop iterations, but I didn't check closely. There's an i
terminal in your whileloop to read for the number of iterations.
- After having simplified your design by eliminating unnecessary sequence
and local variables, you should be able to draw out the labview diagram.
Don't try to use the "insert into array" vis since theres no need. Each
iteration of your loop calculates a number which goes into the next position
of the array right? Pass your result outside the loop, and enable indexing
on the terminal so Labview automatically generates the array for you. If
your calculation is a function of previous data, then use a shift register
to keep previous values around.
I wish you luck. Post again if you have any questions. Without a more
detailed understanding of your task at hand it's kind of hard to post actual
code suggestions for you.
-joey
"nelsons" wrote in message
news:[email protected]...
> how do I create a 1d array that takes a single calculation and insert
> the result into the first row and then the next calculation the next
> time the loop passes that point and puts the results in thsecond row
> and so on until the loop is exited.
>
> The attached file is work inprogress, with some dummy data sp that I
> can test it out without having to connect to equipment.
> The second tab is the one that I am having the problem with. the
> output array from the replace element appears to be starting at the
> index position of 1 rather than 0 but that is ok it is still show that
> the new data is placed in incrementing element locations. However the
> main array that I am trying to build that is suppose to take each new
> calculation and place it in the next index(row) does not appear to be
> working or at least I am not getting any indication on the inidcator.
>
> Basically what I am attempting to do is is gather some pulses from
> adevice for a minute, place the results for a calculation, so that it
> displays then do the same again the next minute, but put these result
> in the next row and so on until the specifiied time has expired and
> the loop exits. I need to have all results displayed and keep building
> the array(display until, the end of the test)Eventually I will have to
> include a min max section that displays the min and max values
> calculated, but that should be easy with the min max function.Actually
> I thought this should have been easy but, I gues I can not see the
> forest through the trees. Can any one help to slear this up for me. -
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 -
Merge multiple rows to get single row result
Hi,
Below is the sample data from my table USERINFO-
personid userid username orgid
1234 1235 TOM 1
2345 2346 HARRY 1
1111 2222 BOND 2
3333 4444 BERY 2
Now I want a query which can give me the following result-
personid userid username personid userid username orgid
1234 1235 TOM 2345 2346 HARRY 1
1111 2222 BOND 3333 4444 BERY 2
i.e., two records belonging to the same orgid should be merged into a single row resulset.
Please let me know the SQL query to get the desired result.
ThanksSQL> select * from test_otn;
PERSONID USERID USERNAME ORGID
1234 1235 TOM 1
2345 2346 HARRY 1
1111 2222 BOND 2
3333 4444 BERY 2
SQL> select max(decode(rn, 1, personid, null)) person_id1,
2 max(decode(rn, 2, personid, null)) person_id2,
3 max(decode(rn, 1, userid, null)) user_id1,
4 max(decode(rn, 2, userid, null)) user_id2,
5 max(decode(rn, 1, username, null)) username1,
6 max(decode(rn, 2, username, null)) username2,
7 orgid
8 from
9 (select row_number() over (partition by orgid order by orgid) rn,
10 personid, userid, username, orgid from test_otn)
11 group by orgid
12 /
PERSON_ID1 PERSON_ID2 USER_ID1 USER_ID2 USERNAME1 USERNAME2 ORGID
1234 2345 1235 2346 TOM HARRY 1
1111 3333 2222 4444 BOND BERY 2
Thx,
SriDHAR -
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
Maybe you are looking for
-
How do I use a JMS MessageSelector with application-specific properties
According to a couple of JMS references (Sun, Oreilly) and the oracle documentation (under the heading "Using Oracle Java Messaging Service (JMS) to Access AQ", page 102 of 1082 , Application Developers Guide - Advanced Queuing, Release 2 (8.1.6)) St
-
HI, Vendor supplies milk.The fat content varies in the milk each & every time.I record the results thro QM check.I have to pay the vendor based on the fat content.How can i map this scenario. murugan
-
Hello I am really new to SAP CRM 7.0. Although i have been working on ABAP for past 4 years now, i am finding it really difficukt to get a hold on CRM now. Can anyone please suggest me the books\links and stuff to learn the software in a more efficie
-
Document downloadin​g
Hi, new user and not computer savvy at all. I downloaded a document from an email attachment. It will not open, message says it won't open becuase it's an RTF file (don't know what that is). This question was already asked and answered on this fo
-
How do i load , name a cd "not music ?
How do you name / input a new cd that is not a music cd ?