Query to display the following output
Hello,
I am using Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production.
My table structure is
Loaneenumber varchar2(10),
Loaneename varchar2(50),
Loantype varchar2(30),
Balance_amount number(12,2),
Remarks varchar2(200)
Sample data
insert into test values ('01002S001', ' Srinivas K.' , ' Advance', ' 25000', '200708 Outstanding loans');
insert into test values ('01002S001', ' Srinivas K.' , ' Advance', ' 22500', '200607 Outstanding loans');
insert into test values ('01002S001', ' Srinivas K.' , ' Advance', ' 5000', 200506 Out Standing Loan For Advance);
I need to display output as follows
Loaneenumber Loaneename Loantype Inputs0708 Inputs0607 Inputs0506
01002S001 Srinivas K. Advance 25,000 22,500 5,000
Years 200708, 200607 are in remarks column. Can I use like operator in decode function?
For one year data I have written the following query
SELECT loaneenumber,
loaneename,
loantype,
balance_amount as "Inputs0708"
FROM cmsloanissuetransaction
WHERE balance_amount >0
AND loantype NOT IN ( 'Bank Loan' ,
'LOANS 2001-02',
'LOANS 2002-03',
'LOANS 2003-04',
'LOANS 2004-05')
AND loancategory ='RYOT'
AND (remarks NOT LIKE '200506%' AND remarks NOT LIKE '200607%')
How to display three years data side by side?
Regards
Krishna
Edited by: KRKP on Sep 17, 2008 9:08 PM
Try this..
SELECT loaneenumber,
loaneename,
loantype,
(case
when remarks LIKE '200708%' then balance_amount) as "Inputs0708" ,
(case
when remarks LIKE '200607%' then balance_amount) as "Inputs0607" ,
(case
when remarks LIKE '200506%' then balance_amount) as "Inputs0506" ,
FROM cmsloanissuetransaction
WHERE balance_amount >0
AND loancategory ='RYOT'
Similar Messages
-
hi friends,
Here is my query on a Alv Report output display
I have two internal tables i_vbak and i_vbap
i_vbak contains the fields and value as
vbeln kunnr auart audat bstnk vkorg
1000066 1000071 ze0r 20070918 Itest1 PA11
1000067 1000072 ze0r 20070919 SLA-Test1 PA11
i_vbap contains the field and value as
VBELN MATNR ARKTX
1000066 SAMPLE MATERIAL1 Sample Material for reports
1000066 SAMPLE MATERIAL Sample Material for reports
1000066 TEST MATERIAL Test Material for reports
1000067 SAMPLE MATERIAL Sample Material for reports
1000067 TEST MATERIAL Test Material for reports
1000067 SAMPLE MATERIAL1 Sample Material for reports
I have a another internal table called inv_final which contain all these fields and respective values to display in the alv output.Here i am giving only two field how it whould come in alv output.
Sold to Patry(kunnr) Sales Doc No(vbap-vbeln) Material Name(matnr)
1000071 1000066 Sample Material1
1000071 1000066 Sample Material
1000071 1000066 Test Material
1000072 1000067 Sample Material
1000072 1000067 Test Material
1000072 1000067 Sample Material1
If anybody have done similay kind of repore than help me with the code,or else if anybody having any idea to solve this out than help me.I have only prob with the logic bofore the final table display in the alv output.
Helpful answer will be rewardad generously.
Thanks a lot
mrutyun^Hi
Put all the fields in to an internal table and disply only your required fields.
Kuntal -
How to modify this query to get the desired output format
I hv written a Query to display all the parent table names and their primary key columns(relevant to this foreign key of the child table).The query is given below...
SELECT DISTINCT(TABLE_NAME) AS PARENT_TABLE,COLUMN_NAME AS PARENT_COLUMN
FROM ALL_CONS_COLUMNS
WHERE CONSTRAINT_NAME IN (SELECT AC.R_CONSTRAINT_NAME
FROM ALL_CONSTRAINTS AC
WHERE AC.TABLE_NAME=TABLE_NAME
AND AC.TABLE_NAME='&TABLE'
AND AC.R_CONSTRAINT_NAME IS NOT NULL);
This query will display all the parent tables and their primary key columns.Now my problem is that how to modify this query to also display the foreign key column name of the child table.
I want the query result in the following format.The query should display the following columns.1)child table's name,2)child table's foreign key column name,3)the corresponding parent table's name,4)the parent table's primary key column name(which is the foreign key in the child table).
For Example I want the output as follows...
TAKE THE CASE OF SCOTT.EMP(AS INPUT TO YOUR QUERY)
CHILD_TABLE CHILD_COLUMN PARENT_TABLE PARENT_COLUMN
EMP DEPTNO DEPT DEPTNO
In this result I hv used alias name for the columns.The query should display this only for the foreign keys in the child table.In the query which I sent to you earlier will give the parent table and the parent column names,But I also want to append the child table and child column names there.
any help on how to tackle would be appreciated.Try this query
SELECT c.table_name child_table,
c.column_name child_column,
p.table_name parent_table,
p.column_name parent_column
FROM user_constraints a,user_constraints b,user_cons_columns c,
user_cons_columns p
WHERE a.r_constraint_name=b.constraint_name and
a.constraint_name=c.constraint_name and
b.constraint_name=p.constraint_name and
c.position=p.position
ORDER BY c.constraint_name,c.position
Anwar -
Very Important (Query to display the output in required format)
CREATE TABLE TEMP(X VARCHAR2(10),Y VARCHAR2(100));
INSERT INTO TEMP('RIDER1','2001-12;2002-32;2003-42');
INSERT INTO TEMP('RIDER2','2001-52;2003-72');
SELECT * FROM TEMP
Initial Out Put in 2 columns X/Y_
X Y
RIDER1 2001-12;2002-32;2003-42
RIDER2 2001-52;2003-72
Write a Query to display the above data in the format below in 3 columns A/B/C*
A B C
Rider1 2001 12
Rider1 2002 32
Rider1 2003 42
Rider2 2001 52
Rider2 2003 72So your old version doesn't support Regular expression. It will be very easy and efficient if you could use regular expression.
SQL> SELECT x,TRIM(REGEXP_SUBSTR(col2,'[^-]+', 1, 1)) col2,
2 TRIM(REGEXP_SUBSTR(col2,'[^-]+', 1, 2)) col3
3 FROM (
4 SELECT DISTINCT x,regexp_substr (y, '[^;]+', 1, level) col2
5 FROM temp
6 CONNECT BY LEVEL <= LENGTH (REGEXP_REPLACE (y, '[^;]+')) + 1
7 ORDER BY 1,2
8 );
X COL2
COL3
RIDER1 2001
12
RIDER1 2002
32
RIDER1 2003
42
X COL2
COL3
RIDER2 2001
52
RIDER2 2003
72But for your version you can use something like
SQL> /* By curtesy Frank Kulash */
SQL> SELECT x,SUBSTR(the_value,1,INSTR(the_value,'-',1)-1) col2,
2 SUBSTR(the_value,INSTR(the_value,'-',1)+1)col3
3 FROM (
4 SELECT DISTINCT x,SUBSTR(y,
5 DECODE(level,
6 1,
7 1,
8 INSTR(y, ';', 1, level - 1) + 1),
9 DECODE(INSTR(y, ';', 1, level),
10 0,
11 length(y),
12 instr(y, ';', 1, level) -
13 DECODE(level,
14 1,
15 0,
16 INSTR(y, ';', 1, level - 1)) - 1)) the_value
17 FROM temp
18 CONNECT BY level <=
19 LENGTH(y) - LENGTH(REPLACE(y, ';')) + 1
20 )
21 ORDER BY 1,2,3
22 ;
X COL2
COL3
RIDER1 2001
12
RIDER1 2002
32
RIDER1 2003
42
X COL2
COL3
RIDER2 2001
52
RIDER2 2003
72
SQL> -
To write a single query to get the desired output.
Hi,
I have table by name "employees" it contains 20 records meaning 20 employee details.
some of the column it contains are employee_id,Hiredate as below.
EMPLOYEE_ID|HIRE_DATE
100|6/17/1987
101|9/21/1989
102|1/13/1993
103|1/3/1993
104|5/21/1991
107|2/7/1999
124|11/16/1999
141|10/17/1995
142|1/29/1997
143|3/15/1998
144|7/9/1998
149|1/29/2000
174|5/11/1996
176|3/24/1998
178|5/24/1999
200|9/17/1987
201|2/17/1996
202|8/17/1997
205|6/7/1994
206|6/7/1994
The query should display the total number of employees, employees hired in 1995,1996,1997 and 1998 some thing like below.
output
Total 1995 1996 1997 1998
20 1 2 2 3
please let me know the query.
Thanks
DineshSQL> select * from employees;
EMPLOYEE_ID HIRE_DATE
100 17-JUN-1987 00:00:00
101 21-SEP-1989 00:00:00
102 13-JAN-1993 00:00:00
103 03-JAN-1993 00:00:00
104 21-MAY-1991 00:00:00
107 07-FEB-1999 00:00:00
124 16-NOV-1999 00:00:00
141 17-OCT-1995 00:00:00
142 29-JAN-1997 00:00:00
143 15-MAR-1998 00:00:00
144 09-JUL-1998 00:00:00
149 29-JAN-2000 00:00:00
174 11-MAY-1996 00:00:00
176 24-MAR-1998 00:00:00
178 24-MAY-1999 00:00:00
200 17-SEP-1987 00:00:00
201 17-FEB-1996 00:00:00
202 17-AUG-1997 00:00:00
205 07-JUN-1994 00:00:00
206 07-JUN-1994 00:00:00
20 rows selected.
SQL> select count(*) total_employees
2 ,sum(case when to_char(hire_date,'YYYY') = '1995' then 1 else 0 end) hired_1995
3 ,sum(case when to_char(hire_date,'YYYY') = '1996' then 1 else 0 end) hired_1996
4 ,sum(case when to_char(hire_date,'YYYY') = '1997' then 1 else 0 end) hired_1997
5 ,sum(case when to_char(hire_date,'YYYY') = '1998' then 1 else 0 end) hired_1998
6 from employees;
TOTAL_EMPLOYEES HIRED_1995 HIRED_1996 HIRED_1997 HIRED_1998
20 1 2 2 3Edited by: SomeoneElse on Jan 6, 2009 8:09 AM -
How to display the Form output in multiple languages ? ------ Urgent
How to display the Form output in multiple languages ? -
UrgentHi,
Do u mean the Form output in 2-3 languages ...like form output will be having english russian etc...
for the above case , what u have to do ...
first have to get the transalations for all the fields
say for example : if the english word is PO Number , then u have to get the transalation text for PO Number :
after this , what u have to is ,,, Log on to SAP with russian language , then in the form o/p u have to paste that russian test ( translation text ) ...
do like this for all the components in the form .
Reward Points if it is Useful.
Thanks,
Manjunath MS -
How do i get it to display the following?
so i want to basically type any numbers from 0-99 and have it display the following:
ex: 32.
Tens = 3
Ones = 2.import java.util.Scanner;
public class Integer
public static void main(String[] args)
Scanner kb = new Scanner(System.in);
System.out.println("Input number: ");
int number = kb.nextInt();
int ten = number / 10;
number = number % 10;
System.out.println("Ten : " + ten);
System.out.println("One : " + number);
Edited by: NewInJava on Feb 8, 2009 6:06 PM -
Hello!
The new version of Firefox I have a problem with opening the site VKontakte. The browser displays the following error: "Firefox has determined that the server redirects the request for this address in a way that it will never end." How to solve this problem? Please excuse me for my English.
Sincerely, Vsevolod.You're welcome
-
Designing a query and displaying the query output
The goal is to create a report (in HTML form) of all the jobs
(and job-related information) for a given department.
I envision the department name as a hyperlink to a report
based on the unique DepartmentID.
For example, the “Sales” department might contain
these jobs:
VP of Sales
Associate Salesperson
Sales Assistant
Each job requires a set of skills and a specific skill level.
“Persuasion skill” could vary as follows:
VP of Sales: ADVANCED persuasion skill
Associate Salesperson: MODERATE persuasion skill
Sales Assistant: BASIC persuasion skill
“Communication skill” could vary as follows:
VP of Sales: EXPERT communication skill
Associate Salesperson: ADVANCED communication skill
Sales Assistant: NOT REQUIRED
And so on…
Each job has roughly 20 skills that are related to it.
I’d like to display this information in a table with
the skills listed in rows, the job titles listed in column
headings, and the skill level (e.g., ADVANCED) located in the
appropriate cell where the skill and job title intersect. That way,
the reader can easily compare skill levels across jobs.
The requisite tables are below. (A field name preceded by
“frn_” is the foreign key related to another
table’s primary key.)
Table: Departments
Fields: DepartmentID, DepartmentName
Table: Jobs
Fields: JobID, JobTitle, frn_DepartmentID
Table: Skills
Fields: SkillID, SkillName
Table: Skill_Levels
Fields: Skill_LevelID, Skill_Level_Description
Table: JobSkills (this table “links” a job,
skill, and skill level)
Fields: JobSkillID, frn_JobID, frn_SkillID, frn_Skill_LevelID
I'm not sure how to do this, so thank you for any help!
LukeYou're correct; I want to display the data as you described,
with one slight change.
Instead of the words "expert" or "basic," the proficiency
ratings should be displayed as numbers, e.g., "1" for "basic, "3"
for moderate, and "5" for expert. (Table: KSAProfRatings contains
fields for both, i.e, Field: PRStatement for "basic", "moderate",
"expert" etc. and Field: PRRating for "1", "2", "3", etc. I want to
use Field: PRRating)
Table: KSAs contains Field: KSAStatement, which contains the
skills. In addition to skills, Field: KSAStatement also contains
knowledges and abilities.
So, in addition to the skills that I mentioned above, there
might be a knowledge, such as "Knowledge of company products &
services," and an ability, such as "Ability to communicate
effectively." These knowledges and abilities receive a proficiency
rating just like the skills.
There is conceptual overlap among knowledges, skills, and
abilities (KSAs), so I had referred only to "skills" for clarity.
The query that I posted reflects the actual table names,
e.g., Table: KSAs instead of Table: Skills, and Table:
KSAProfRatings instead of Table: Skill_Levels (see my first post),
but the principle is the same. -
Need a Query for the following Output
I have a table name Table1. some of the data are like the following
EmpCode ProductCode Quantity
20006 IMPLSA 5
20006 LACJDT 10
20006 LIVLSU 15
20006 PEPPSU 11
20006 SAFMTA 12
20006 SUCFTA 17
21475 IMPLSA 2
21475 LACJDT 7
21475 LIVLSU 4
21475 PEPPSU 8
21475 SUCFTA 12
20409 IMPLSA 11
20409 LACJDT 13
20409 LIVLSU 9
20409 SAFMTA 7
20409 SUCFTA 5
21112 IMPLSA 2
21112 LIVLSU 18
21112 PEPPSU 20
21112 SAFMTA 22
21112 SUCFTA 15
Here no of EmpCode and ProductCode are not fixed.
And i need the output like this
ProductCode 20006 21475 20409 21112
IMPLSA 5 2 11
2
LACJDT 10 7 13 0
LIVLSU 15 4 9 18
PEPPSU 11 8 0 20
SAFMTA 12 0 7 22
SUCFTA 17 12 5 15
I know that it may be solved by dynamic pivot. but i never write any dynamic pivot query.
So Please Help me.DECLARE @EmpList varchar(max),@SQL varchar(max)
SELECT @EmpList = STUFF((SELECT DISTINCT ',[' + CAST(EmpCode AS varchar(15)) + ']'
FROM Table1
ORDER BY ',[' + CAST(EmpCode AS varchar(15)) + ']'
FOR XML PATH('')),1,1,'')
SET @SQL='SELECT ProductCode,' + @EmpList +
' FROM table1 t
PIVOT(SUM(Quantity) FOR EmpCode IN (' + @EmpList + '))p'
EXEC (@SQL)
Please Mark This As Answer if it solved your issue
Please Mark This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page -
Query to display the exact match product at top or increase the nearness
Hello All,
I am using the iStore search and it is returning results for Part Number and Description search. If I am searching a particular Part Number , it is displaying the particular product and its related products. I need the exact matched product in the first row (topmost).
When I checked the back-end query, It is using contains for powerful search.
How can I display the exact match product at top or increase the nearness in search.
Please help.
I have seen a similar thread in the forum.
Contains: exactly match
Thanks in advance,
Muhammed Aslam
Edited by: tpmuhammedaslam on Jan 10, 2013 3:48 AMHello Muhammed Aslam,
If fuzzy search is enabled, then cannot search by part number.
The seeded query for iStore product search is based on the description as follows:
Product Search (Section Search - R12)
select * from
(select T.*, RowNum as row_num
from (select inv_item_id INVENTORY_ITEM_ID
,description DESCRIPTION
,0 CATEGORY_ID
,nearness NEARNESS
,concatenated_segments CONCATENATED_SEGMENTS
,primary_uom_code PRIMARY_UOM_CODE
,primary_unit_of_measure PRIMARY_UNIT_OF_MEASURE
from (SELECT * FROM (select /*+ FIRST_ROWS leading(i) INDEX (x,IBE_SECTION_SEARCH_U1) */
distinct i.inventory_item_id, i.description, 0
,x.inventory_item_id inv_item_id, score(100) nearness
,mtl_system_items_b_kfv.concatenated_segments,
mtl_system_items_b_kfv.primary_uom_code,
mtl_system_items_b_kfv.primary_unit_of_measure
from ibe_ct_imedia_search i,ibe_section_search x
,mtl_system_items_b_kfv
where contains (i.indexed_search, :1 , 100) > 0
and i.language = userenv('LANG')
and i.organization_id = :2
and i.web_status='PUBLISHED'
and x.inventory_item_id = i.inventory_item_id
and i.inventory_item_id = mtl_system_items_b_kfv.inventory_item_id
and i.organization_id = mtl_system_items_b_kfv.organization_id
and x.minisite_id = :4
and x.organization_id =:5
order by nearness desc ) WHERE rownum < :6
))T
where rownum where row_num >= :8
Product Search (Category Search - R12)
select * from
(select T.*, RowNum as row_num
from (select inventory_item_id INVENTORY_ITEM_ID
,description DESCRIPTION
,category_id CATEGORY_ID
,nearness NEARNESS
,concatenated_segments CONCATENATED_SEGMENTS
,primary_uom_code PRIMARY_UOM_CODE
,primary_unit_of_measure PRIMARY_UNIT_OF_MEASURE
from (select i.inventory_item_id, i.description, i.category_id
,score(100) nearness
,mtl_system_items_b_kfv.concatenated_segments
,mtl_system_items_b_kfv.primary_uom_code
,mtl_system_items_b_kfv.primary_unit_of_measure
from ibe_ct_imedia_search i,
mtl_system_items_b_kfv
where contains (i.indexed_search, :1 , 100) > 0
and i.language = userenv('LANG')
and i.web_status='PUBLISHED'
and i.organization_id = :3
and exists (select 1
from ibe_dsp_section_items s,ibe_dsp_msite_sct_items b
where s.section_item_id = b.section_item_id
and b.mini_site_id = :4
and s.inventory_item_id = i.inventory_item_id
and (s.end_date_active > sysdate or s.end_date_active is null)
and s.start_date_active < sysdate)
and rownum < :5
and i.inventory_item_id = mtl_system_items_b_kfv.inventory_item_id
and i.organization_id = mtl_system_items_b_kfv.organization_id
order by nearness desc ))T
where rownum where row_num >= :7
Regards,
Debbie -
Displaying the report output in excel format
Please help me in getting the report output in excel format.
thnksI ran into a BIG problem after passing from 6i rep server to 9i rep server.
On 6i rep server I used to set DESFORMAT='DELIMITED', and that produced reasonable tab-delimited output for reports that did not have group above (all the query groups were from left to right, not a single group having fields displayed above some other group). When deployed on rep server 9i, the same reports produced some unexplainable output: some of the rows were duplicated, but I couldn't figure out any rule.
So, the best thing to get the reports into something that fits in .xls would be to have the output in .xml, that may be imported in Excel. -
How to display the ALV output in a Group format
Hello Experts,
I have my current ALV report output like this:
GROUP DESCRIPTION
group1 adsfadsfadsfa
group1 lkjadsfjlajdsfla
group1 adsfadsfadsf
group1 adsfadsfadfa
group2 adsfadsfafaa
group2 oiueworuowe
group2 zxvzcxvzvcsd
group2 oiuqoewruqw
And I need to display the output of my ALV report in a group format like this:
GROUP DESCRIPTION
group1 adsfadsfadsfa
lkjadsfjlajdsfla
adsfadsfadsf
adsfadsfadfa
group2 adsfadsfafaa
oiueworuowe
zxvzcxvzvcsd
oiuqoewruqw
Can anybody please let me know if there is any sample program/thread/help etc.
I grealty appreciate your help.
Thanks.Hi Rainer,
Thanks for the reply. I am using container for the ALV Display.
So I wrote my code lie this:
sort t_data by zgroup zdesc ( t_data is my output internal table) .
I have my ALV layout delcared like this:
data: alv_layout type lvc_s_layo.
So I have modified my code like this:
alv_layout-NO_MERGING = 'X'.
But it did'nt work. Please let me know if I need make any other changes.
Thanks again. -
How to display the JSP output in the same page....
im new to JSP..... can anyone tell me how to display the output of a particular JSP page in the same page itself...... if anyone could send a small sample code it will be very useful for me....
thanks in advance
regds
Krish......Hi Robert -
When you say you are writing a template-based Renderer, do you mean that you are creating a custom look and feel and replacing the header Renderer? If so, I'd recommend instead simply creating your own template (not template-based Renderer), and reference your template directly from your uiXML pages where you want to insert the timestamp.
You'll probably want to write a method data provider which calls System.currentTime(), convert the result to a date, and then use Java's date formatting capabilities (see java.text.format.DateFormat) to produce a user presentable String that you can return from your data provider.
For more info (and samples) on templates and data binding, see the "Templates and Data Binding" section of the "Includes and Templating in ADF UIX" help topic:
http://tinyurl.com/5b7bf
Andy -
Query to get the following criteria
Hi all
I've the following tables
rec ,pay ,cact ,isumand the relation between them is
isum.invid=rec.INVID_ARREC
isum.invid=pay.invid_arpay
cact.arpayid_cb=pay.arpayid
cact.arrecid_cb=rec.arrecidi need to get the o/p of BAL , SUM(TAMT) , SUM(VAL)
which will have the same amounts.
How can i get that
i tried the following but getting the duplicate records
plz help me in completing this query
SELECT bal, tamt, val
FROM rec ,
isum ,
(SELECT SUM (tamt) tamt
FROM rec, cact, isum i
WHERE
i.invid = invid_arrec
AND arrecid_cb = arrecid
GROUP BY invid_arrec),
(SELECT SUM (val) val
FROM pay, isum i
WHERE i.invid = invid_arpay
GROUP BY invid_arpay)
WHERE invid = invid_arrecplz let me know if more info is required
plz help..
Edited by: smile on Oct 22, 2010 1:38 AM
Edited by: smile on Oct 22, 2010 1:39 AMwe don't have your tables, we don't have your data, we don't have your database.
you want help, you provide all that is necessary to help you.
CREATE TABLE; INSERT INTO...
from what I can tell now, just join the tables and use the SUM function...
Maybe you are looking for
-
Adobe form data not being retrieved by Web Dynpro application
Hi, I have created an online interactive Adobe form embedded in a Web Dynpro ABAP application. The Web Dynpro application calls a function module to update data in SAP. My problem is that the ABAP code that was generated to retrieve the data from t
-
I was using my iphone 4s while plugged into the wall andi noticed the battery was decreasing. How is this possible if its plugged in?
-
To compare Table in different Database
Hi Is possible to compare tables in Different Database ? They are same tables , but data can to be different TIA
-
I'm trying to connect to MS SQL Server version 7. I've created an ODBC datasource and in JDeveloper I can create a database connection using the Sun JDBC-ODBC bridge that'll show all the tables and their contents. I've created an EntityObject for one
-
Are there any free apps that will open a WORD document on the iMac? Thanks!