Sql query to bring single record from right side of a table
hi
I have two tables as below:
create table testsh1 ( idd varchar2(10), name varchar2(20));
create table testsh2 ( idd varchar2(10), balance float );
insert into testsh1 values('1','abc');
insert into testsh1 values('2','def');
insert into testsh1 values('3','ghi');
insert into testsh1 values('4','jkl');
insert into testsh1 values('4','jkl');
insert into testsh1 values('3','ghi');
insert into testsh2 values('1',500);
insert into testsh2 values('1',500);
insert into testsh2 values('3',1000);
insert into testsh2 values('3',1000);
insert into testsh2 values('4',1500);
insert into testsh2 values('4',1500);
insert into testsh2 values('1',500);
I am expecting the result below:
1 abc 500
2 def NULL
3 ghi 1000
3 ghi 1000
4 jkl 1500
4 jkl 1500
That is only records from testsh1 table can come as many times but from testsh2 only we need to bring unique and matching records on column idd.
Please help
Thanks
Hi Shavetha,
As the testsh2 has duplicates of each record, the DISTINCT of the record has to be record has to be applied.
Please Try this,
SELECT IDD, NAME, (SELECT DISTINCT BALANCE
FROM TESTSH2 B
WHERE B.IDD = A.IDD) BALANCE
FROM TESTSH1 A;Which Outputs:
IDD NAME BALANCE
1 abc 500
2 def
3 ghi 1000
4 jkl 1500
4 jkl 1500
3 ghi 1000Thanks,
Shankar
Similar Messages
-
SQL Loader problem while loading records from txt file to database table.
I am getting following error while loading records from flat txt file into database table with the help of 'sqlldr' command. I have executed catldr.sql from RDBMS folder but it is still showing same error. I am setting DIRECT = TRUE while issuing sqlldr command. If I try with DIRECT = FALSE then it works fine. Database is Oracle 8i.
SQL*Loader-951: Error calling once/load initialization
ORA-24329: invalid character set identifier
F1 Please.Hello,
Direct path load, can only be used with SQL*Loader and Database have the same version.
Care to tell the database version and sql*loader version you are using.
-Sri -
Dynamic SQL query to get single value from list in a column
I have two tables: tblWorkers and tblSkills. tblWorkers has a
column, Skills, which is populated from a multiple-checkbox form
field with one or more skill_IDs from tblSkills, so each
tblWorkers.Skills consists of a list of one or more comma-delimited
values. For any Skill_ID, I need to generate a listing of all
Workers with the corresponding skill, so I have tried to do
something along the lines of SELECT WorkerName FROM tblWorkers
WHERE Skills IN (Skills, #FORM.Skill_ID#) ... or WHERE Skills IN
(ListFind(Skills, #FORM.Skill_ID#)) ... etc. ??? My results (once I
got data type mismatches out of the way) return all Workers, not
just those with the desired Skill. There must be an easy way to do
this ... How do people with a bit more CF/SQL experience than I
have do this???quote:
Originally posted by:
lucapac
I have two tables: tblWorkers and tblSkills. tblWorkers has a
column, Skills, which is populated from a multiple-checkbox form
field with one or more skill_IDs from tblSkills, so each
tblWorkers.Skills consists of a list of one or more comma-delimited
values. For any Skill_ID, I need to generate a listing of all
Workers with the corresponding skill, so I have tried to do
something along the lines of SELECT WorkerName FROM tblWorkers
WHERE Skills IN (Skills, #FORM.Skill_ID#) ... or WHERE Skills IN
(ListFind(Skills, #FORM.Skill_ID#)) ... etc. ??? My results (once I
got data type mismatches out of the way) return all Workers, not
just those with the desired Skill. There must be an easy way to do
this ... How do people with a bit more CF/SQL experience than I
have do this???
As Kronin implied, we normalize our databases. If you don't
understand that answer, the book "Database Design for Mere Mortals"
is often mentioned on this forum. -
Dear All,
I have a requirement, to write a SQL query to populate the records which are inserted less than 10 no of records.
The tables has the cretaed_date column and along with other key column which will have unique values.
Ex1: The user might have inserted records from application, per week basis, between the date range '01-jun-2013' - 08-jun-2013 , the no of records created by the user during this week may be less than 10 records or more.
But I want to populate the records by giving date range that too, it should pick the records the count which fall with in 10 records.
I dont want the query to populate the records if the user has inserted more than 10 records in a week.
Ex2:
User 1 has created 15 records during the week 1 ( the query should not populate this ).
User 2: has cretaed less than 10 records from the UI during the week 2. ( This details should get populated ).
ThanksUse COUNT to find how many rows where inserted in a week.
If this does not answer your question then please read Re: 2. How do I ask a question on the forums? And provide necessary details. -
SQL query to get the Datetime 06 hours prior to the table Datetime value
Hi Experts,
I'm just trying to create a SQL query to get the Datetime which should be 06 hours prior to my Table column value(Executiontime),
Eg: my Executiontime(column) value is 07:00AM means, this query should fetch the detail of first VMName from table at 01:00AM,
SQL Table Name: TestTable
Columns: VMName(varchar),status(varchar) Executiontime(Datetime)
SQL Query : Select Top 1 VMName from
TestTable where convert(date,Exeutiontime)=convert(date,getdate()) and
status='0' and ExecutionTime > dateadd(hour,6,getdate())
Request someone to alter this Query to my requirement or give me the new one.
Regards,
Sundar
SundarHi All,
Thanks for your Prompt response. I tried the below queries, but still I don't have any luck. Actually the queries are returning the value before the condition met (say when the time difference is more than 06 hours). I want the
query to return exactly @ 06 hour difference or less than 06 hours,
Query 01: Select Top 1 VMName from TestTable where
convert(date,Exeutiontime)=convert(date,getdate())
and status='0'
and ExecutionTime >
dateadd(hour,-6,getdate())
Query 02: Select
Top 1 VMName from TestTable where
status='0'
and ExecutionTime >
dateadd(hour,-6,getdate())
Query 03: Select
Top 1 VMName from TestTable where status='0'
and ExecutionTime >
dateadd(hour,-6,ExecutionTime)
Can someone point out the mistake please.
Regards,
Sundar
Sundar -
Hi from few days onwards i found one abnormality in my iphone4s .That is if i observe my phone settings screen from right side of the device top navigation bar appearing rightside height is more than the left side. In reverse manner from the left side. I dnt know whether it is default feature of iphone or not but i am really disappointed due to this. So please anyone help me in this issue and let me clear my doubt and make me happy. Thanks in advance.
I believe what you are seeing is an optical illusion when viewing the screen from the side. Try to align one of the one of the options in Settings, like General, with the navigation bar you'll see it does the same thing.
Hope that helps -
Insert records from report program into R3 table
Hi
I wanted to insert records from report program into R3 table.
here is my code
data : itab type standard table of zemp initial size 10 with header line.
itab-EMPNO = '012'.
itab-ENAME = 'XXXX'.
itab-JOB = 'XXXX'.
APPEND itab.
insert ztable from table itab.
but i am getting the following error
the type of the data base table and work area/internal table "ITAB" are no unicode-converible.
how can I insert records from report program into R3 table
should I have to write move corresponding
pls guide
thanks
manianHi,
itab-EMPNO = '012'.
itab-ENAME = 'XXXX'.
itab-JOB = 'XXXX'.
APPEND itab.
insert ztable from table itab.
Do one thing
Data : itab type table of ztable with header line.
itab-EMPNO = '012'.
itab-ENAME = 'XXXX'.
itab-JOB = 'XXXX'.
APPEND itab.
insert ztable from table itab.
error will resolve, then try to make structure similar to ZTABLE -
Move dynpro field text from right side on yhe left.
Hi experts. I have a DDic field (char1 as chebox) on screen. I need to move the DDic text for this field from right side to the left side of the checkbox. How can I do it? Is it neccesary to split this one object into two? To create a new text field and handle it in program?
Thanks for your answer.hi Mark,
in the Graphical Screen Painter you have to right click on the field and you'll have some helpful options...
ec -
How can distribute 5 lakhs records from sap R/3 setup tables ?
How can distribute 5 lakhs records from sap R/3 setup tables in to multiple requests in sap BI?
Hello,
what is "lakhs" ?
Please use plain English words on a world wide forum...
Regards,
Olivier -
Unable to change Axis y location from right side to left
Hi All,
I am working with OBIEE 11.1.1.1.7.
I am tring to change the location of AXIS Y (in chart) from right side to left.
please help :-)Hi Tyson,
I did exactly what you have mentioned and it worked fine.
But when I am putting the same thing in my custom.css file as mentioned below, IT's NOT WORKING.
uploaded custom.css at
Application XXX>Shared Components>Cascading Style Sheets
custom.css
.TabHolder,.TabHolderC {text-align:left;}calling custom.css in the Page Template (one level tab)
<head>
<title>#TITLE#</title>
<link rel="stylesheet" href="#IMAGE_PREFIX#themes/theme_16/theme_3_1.css" type="text/css" />
<!--[if IE]><link rel="stylesheet" href="#IMAGE_PREFIX#themes/theme_16/ie.css" type="text/css" /><![endif]-->
<!-- added custom css file -->
<link rel="stylesheet" href="#WORKSPACE_IMAGES#custom.css" type="text/css"/>
#HEAD#
</head>Any idea why it is not picking up???...
Thanks,
Deepak -
Two noise from right side when open the mbp
Every time when I open the laptop, there are two sound like zi zi from right side of it, before the opening music, it sounds like reading the disc, is there something wrong with the computer?
No. The OS, when the MBP is started does a diagnostics check, testing the optical drive as a part of same. That is the sound and it is normal.
Ciao. -
Hi all,
I want to remove zeros from right side.
like : if value is '0.055500000000E+04'.
then the output should be '0.0555'.
How can i get such output.
Plz help me....Hi,
the problem here is u are dealing with a datatype of format F (i.e floating point ) and the output u desire is in packed format .
You cannot delete the zeros of such data typesas type F instead u can move them to the packed datatype and get the result.
do one thing declare a variable of type p and move the value of type f which u have right now to the variable u have declared as type p.
data : v_val type p decimals 4.
v_val = " <------ assign the type f to type p over here .
hope this helps .
regards,
vijay. -
Add additional DESC column at right side of pivot table in bi publisher
ARABIC DESC
India
UAE
Total
English DESC
QUANT_DECIMAL
VALUE_DHS
QUANT_DECIMAL
VALUE_DHS
QUANT_DECIMAL
VALUE_DHS
0
0
0
0
0
0
اجر
4
4
23
5619
27
5623
ABC
اجر
0
0
10
3510
10
3510
CDF
ملابس
0
0
14
772
14
772
XYX
جالية
0
0
25
2020
25
2020
EJB
Total
4
4
72
11921
76
11925
please help me to add another column at right side of pivot table as marked in blue.
1st column indicates in arabic desc and my client want english desc at right side of pivot table
country is group by as INdia and UAE.
Please help me to display the above report in pivot table in BI Publisher;
Thanks
NaveenNaveen,
Do you have that column in the database?
Thanks,
Sasi Nagireddy.. -
tableSelection and multipleSelection on right side of the table
Hi, I'm having problem to align the tick box selection to the right side of the table including the "Select All | Select None" function in UIX. Anyone can help me in this case? Thanks..
<tableSelection>
<multipleSelection text="Select items and ..." onClick="Select('${uix.current.Id}')"/>
</tableSelection>''the blank space doesn't appear in safe mode''
This means that the problem is an add-on, user setting, or
'''[https://support.mozilla.org/en-US/kb/troubleshoot-firefox-issues-using-safe-mode Start Firefox in Safe Mode]''' {web link}
While you are in safe mode;
Type '''about:preferences''' in the address bar and press '''Enter.'''
Select '''Advanced > General.'''
Look for and turn off '''Use Hardware Acceleration'''.
Then check ALL of your settings; Browser and add-ons.
Poke around safe web sites. Are there any problems?.
Then restart. -
Need help for SQL SELECT query to fetch XML records from Oracle tables having CLOB field
Hello,
I have a scenario wherein i need to fetch records from several oracle tables having CLOB fields(which is holding XML) and then merge them logically to form a hierarchy XML. All these tables are related with PK-FK relationship. This XML hierarchy is having 'OP' as top-most root node and ‘DE’ as it’s bottom-most node with One-To-Many relationship. Hence, Each OP can have multiple GM, Each GM can have multiple DM and so on.
Table structures are mentioned below:
OP:
Name Null Type
OP_NBR NOT NULL NUMBER(4) (Primary Key)
OP_DESC VARCHAR2(50)
OP_PAYLOD_XML CLOB
GM:
Name Null Type
GM_NBR NOT NULL NUMBER(4) (Primary Key)
GM_DESC VARCHAR2(40)
OP_NBR NOT NULL NUMBER(4) (Foreign Key)
GM_PAYLOD_XML CLOB
DM:
Name Null Type
DM_NBR NOT NULL NUMBER(4) (Primary Key)
DM_DESC VARCHAR2(40)
GM_NBR NOT NULL NUMBER(4) (Foreign Key)
DM_PAYLOD_XML CLOB
DE:
Name Null Type
DE_NBR NOT NULL NUMBER(4) (Primary Key)
DE_DESC NOT NULL VARCHAR2(40)
DM_NBR NOT NULL NUMBER(4) (Foreign Key)
DE_PAYLOD_XML CLOB
+++++++++++++++++++++++++++++++++++++++++++++++++++++
SELECT
j.op_nbr||'||'||j.op_desc||'||'||j.op_paylod_xml AS op_paylod_xml,
i.gm_nbr||'||'||i.gm_desc||'||'||i.gm_paylod_xml AS gm_paylod_xml,
h.dm_nbr||'||'||h.dm_desc||'||'||h.dm_paylod_xml AS dm_paylod_xml,
g.de_nbr||'||'||g.de_desc||'||'||g.de_paylod_xml AS de_paylod_xml,
FROM
DE g, DM h, GM i, OP j
WHERE
h.dm_nbr = g.dm_nbr(+) and
i.gm_nbr = h.gm_nbr(+) and
j.op_nbr = i.op_nbr(+)
+++++++++++++++++++++++++++++++++++++++++++++++++++++
I am using above SQL select statement for fetching the XML records and this gives me all related xmls for each entity in a single record(OP, GM, DM. DE). Output of this SQL query is as below:
Current O/P:
<resultSet>
<Record1>
<OP_PAYLOD_XML1>
<GM_PAYLOD_XML1>
<DM_PAYLOD_XML1>
<DE_PAYLOD_XML1>
</Record1>
<Record2>
<OP_PAYLOD_XML2>
<GM_PAYLOD_XML2>
<DM_PAYLOD_XML2>
<DE_PAYLOD_XML2>
</Record2>
<RecordN>
<OP_PAYLOD_XMLN>
<GM_PAYLOD_XMLN>
<DM_PAYLOD_XMLN>
<DE_PAYLOD_XMLN>
</RecordN>
</resultSet>
Now i want to change my SQL query so that i get following output structure:
<resultSet>
<Record>
<OP_PAYLOD_XML1>
<GM_PAYLOD_XML1>
<GM_PAYLOD_XML2> .......
<GM_PAYLOD_XMLN>
<DM_PAYLOD_XML1>
<DM_PAYLOD_XML2> .......
<DM_PAYLOD_XMLN>
<DE_PAYLOD_XML1>
<DE_PAYLOD_XML2> .......
<DE_PAYLOD_XMLN>
</Record>
<Record>
<OP_PAYLOD_XML2>
<GM_PAYLOD_XML1'>
<GM_PAYLOD_XML2'> .......
<GM_PAYLOD_XMLN'>
<DM_PAYLOD_XML1'>
<DM_PAYLOD_XML2'> .......
<DM_PAYLOD_XMLN'>
<DE_PAYLOD_XML1'>
<DE_PAYLOD_XML2'> .......
<DE_PAYLOD_XMLN'>
</Record>
<resultSet>
Appreciate your help in this regard!Hi,
A few questions :
How's your first query supposed to give you an XML output like you show ?
Is there something you're not telling us?
What's the content of, for example, <OP_PAYLOD_XML1> ?
I don't think it's a good idea to embed the node level in the tag name, it would make much sense to expose that as an attribute.
What's the db version BTW?
Maybe you are looking for
-
Hi, We are using timeout PJC functionality for our web forms. It's working fine and the form application display the alert/message whenever inactivity time reaches(which is set for 30 minutes). The issue is when you minimized the form application by
-
Message mapping execution?
Hi friends, The message processing(pipeline steps) happens in the abap stack,then how request message mapping(one of the pipeline step)happens in abap stack,as message mapping should execute in java stack, Thanks, Suresh.
-
Sql loader loading data from legacy to Oracle
Hi we have a requirement that we need to import data from legacy to oracle AR.We know that we need to put the data file in BIN folder,but I want to know about the data file source if we place in windows folder instead of BIN directory will SQL loader
-
Hello Experts, How to Create own Wizard Like MRP Wizard, Document Wizard Quick Reply will be helpful. Please Suggest
-
SCOM 2012 client movement between Management servers
Hi all, I know In SCOM 2012 sp1 all management servers are peers , if I have five management servers ( A, B, C, D,E ) and 2 gateway servers ( F, G ) . One client is assigned to A management server , in case if that management server down , to which m