Need sql query
Hi,
I need a query having the column name with comma...
For Ex.
select table_name from user_tables;
I need the output as
one,
two,
three,
etc...,
Kinldy provide me the query,...
Rgds...
Edited by: user537350 on May 28, 2009 10:20 PM
SQL> select abc||',' from wipro;
abc||','
abc,
abc,
abc,
abc,
Similar Messages
-
Need sql query to import from excel sheet
Hey , i need sql query to import from excel sheet.
i work in a company where i need to daily update the data from excel sheet.
if i get a shortcut method i ill be very thank full to you guys to reduce my work upto 10 %.any query which can inert from excel file?
Sort of. Certainly not anything as simple as what you seem to hope for. Check out this very good PHP class:
PHPExcel - Home -
Need Sql Query that Suppress the repeating rows.
Hi Sir,
I have below data set.
DeptID Sum(SAL) Avg(Sal)
10 1300 1300
10 2450 1300
10 5000 1300
20 800 800
20 1100 800
20 2975 800
20 3000 800
30 800 800
30 1100 800
30 2975 800
40 3000 800
40 4000 900
I Need SQL query that can remove the duplicate or suppress.Just like below data set.
Output:
DeptID Sum(SAL) Avg(Sal)
10 1300 1300
2450 1300
5000 1300
20 800 800
1100 800
2975 800
3000 800
800 800
30 1100 800
2975 800
40 3000 800
4000 900
Could you please help me on this..Your requiremnt is more of a reporting request which should not be handled in SQL. For example in SQL Plus you can use the BREAK command
SQL> break on deptno
SQL> select deptno, ename from emp order by deptno;
DEPTNO ENAME
10 KING
CLARK
20 JONES
SCOTT
SMITH
ADAMS
30 TURNER
MARTIN
WARD
ALLEN
BLAKE
11 rows selected.
SQL>
But if you still wish to do it in SQL you can use ROW_NUMBER analytic function and achieve it like this
select decode(rno, 1, deptno) deptno
, ename
from (
select row_number() over(partition by deptno order by ename) rno
, deptno
, ename
from emp -
Need sql query or pl/sql query urgent
Hi Experts,
The requirement is that
SELECT 'N' flag, sysdate init_date,
'' vendor_name,
DECODE (pa.address_type,
'P', 'Present Address',
'R', 'Permanent Address',
pa.address_type
) address_type,
pa.address_line1
|| ','
|| pa.address_line2
|| ','
|| pa.town_or_city
|| ','
|| meaning
|| ','
|| pa.POSTAL_CODE "Address",
TRUNC (TO_CHAR (pa.date_from, 'YYYY')) YEAR,
TO_CHAR (pa.date_from, 'MON') MONTH,''station
FROM per_addresses pa, fnd_lookup_values, per_all_people_f pf
WHERE (pf.employee_number = :1 or pf.APPLICANT_NUMBER = :2)
and pf.EFFECTIVE_END_DATE='31-DEC-4712'
AND pa.person_id = pf.person_id
AND pa.business_group_id = 42
--AND pa.date_to IS NULL
AND lookup_type = 'PER_US_COUNTRY_CODE'
AND lookup_code = pa.country
AND enabled_flag = 'Y'
AND (end_date_active IS NULL OR end_date_active > SYSDATE)
if i run the above query the output is coming like that
Present Address | Flat No. 1201, OC - 15, Orange County, Plot No. GH - 4,Ahinsa Khand 1st, Indrapuram,Ghaziabad,India,201010| 2,010| JUL
Permanent Address | Q.No. 354, Sector - 3 / B,,Bokaro Steel City,India,827003 |2,010 |JUL
Present Address | 4, Sitara,Chandra Reddy layout, S.T. Bed,Bangalore,India,0| 2,006| JAN
Present Address | 101,,Ushma Urja Apartments,Noida,India,201301 | 2,006 | JUL
Permanent Address | F-19, Maccon Colony, Opp. DAV Shyamali School,,Ranchi,India,834002 | 2,009 | FEB
Present Address | Flat no. 604, B - 1, Krishna Apra Gardens,Vaibhav Khand, Plot - 7,Ghaziabad,India,201010 | 2,009 FEB
But the requirement is the output should come like that
Permanent Address |Q.No. 354, Sector - 3 / B,,Bokaro Steel City,India,827003| 2,010 |JUL
Permanent Address 1| F-19, Maccon Colony, Opp. DAV Shyamali School,,Ranchi,India,834002| 2,009 | FEB
Present Address | Flat No. 1201, OC - 15, Orange County, Plot No. GH - 4,Ahinsa Khand 1st, Indrapuram,Ghaziabad,India,201010| 2,010 | JUL
Present Address 1 | Flat no. 604, B - 1, Krishna Apra Gardens,Vaibhav Khand, Plot - 7,Ghaziabad,India,201010| 2,009 | FEB
Present Address 2 | 101,,Ushma Urja Apartments,Noida,India,201301| 2,006| JUL
Present Address 3 | 4, Sitara,Chandra Reddy layout, S.T. Bed,Bangalore,India,0 | 2,006| JAN
Please provide logice how i need to write a sql query or procedure or function or package
Thanks & Regards
VenuYou can use analytics here :
SELECT
flag,
init_date,
vendor_name,
address_type ||' ' ||rn AS address_type,
Address,
YEAR,
MONTH,
station
FROM
SELECT
'N' flag,
sysdate init_date,
'' vendor_name,
DECODE (pa.address_type, 'P', 'Present Address', 'R','Permanent Address', pa.address_type ) address_type,
row_number() over(partition BY pa.address_type order by 1) AS rn,
pa.address_line1
|| ','
|| pa.address_line2
|| ','
|| pa.town_or_city
|| ','
|| meaning
|| ','
|| pa.POSTAL_CODE "Address",
TRUNC (TO_CHAR (pa.date_from, 'YYYY')) YEAR,
TO_CHAR (pa.date_from, 'MON') MONTH,
'' station
FROM
per_addresses pa,
fnd_lookup_values,
per_all_people_f pf
WHERE
pf.employee_number = :1
OR pf.APPLICANT_NUMBER = :2
AND pf.EFFECTIVE_END_DATE='31-DEC-4712'
AND pa.person_id = pf.person_id
AND pa.business_group_id = 42
--AND pa.date_to IS NULL
AND lookup_type = 'PER_US_COUNTRY_CODE'
AND lookup_code = pa.country
AND enabled_flag = 'Y'
AND
end_date_active IS NULL
OR end_date_active > SYSDATE
); -
HI
I want a sql query i.e., all employees list which are having lessthan maximum salary of manager in same departmnet;
my table is like this
employees
EMPLOYEE_ID NOT NULL NUMBER(6)
FIRST_NAME VARCHAR2(20)
LAST_NAME NOT NULL VARCHAR2(25)
EMAIL NOT NULL VARCHAR2(25)
PHONE_NUMBER VARCHAR2(20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2(10)
SALARY NUMBER(8,2)
COMMISSION_PCT NUMBER(2,2)
MANAGER_ID NUMBER(6)
DEPARTMENT_ID NUMBER(4)
if need the department table
departments:
DEPARTMENT_ID
NOT NULL NUMBER(4)
DEPARTMENT_NAME
NOT NULL VARCHAR2(30)
MANAGER_ID
NUMBER(6)
LOCATION_ID
NUMBER(4)Try this:
select
employees.last_name || ', ' || employees.first_name “Employee”,
employees.salary “Emp Salary”,
sub.salary “Mgr Salary”,
employees.department_id “Department”
from
employees,
( select
mgr.department_id dept,
max(mgr.salary) salary
from
employees,
employees mgr
where
employees.mgr = mgr.employee_id
group by
mgr.department_id) sub
where
employees.department_id = sub.dept
and employees.salary < sub.salary
Jeff -
Need sql query to remove duplicates using UNION ALL clause
Hi,
I have a sql query which has UNION clause.But the UNION clause is causing some performance issues.
To overcome that I have used UNION ALL to improve performance but its returning duplicates.
Kindly anyone send a sample SQL query where my primary objective is used to use UNION ALL clause and to consider unique rows (elimating duplicate
ones)
Any help will be needful for me
Thanks and Regardswhy not UNION? :(
another way also use MINUS
SQL>
SQL> with t as
2 (
3 select 1 if from dual union all
4 select 2 if from dual union all
5 select 1 if from dual union all
6 select 3 if from dual union all
7 select 3 if from dual
8 )
9 ,t2 as
10 (
11 select 1 if from dual union all
12 select 2 if from dual union all
13 select 3 if from dual union all
14 select 4 if from dual union all
15 select 5 if from dual
16 )
17 (select if from t
18 union all
19 select if from t2)
20 /
IF
1
2
1
3
3
1
2
3
4
5
10 rows selected
SQL> so
SQL>
SQL> with t as
2 (
3 select 1 if from dual union all
4 select 2 if from dual union all
5 select 1 if from dual union all
6 select 3 if from dual union all
7 select 3 if from dual
8 )
9 ,t2 as
10 (
11 select 1 if from dual union all
12 select 2 if from dual union all
13 select 3 if from dual union all
14 select 4 if from dual union all
15 select 5 if from dual
16 )
17 (select if from t
18 union all
19 select if from t2)
20 minus
21 select -99 from dual
22 /
IF
1
2
3
4
5
SQL> -
Need sql query to find out Joins attached with folders in Discoverer
Hi,
Can anyone let me know the sql query which can be used to identify the joins which are attached to the folders.
Actually we have to identify all the joins conditions from folders those are migrated from one instance to others.
Thanks
abhishekI recommend that you implement the admin EUL supplied by oracle, you can get there a lot of repository information (metalink note: 556932.1).
Try to use this (maybe you will need some pkg's):
SELECT
DECODE(KEYS.FK_MANDATORY,
1,
'Always exist in master folder',
'Might not exist in master folder') "Detail Item values",
EUL10G_US.EUL5_GET_JOIN(EXP.EXP_ID, 'N') "Join Master --> Detail",
KEYS.KEY_DESCRIPTION JOIN_DESCRIPTION,
KEYS.KEY_DEVELOPER_KEY JOIN_IDENTIFIER,
KEYS.KEY_NAME JOIN_NAME,
DECODE(SUBSTR(KEYS.KEY_NAME, 1, 19),
'AUTO_GENERATED_NAME',
'Yes',
'No') "AutoGen",
DECODE(DECODE(SUBSTR(KEYS.KEY_NAME, 1, 19),
'AUTO_GENERATED_NAME',
'Yes',
'No') ,
'Yes',
EUL10G_US.EUL5_GET_JOIN(EXP.EXP_ID),
KEYS.KEY_NAME) "Actual Join Name",
KEYS.KEY_UPDATED_DATE JOIN_LAST_UPDATE,
DECODE(KEYS.FK_ONE_TO_ONE, 1, 'One to one join', NULL) "One to One join",
DECODE(KEYS.FK_MSTR_NO_DETAIL,
1,
'Outer join on detail' || CHR(10),
NULL) "Outer Join on Detail",
DECODE(KEYS.FK_DTL_NO_MASTER,
1,
'Outer join on master' || CHR(10),
NULL) "Outer Join on Master",
DECODE(KEYS.FK_MSTR_NO_DETAIL,
1,
'Outer join on detail' || CHR(10),
NULL) || DECODE(KEYS.FK_DTL_NO_MASTER,
1,
'Outer join on master' || CHR(10),
NULL) ||
DECODE(KEYS.FK_ONE_TO_ONE, 1, 'One to one join', NULL) "Optional Join Configurations",
OBJ.OBJ_NAME "MASTER_FOLDER",
OBJ_DETAIL.OBJ_NAME "DETAIL_FOLDER"
FROM EUL10G_US.EUL5_OBJS OBJ,
EUL10G_US.EUL5_EXPRESSIONS EXP,
EUL10G_US.EUL5_KEY_CONS KEYS,
EUL10G_US.EUL5_OBJS OBJ_DETAIL
WHERE ((KEYS.KEY_ID = EXP.JP_KEY_ID) AND
(OBJ.OBJ_ID = KEYS.FK_OBJ_ID_REMOTE) AND
(OBJ_DETAIL.OBJ_ID = keys.KEY_OBJ_ID)); -
Need sql query to find out Joins attached with folders
Hi,
Can anyone let me know the sql query which can be used to identify the joins which are attached to the folders.
We dont want to see those from front end(disc admin).
Thanks
abhishekabhishek - This is the Application Express forum. I have no idea what you are asking but it may need to be directed to a different forum.
Scott -
Need sql query to find ten records in sequential manner
Plz help me
I need to have ten records on my page. at the bottom of the page, i want to dispaly the number of pages that have records , just as a google page shows at the bottom. if the moves user moves to the next page , the next ten records must be displayed. suppose the user selects and clicks 5th page then the records on that page are displayed.How can i write the sql query corresponding to this specificationi don't want all records to be fetched at the same time and put on the server, rather whenever the page is opened , the corresponding records are fetched and displayedHi
Maybe you should use a CachedRowSet.
Look this:
http://developer.java.sun.com/developer/technicalArticles/javaserverpages/cachedrowset/
This page has a example that will help you. -
Hi All,
i have input like
'JEFFRJON-Sales Manager-JEFFRJON'
'TBH01-JEFFRJON-Apps Agile Rep-JEFFRJON'
Need output only
Sales Manager
Apps Agile Rep
Please give me the sql query for this....anbarasan wrote:
Hi All,
i have input like
'JEFFRJON-Sales Manager-JEFFRJON'
'TBH01-JEFFRJON-Apps Agile Rep-JEFFRJON'
Need output only
Sales Manager
Apps Agile Rep
Please give me the sql query for this....You should really provide more info - like database version - so that people don't have to make assumptions when they try to help you. Based on limited requirements;
with t as (
select 'JEFFRJON-Sales Manager-JEFFRJON' str from dual union all
select 'TBH01-JEFFRJON-Apps Agile Rep-JEFFRJON' from dual)
select regexp_replace(str, '(.*JEFFRJON-)(.*)(-JEFFRJON.*)','\2') c
from t;
C
Sales Manager
Apps Agile Rep -
Need sql query for like operation.
Hi All,
i have table like name column and contain the data like
ibm 100
ibm 200
ibm 300
a2b
a
b
c
like this ....
but sql query need search using like or any regular expression---
select * from table where name like (ibm 200 and ibm 300).
and i don't want use like this select * from table where name like' ibm 200' or name like 'ibm 300').
can you please any body help to correct the above query...
Edited by: anbarasan on Oct 16, 2011 10:02 PMWITH t AS
(SELECT 'ibm 100' NAME
FROM DUAL
UNION ALL
SELECT 'ibm 200' NAME
FROM DUAL
UNION ALL
SELECT 'ibm 300' NAME
FROM DUAL
UNION ALL
SELECT 'a2b' NAME
FROM DUAL)
SELECT *from t where REGEXP_LIKE (name, 'ibm')
and REGEXP_LIKE (name, '100|200') -
Need SQl Query for Revenue Code and Revenue Amount in Receivables
Hi,
I need a SQL Query to develop data set for the following columns:
Revenue Code,Revenue Code Description,Invoice Amount,Revenue Amount,Original Invoice Number,Original Invoice Date.
Can i get from ra_cust_trx_line_gl_dist_all and ra_customer_trx_all and ra_customer_trx_lines_all by joining them.But for the columns whcih to take
i am in dilemma.
Kindly any help will be needful for meHi,
I need a SQL Query to develop data set for the following columns:
Revenue Code,Revenue Code Description,Invoice Amount,Revenue Amount,Original Invoice Number,Original Invoice Date.
Can i get from ra_cust_trx_line_gl_dist_all and ra_customer_trx_all and ra_customer_trx_lines_all by joining them.But for the columns whcih to take
i am in dilemma.
Kindly any help will be needful for me -
Need SQL query for PO that do NOT have 3-way match.
The question is -- have any PO"s been generated with other then 3-way match selected - which means they overrode the set-ups in purchasing , to see if there are an PO that do NOT have 3-way match.
Thanks
Mohan.1)Generally when ever we will do Supplier setup we will select in the Receiving tab Match approval level we will select either 3-way ,2-way,4-way or we will keep that as blank.
for that we do not have any direct column in the back end ,so we will use the following conditions.
'2WAY' inspection_required_flag = 'N'
receipt_required_flag = 'N'
'3WAY' inspection_required_flag = 'N'
receipt_required_flag = 'Y'
'4WAY' inspection_required_flag = 'Y'
receipt_required_flag = 'Y'
2)When ever we will create a PO in the shipments level what ever the Match approval level,
we defined in the supplier will automatically reflects in the shipments-More tab.
3)Here i wants to know all the PO's whihc are having Match approval level differences between supplier definiton and PO's match approval level.
(i.e If i will select a supplier for a PO , automatically we will get one Match approvallevel from supplier setup .if i will change that match approval level manually in the PO shipments -More tab i wants to know all that PO by using a SQL query.
4)But for some PO's i am getting receipt_required_flag and inspection_required_flag as null.But in the Supplier setup it may be one of the Matching approval.
Thanks
Mohan. -
Need SQL query to get the result.
Region
Month
Trx Type
Resolution Summary
AMERICAS
May-13
Adjustments
Correct
EMEA
May-13
Adjustments
Incorrect
AMERICAS
May-13
Credit Memo
Incorrect
EMEA
May-13
Invoice
Correct
AMERICAS
May-13
Credit Memo
Correct
OFD
May-13
Adjustments
Correct
AMERICAS
May-13
Invoice
Incorrect
LAD
May-13
Adjustments
Correct
LAD
May-13
Adjustments
Correct
OFD
May-13
Adjustments
Correct
Above is my Table and find below the required result.Similarly for other regions as well. Can anyone help me with the SQL Query?
Region
Resolution Summary
Adjustment
Credit Memo
Invoice
Grand Total
AMERICAS
Correct
1
1
2
Incorrect
0
1
1
2Like this?
SQL> select * from transaction_audit;
REGION MTH TRX_TYPE RESOLUTIO
AMERICAS may-13 ADJUSTMENTS CORRECT
EMEA may-13 ADJUSTMENTS INCORRECT
AMERICAS may-13 CREDIT MEMO INCORRECT
EMEA may-13 INVOICE CORRECT
AMERICAS may-13 CREDIT MEMO CORRECT
OFD may-13 ADJUSTMENTS CORRECT
AMERICAS may-13 INVOICE INCORRECT
LAD may-13 ADJUSTMENTS CORRECT
LAD may-13 ADJUSTMENTS CORRECT
OFD may-13 ADJUSTMENTS CORRECT
10 rows selected.
SQL> select region
2 , resolution_summary
3 , count(decode(trx_type, 'ADJUSTMENTS', trx_type)) adjustments
4 , count(decode(trx_type, 'CREDIT MEMO', trx_type)) credit_memo
5 , count(decode(trx_type, 'INVOICE' , trx_type)) invoice
6 from transaction_audit
7 group
8 by region
9 , resolution_summary
10 order
11 by region
12 , resolution_summary
13 /
REGION RESOLUTIO ADJUSTMENTS CREDIT_MEMO INVOICE
AMERICAS CORRECT 1 1 0
AMERICAS INCORRECT 0 1 1
EMEA CORRECT 0 0 1
EMEA INCORRECT 1 0 0
LAD CORRECT 2 0 0
OFD CORRECT 2 0 0
6 rows selected.
SQL> -
Need sql query to convert rows to columns
Im using oracle 11g.
I have data in a table as below: Column names are type,month,percentage
TYPE MONTH PERCENTAGE
A1 JAN-2013 100
A2 JAN-2013 100
A3 JAN-2013 95
A4 JAN-2013 98
A5 JAN-2013 99
A6 JAN-2013 90
A7 JAN-2013 92
A1 FEB-2013 100
A2 FEB-2013 99
A3 FEB-2013 88
A4 FEB-2013 67
A5 FEB-2013 98
A6 FEB-2013 95
A7 FEB-2013 84
The desired output using a sql query is as below
TYPE JAN-2013 FEB-2013
A1 100 100
A2 100 99
A3 95 88
A4 98 67
A5 99 98
A6 90 95
A7 92 84Try this:
select * from table_name
PIVOT( max(Percentage)
for MONTH
in ('JAN-2013','FEB-2013')
) ;with data
with t(TYPE,MONTH,PERCENTAGE) as
SELECT 'A1', 'JAN-2013', 100
FROM DUAL
UNION ALL
SELECT 'A2', 'JAN-2013', 100
FROM DUAL
UNION ALL
SELECT 'A3', 'JAN-2013', 95
FROM DUAL
UNION ALL
SELECT 'A4', 'JAN-2013', 98
FROM DUAL
UNION ALL
SELECT 'A1', 'FEB-2013', 100
FROM DUAL
UNION ALL
SELECT 'A2', 'FEB-2013', 99
FROM DUAL
UNION ALL
SELECT 'A3', 'FEB-2013', 88
FROM DUAL
UNION ALL
SELECT 'A4', 'FEB-2013', 67
FROM DUAL
select * from t PIVOT( max(Percentage)
for MONTH
in ('JAN-2013','FEB-2013')
) ; -
Need sql query to get OIM request pending approval details for one user
HI OIM Guru,
It would be great help if someone can provide me sql query by which i can find out how many requests are pending for approval for one user ?1. Below query will give you status of all the request.
SELECT REQ.REQUEST_ID , REQ.REQUEST_STATUS FROM REQUEST REQ
2. You can have following status
Obtaining Operation Approval
Obtaining Template Approval
Operation Approval Approved
Operation Approval Rejected
Post Operation Processing Initiated
Request Approval Rejected
Request Closed
Request Completed
Request Created
Request Failed
Request Withdrawn
Template Approval Rejected
3. Now prepare the query from above sapmle, the requset status string should not contains foloowing values.
Rejected
Failed
Closed
Withdrawn
Completed
The builded query will give you the desired result for 11g
for 10 G
Get the OST_STATUS from Req table, and do you logic above stated
-Kuldeep
Edited by: Kuldeep on May 22, 2012 1:04 AM
Maybe you are looking for
-
Bridge Scripting Capabilities (CS3 Javascript)
Hi -- We have many users at our company who need to edit metadata in images (primarily jpegs, but some tifs). These users do not have access to Photoshop but do have access to Bridge. I have written a script in Bridge that opens a dialog window for t
-
CEUPDATEMENAGER Hangs while upgrading from CE 7.11 to 7.20
Hi, I am updating our sandbox CE 7.11 SPS4 system to CE 7.20 SPS2. I have downloaded the CEUPDATEMANAGER file for CE 7.20 from service marketplace: CEUPDATEMANAGER01_0-20005861.SAR (for AIX). After extracting this file in kernel directory, I started
-
Word to PDF Conversion = Different Color on Paper
Hello All, I created a bunch of forms in Word 2010. Converted them into PDF and made them fillable. On screen Word doc and PDF doc colors look the same, but when I print PDF documents their blue turns intor dark purple. Any suggestions on how to keep
-
We have been trying to use the batch scheduler in HFM and have not yet had any luck on having the reports emailed out automatically. It looks like the reports in the batch are running ok but they aren't going to anyone in the specified distribution l
-
My purchases won't download fully
I bought an EP, and none of the tracks fully downloaded. I only got partial tracks for them. It cuts off anywhere from 30 seconds to the last minute of each song when I try to play them in iTunes, How do I fix this or get my money back?