Little help from the query
small request I have given as below,Month ProductNo CustomerNo units
9001 1001 Jan - 09 100
9002 1002 Jan - 09 200
9003 1003 Jan - 09 300
Jan 9001 400 ABCCustomer
9002 1004 Jan - 09 500
for all record - if column - customerNo starts with digital it must show as CN_ * other wise of the same name.
Result must be
9001 100 CN_1001-09 Jan
9002 200 CN_1002-09 Jan
9003 300 CN_1003-09 Jan
Jan 9001 400 ABCCustomer
9002 500 CN_1004-09 Jan
Can help get the query
A logic that is easier to implement this is as below
SQL> with t as (select 'jan' Month, 9001 ProductNo,'1001-09' CustomerNo,100 Units from dual union all
2 select 'jan', 9002, '1002-09', 200 from dual union all
3 select 'jan', 9003, '1003-09', 300 from dual union all
4 select 'jan', 9001, 'ABCCustomer', 400 from dual union all
5 select 'Jan', 9002, '1004-09', 500 from dual)
6 select month,productno,case when upper(substr(customerno,1,1))=lower(substr(customerno,1,1))
7 then 'CN_'||customerno else customerno end customerno,units from t;
MON PRODUCTNO CUSTOMERNO UNITS
--- ---------- -------------- ----------
jan 9001 CN_1001-09 100
jan 9002 CN_1002-09 200
jan 9003 CN_1003-09 300
jan 9001 ABCCustomer 400
Jan 9002 CN_1004-09 500
TRY WITH THIS upper (substr(customerno,1,1)) = lower (substr(customerno,1,1))
Tags: Database
Similar Questions
-
Could use a little help from the system recovery
My son has a HP DV something 21XX Entertainment laptop computer running XP. He had some serious spyware that I couldn't get cleaned up and I "discovered" restoration of the system using the F10 key. I did it. He acted as a whole new computer I have registry and all. I had assumed that he had whipped the own HD. However when I tried to update XP it said I didn't have the room. And of course a 'C' drive it's full of things. So now I'm a bit lost and I was wondering if there is a guide step by step somewhere (yes I should have asked prior to taking title).
1. I see as well a C drive and a system recovery disk. Who now works or how can I say.
2. I'd like to if I don't lose any of his stuff. Actually I'm passing some of them to my external drive for 'safe keeping' if all goes well
3. I have not been able to get on the net wireless, but have been wired. That is probably an update is necessary? It shows my network and that I am connected, but it won't actually show anything "page not found".
4. I download some spyware now so I can check my system restore it cleared out.
For any help or suggestion or pointing me in the right direction would be appreciated.
BTW, my son computer is a few years old and was one of the models who had the bad mother and HP the extended warranty on. They did replace the MB warranty (about 16 months after purchase). It's quality service and I have so I have several brands of laptops, I'm not yet ready to upgrade sound, if I do not.
Thanks again!
Sdallnct wrote:
My son has a HP DV something 21XX Entertainment laptop computer running XP. He had some serious spyware that I couldn't get cleaned up and I "discovered" restoration of the system using the F10 key. I did it. He acted as a whole new computer I have registry and all. I had assumed that he had whipped the own HD. However when I tried to update XP it said I didn't have the room. And of course a 'C' drive it's full of things. So now I'm a bit lost and I was wondering if there is a guide step by step somewhere (yes I should have asked prior to taking title).
1. I see as well a C drive and a system recovery disk. Who now works or how can I say.
2. I'd like to if I don't lose any of his stuff. Actually I'm passing some of them to my external drive for 'safe keeping' if all goes well
3. I have not been able to get on the net wireless, but have been wired. That is probably an update is necessary? It shows my network and that I am connected, but it won't actually show anything "page not found".
4. I download some spyware now so I can check my system restore it cleared out.
For any help or suggestion or pointing me in the right direction would be appreciated.
BTW, my son computer is a few years old and was one of the models who had the bad mother and HP the extended warranty on. They did replace the MB warranty (about 16 months after purchase). It's quality service and I have so I have several brands of laptops, I'm not yet ready to upgrade sound, if I do not.
Thanks again!
Hello
Here is a link to the system recovery with much information.
Your operating system runs from your C: partition. D: is the recovery partition.
As far your Wi - Fi connection... going to try Google chrome or another browser to see if you can connect. There is a little bug in IE (I guess that's what you use) which may prevent it from connect to web pages.
You have probably a Trojan or malware on the system. Try to go to www.ESET.com . Look on the right side under quick links and use their scanner online. It will find all things 'wrong' that is on your system and delete, if you may of course. As far as I know, they are the best in the business. Everyone has a favorite and this one is mine. I have install on the PC of the client frequently and for three years have never had a client complain about viruses, Trojans, adware or malware.
Do not update your pc had SP2 before having to operate satisfactorily and have done a Windows system restore point.
post your results (positive or negative) here in your thread so we know how it works for you.
Kind regards
ERICO
-
need help with the query, thx
Hello
I need a little help with the query I have to write;
the table has 4 columns:
what I am asking is the following result: salary according to the latest available yearcol1 col2 col3 col4 emp_name empl_id salary year content of data: col1 col2 col3 col4 smith 12 1200 1999 smith 12 1340 2000 smith 12 1500 2001 jones 13 1550 1999 jones 13 1600 2000 aron 14 1200 2002
i.e.
ID appreciate some guidance on how to achievesmith 12 1500 2001 jones 13 1600 2000 aron 14 1200 2002
Thank you
Rgdsselect *from (select col1, col2,col3, col4,row_number() over(partition by col1 order by col4 desc) rn from
) where rn=1 -
Help with the query to select only one record from the result set in double
Hello
Please help with the query. Version of Oracle database we use is 10g R2.
I have a vision that is duplicated IDS, but they are used across the different functions. See below examples of data. Please help me with a query to select only one record (based on ID regardless of the area) from the bottom of the result set of duplicate records. For what is the point of view is there unique records, given the combination of the fields ID, Org, DF, dry, Sub-Sec
ID Org DF Sec Sub-Sec (163) CQ CPDM CPDM HD (163) PC ENG ENG ENG (163) CQ ASIC ASIC IS 8888 TS TAC TAC TAC (163) TS HE HE SW 6789 CQ INFO INFO FOS 6789 PC SECSYS SECSYS INFO1 6789 TS SECSYS SECSYS INFO2 9009 PC BMS BMS BMS1 My result set must eliminate the duplicate identifiers regardless of whoever we choose of the result set. (I mean without distinction Org, DF, s, Sub-s). My expected result set should be.
ID DSB DF SEC Sub-Sec (163) CQ CPDM CPDM HD 8888 TS TAC TAC TAC 6789 CQ INFO INFO FOS 9009 PC BMS BMS BMS1 Thank you
Orton
Hello
This sounds like a job for ROW_NUMBER:
WITH got_r_num AS
(
SELECT id, DSB, df, s, sub_sec org
ROW_NUMBER () OVER (PARTITION BY ID.
ORDER BY org
) AS r_num
OF view_x
)
SELECT id, DSB, df, sub_sec s,
OF got_r_num
WHERE r_num = 1
;
He is a Top - N query example, where you choose the elements of N (N = 1 in this case) from the top of an ordered list.
I hope that answers your question.
If not, post a small example of data (CREATE TABLE and INSERT, only relevant columns instructions) to your sample data and the results desired from these data. (I know that you said that you were a view selection. Just for this thread, pretending it is a picture and post simple CREATE TABLE and INSERT statements to simulate your point of view).
Point where the above query is to produce erroneous results, and explain, using specific examples, how you get the right results from data provided in these places. (I didn't quite understand the explanation above. I don't know why you want toID ORG DF DRY SUB_SEC
-- --- -- --- -------
1234 CQ DPRK DPRK HD
and is not
1234 IS CQ ASIC, ASIC
or
TS 1234 IT IT SW
or
1234 CQ ASIC ASIC HD
)
If you change the query at all, post your modified version.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).See the FAQ forum: https://forums.oracle.com/message/9362002
-
How to remove the newline from the query output?
Hello
How to remove the newline from the query output?
have tried to replace select (column_name, Chr (10), ' ') from table_name.
Published by: GreenHorn 11 Sep, 2008 12:53 AMPlease consider, that windows uses a sequence of chr13 | Chr (10) Unix uses only a single character CHR (10).
The new line characters may depend on the operating system.You might consider with:
Replace (replace (column_name, Chr (13) |)) CHR (10), ' '), CHR (10),' ')
Hartmut
Published by: hartmutm on 11.09.2008 01:32
-
Need help with the query. Help, please
Hey everyone, need your help. Thank you in advance. In my view, there is function Pivot. Just do not know how to use this function. I have the query that works. The result is:
11-111-1111 Vlad 16505 01/04/2013 5 August 13 dental plan pre-tax amount 29,65
11-111-1111 Vlad 16505 01/04/2013 dental pre-tax 5 August 13 Plan level EE + SP
11-111-1111 16505 Vlad 01/04/2013 5 August 13 pre-tax Option TOP dental plan
11-111-1111 Vlad 16505 01/04/2013 5 August 13 pre-tax dental care plan pay the value
11-111-1111 16505 Vlad 01/04/2013 dental pre-tax 5 August 13 Plan period Type
11-111-1111 Vlad 16505 01/04/2013 amount pre-tax medical Plan of 5 August 13 149
11-111-1111 Vlad 16505 01/04/2013 5 August 13 pre-tax Medical Plan level EE + SP
11-111-1111 Vlad 16505 01/04/2013 5 August 13 pre-tax Plan medical Option MED
11-111-1111 Vlad 16505 01/04/2013 5 August 13 plan pre-tax pay value
11-111-1111 16505 Vlad 01/04/2013 5 August 13 pre-tax Medical Plan period Type
11-111-1111 Vlad 16505 01/04/2013 5 August 13 pre-tax Plan PPO medical Plan
11-111-1111 Vlad 16505 01/04/2013 5 August 13 Vision Plan amount 5.94 pre-tax
But I need the result to be
Amount of SSN ID name item level Option PayValue period Type
11-111-1111 Vlad 16505 01/04/2013 null null high of 5 August 13 pre-tax Dental Plan 29,65 EE + SP
11-111-1111 Vlad 16505 01/04/2013 null null MED 5 August 13 149 medical plan pre-tax EE + SP
11-111-1111 Vlad 16505 01/04/2013 Vision Plan before taxes of 5 August 13
Select distinct
' 11-111-1111 "as ssn,
WOMEN'S WEAR. Employee_number,
"Vlad" as EMPLOYEE_FULL_NAME,
TO_CHAR (papf.start_date, "MM/DD/YYYY") as Date_Of_Hire
a.effective_start_date,
PETF.element_name,
pivf. Name,
peevf.screen_entry_valueOf
PER_all_PEOPLE_F women's wear
per_assignments_f A
pay_element_types_f petf
pay_element_links_f pelf
PAY_ELEMENT_ENTRIES_F penf
PAY_ELEMENT_ENTRY_VALUES_F peevf
pay_input_values_f pivf
WHERE
PETF.element_name ('Dental Plan before taxes', 'Medical Plan before taxes', "Vision Plan before taxes")
and petf. ELEMENT_TYPE_ID = pelf. ELEMENT_TYPE_ID
and (trunc (sysdate) BETWEEN pelf. EFFECTIVE_START_DATE AND pelf. EFFECTIVE_END_DATE)
and (pelf. ELEMENT_LINK_ID = penf. ELEMENT_LINK_ID and a.assignment_id = penf. ASSIGNMENT_ID)
and (trunc (sysdate) BETWEEN penf. EFFECTIVE_START_DATE AND penf. EFFECTIVE_END_DATE)
and penf. ELEMENT_ENTRY_ID = peevf. ELEMENT_ENTRY_ID
and peevf. INPUT_VALUE_ID = pivf. INPUT_VALUE_ID
AND papf.employee_number IS NOT NULL
AND A.assignment_type = 'E '.
AND A.person_id = papf.person_id
and papf.effective_end_date > sysdate
and a.effective_end_date > sysdate
and (trunc (sysdate) BETWEEN women's wear. EFFECTIVE_START_DATE AND women's wear. EFFECTIVE_END_DATE)
and a.effective_start_date = (select MAX (effective_start_date) from PER_ASSIGNMENTS_f where assignment_id = a.assignment_id)
and a.assignment_id = 42643
and a.assignment_status_type_id = '1'
order of petf.element_name;Change with your query
SELECT * FROM (select distinct)
' 11-111-1111 "as ssn,
WOMEN'S WEAR. Employee_number,
"Vlad" as employee_full_name,
TO_CHAR (papf.start_date, "MM/DD/YYYY") as date_of_hire
a.effective_start_date,
PETF.element_name,
pivf. Name,
peevf.screen_entry_value
Of
PER_all_PEOPLE_F women's wear
per_assignments_f A
pay_element_types_f petf
pay_element_links_f pelf
PAY_ELEMENT_ENTRIES_F penf
PAY_ELEMENT_ENTRY_VALUES_F peevf
pay_input_values_f pivf
WHERE
PETF.element_name ('Dental Plan before taxes', 'Medical Plan before taxes', "Vision Plan before taxes")
and petf. ELEMENT_TYPE_ID = pelf. ELEMENT_TYPE_ID
and (trunc (sysdate) BETWEEN pelf. EFFECTIVE_START_DATE AND pelf. EFFECTIVE_END_DATE)
and (pelf. ELEMENT_LINK_ID = penf. ELEMENT_LINK_ID and a.assignment_id = penf. ASSIGNMENT_ID)
and (trunc (sysdate) BETWEEN penf. EFFECTIVE_START_DATE AND penf. EFFECTIVE_END_DATE)
and penf. ELEMENT_ENTRY_ID = peevf. ELEMENT_ENTRY_ID
and peevf. INPUT_VALUE_ID = pivf. INPUT_VALUE_ID
AND papf.employee_number IS NOT NULL
AND A.assignment_type = 'E '.
AND A.person_id = papf.person_id
and papf.effective_end_date > sysdate
and a.effective_end_date > sysdate
and (trunc (sysdate) BETWEEN women's wear. EFFECTIVE_START_DATE AND women's wear. EFFECTIVE_END_DATE)
and a.effective_start_date = (select MAX (effective_start_date) from PER_ASSIGNMENTS_f where assignment_id = a.assignment_id)
and a.assignment_id = 42643
and a.assignment_status_type_id = '1')
PIVOT (MAX (screen_entry_value) FOR (name) TO ("Amount" AS 'Amount', 'level' AS 'level', 'Option High' AS 'High Option', 'Pay the value' AS 'Value to pay', 'Period of Type' AS 'Type period'))
order by element_name;
(GOLD)
SELECT ssn,
Employee_number,
employee_full_name,
date_of_hire,
effective_start_date,
element_name,
Max (decode (Name, 'Amount', screen_entry_value)) 'amount. "
Max (decode (Name, 'Level', screen_entry_value)) 'level ',.
MAX (DECODE (name, "High Option", screen_entry_value)) "High Option",
MAX (DECODE (name, 'Value of pay', screen_entry_value)) 'value of pay. "
MAX (DECODE (name, 'Period Type', screen_entry_value)) 'period of Type '.
FROM (select distinct)
' 11-111-1111 "as ssn,
WOMEN'S WEAR. Employee_number,
"Vlad" as employee_full_name,
TO_CHAR (papf.start_date, "MM/DD/YYYY") as date_of_hire
a.effective_start_date,
PETF.element_name,
pivf. Name,
peevf.screen_entry_value
Of
PER_all_PEOPLE_F women's wear
per_assignments_f A
pay_element_types_f petf
pay_element_links_f pelf
PAY_ELEMENT_ENTRIES_F penf
PAY_ELEMENT_ENTRY_VALUES_F peevf
pay_input_values_f pivf
WHERE
PETF.element_name ('Dental Plan before taxes', 'Medical Plan before taxes', "Vision Plan before taxes")
and petf. ELEMENT_TYPE_ID = pelf. ELEMENT_TYPE_ID
and (trunc (sysdate) BETWEEN pelf. EFFECTIVE_START_DATE AND pelf. EFFECTIVE_END_DATE)
and (pelf. ELEMENT_LINK_ID = penf. ELEMENT_LINK_ID and a.assignment_id = penf. ASSIGNMENT_ID)
and (trunc (sysdate) BETWEEN penf. EFFECTIVE_START_DATE AND penf. EFFECTIVE_END_DATE)
and penf. ELEMENT_ENTRY_ID = peevf. ELEMENT_ENTRY_ID
and peevf. INPUT_VALUE_ID = pivf. INPUT_VALUE_ID
AND papf.employee_number IS NOT NULL
AND A.assignment_type = 'E '.
AND A.person_id = papf.person_id
and papf.effective_end_date > sysdate
and a.effective_end_date > sysdate
and (trunc (sysdate) BETWEEN women's wear. EFFECTIVE_START_DATE AND women's wear. EFFECTIVE_END_DATE)
and a.effective_start_date = (select MAX (effective_start_date) from PER_ASSIGNMENTS_f where assignment_id = a.assignment_id)
and a.assignment_id = 42643
and a.assignment_status_type_id = '1')
GROUP BY ssn, employee_number, employee_full_name, date_of_hire, effective_start_date, NOM_ELEMENT
order by element_name;
-
passing multiple values from the query in the select statement of the procedure
I am collecting IDS to select education agreement from the date of rental values and then I would pass the result of the query in the statement select to get the result.
data type for the contract id is of type varchar and date of rental there is more than one id to contract for most of the time. Help, please. Thank you
CREATE OR REPLACE PROCEDURE abstract_menu (p_letting IN VARCHAR2, p_results OUT SYS_REFCURSOR) IS v_contractId VARCHAR2 (40); SELECT lcontid INTO v_contractId FROM letprop WHERE datestat IS NOT NULL AND letting = p_letting AND letstat <> 'R'; BEGIN OPEN p_results FOR SELECT DISTINCT SUBSTR (l.letting, 3, 2) || '-' || SUBSTR (l.letting, 5, 2) || '-' || SUBSTR (l.letting, 1, 2) lettingdate, l.lcontid contractid, SUBSTR (q.cprojnum, 1, 10) projectnumber, DECODE (TRIM (MIN (j.route)), NULL, 'N/A', TRIM (MIN (j.route))) routenumber, L.DATESTAT statusdate, L.LETSTAT lettingstatus, (q.cdescr) jobdescription, INITCAP (q.clocat1 || q.clocat2) LOCATION FROM vendor v, vendaddr r, letprop l, planhold p, proposal q, project j, propproj k, bidlet bd WHERE v.vendor = r.vendor AND k.contid = q.contid AND k.pcn = j.pcn AND l.lcontid = k.contid AND p.vendor = v.vendor AND l.letting = p.letting AND l.lcontid IN v_contactid "**************This is where I would like to pass the contract id from the above select statement***********'" AND l.CALL = p.CALL AND r.addrnum = p.billto AND bd.letting = l.letting GROUP BY q.cdescr, q.clocat1, q.clocat2, bd.letting, l.letting, l.lcontid, q.cprojnum, L.LETSTAT, L.DATESTAT ORDER BY lettingdate; end;
user9196150 wrote:
AND l.lcontid IN v_contactid ' * this is where I would like to pass the id of the select statement above contract * ""»CREATE OR REPLACE PROCEDURE abstract_menu (p_letting IN VARCHAR2, p_results OUT SYS_REFCURSOR) IS BEGIN OPEN p_results FOR SELECT DISTINCT SUBSTR (l.letting, 3, 2) || '-' || SUBSTR (l.letting, 5, 2) || '-' || SUBSTR (l.letting, 1, 2) lettingdate, l.lcontid contractid, SUBSTR (q.cprojnum, 1, 10) projectnumber, DECODE (TRIM (MIN (j.route)), NULL, 'N/A', TRIM (MIN (j.route))) routenumber, L.DATESTAT statusdate, L.LETSTAT lettingstatus, (q.cdescr) jobdescription, INITCAP (q.clocat1 || q.clocat2) LOCATION FROM vendor v, vendaddr r, letprop l, planhold p, proposal q, project j, propproj k, bidlet bd WHERE v.vendor = r.vendor AND k.contid = q.contid AND k.pcn = j.pcn AND l.lcontid = k.contid AND p.vendor = v.vendor AND l.letting = p.letting AND l.lcontid IN ( SELECT ll.lcontid FROM letprop ll WHERE ll.datestat IS NOT NULL AND ll.letting = p_letting AND ll.letstat 'R' ) AND l.CALL = p.CALL AND r.addrnum = p.billto AND bd.letting = l.letting GROUP BY q.cdescr, q.clocat1, q.clocat2, bd.letting, l.letting, l.lcontid, q.cprojnum, L.LETSTAT, L.DATESTAT ORDER BY lettingdate; end; /
SY.
-
Need help with the query string manipulation
Hello
With the help of 10.1.0.4.2
Given a table called PREFIX_CODES that contains a column called PREFIX_CODE
with the following data:
PREFIX_CODE - VARCHAR2 (20)
-------------------
AAA
BENAMER
CARTER
and another table called SUBSCRIBERS with a column called SUBSCRIBER_ID
with the following data:
SUBSCRIBER_ID - VARCHAR2 (30)
---------------------
BBBB-123456
AAA-444444
DD-2222222
EEEE-888888
Is there a query that will pull all the SUBSCRIBER_ID that begin with
each of the PREFIX_CODES? The following query is not valid, but it
This will give you an idea of what I'm trying to do:
SELECT SUBSCRIBER_ID
SUBSCRIBERS
WHERE AS SUBSCRIBER_ID (SELECT PREFIX_CODE |) » %'
OF PREFIX_CODES)
Using the data from above, I would like that the query to return:
BBBB-123456
AAA-444444
Thanks for your help!Hello
Welcome to the forum!
You were on the right track. To find if a given subscriber corresponds to any prefix_code, you can do an EXISTS subquery:
SELECT subscriber_id FROM subsribers s WHERE EXISTS ( SELECT NULL FROM prefix_codes WHERE s.subscriber_id LIKE prefix_code || '%' ) ;
This will tell you if at least a prefix code. It won't tell you exactly how many, or what they were.
Your message, I'm guessing that there may be more than one, and you can deduct the subscriber_id itself, then the above query should work for you. -
Help with the query to return the last possible value
Can someone please help me to create a query for the situation below?
Table: TABLEA
Columns:
FACID VARCHAR2 (10),
DEPTID VARCHAR2 (10),
CHARGENUMBER NUMBER (10)
I have the following data:
A, B, 1
A, B, 2
C, D, 3
C, D, 4
I will return the following:
A, B, 2
C, D, 4
In other words, I would return the last possible CHARGENUMBER for FACID and DEPTID.
The table has no index, and it is responsible for a worksheet in that order.
Thank you very much!Hello
If you have a TIMESTAMP column, called entry_dt, you can use a Top - N query like this to find the last x entries.
WITH got_rnum AS ( SELECT my_table.* , RANK () OVER (ORDER BY entry_dt DESC) AS rnum FROM my_table ) SELECT * -- or list all columns except rnum FROM got_rnum WHERE rnum <= x ;
It is very common to have a trigger to ensure that columns like entry_dt are met.
If you have only one statement that inserts with hundreds of lines, they can all have the same entry_dt. (The value of SYSTIMESTAMP is constant throughout a statement, even if it takes a few seconds).
The above query uses RANK, so if you tell him you want the last 10 entries, it can return more than 10, because it includes all lines with exactly the same entry_dt as the 10th. If you want to exactly 10 rows returned, even if there is a tie for 10th place, then use ROW_NUMBER instead of RANK; the rest of the query is the same. -
Hi all
I have the below requirement.
I'm looking for a way to identify products with the exact same specifications.Master table: Product ID Product Name 1 TV 2 Cellphone 3 Laptop 4 DVD Player Details table: Product ID Spec type Spec Detail 1 Color Blue 1 Weight 20 2 Color Blue 2 Weight 20 3 Color Blue 3 Weight 25 4 Color Blue 4 Weight 20 4 Height 10
That is to say, in the example TV and cell phone above has exact specifications.
So the result of the query must be TV and phone cell phone here.
Is it possible to do in a query, or we need a sql block to perform this action.
Any help would be greatly appreciated.
Thank you
AgathyaHi agathya,
We do not know how you want to handle the situation where more than two products have the same specifications, so I extended your sample data slightly to take account of this situation as well:
SQL> create table products (id,name) 2 as 3 select 1, 'TV' from dual union all 4 select 2, 'Cellphone' from dual union all 5 select 3, 'Laptop' from dual union all 6 select 4, 'DVD Player' from dual union all 7 select 5, 'Radio' from dual union all 8 select 6, 'VCR' from dual 9 / Tabel is aangemaakt. SQL> create table product_specifications (product_id,spec_type,spec_detail) 2 as 3 select 1, 'Color' , 'Blue' from dual union all 4 select 1, 'Weight', '20' from dual union all 5 select 2, 'Color' , 'Blue' from dual union all 6 select 2, 'Weight', '20' from dual union all 7 select 3, 'Color' , 'Blue' from dual union all 8 select 3, 'Weight', '25' from dual union all 9 select 4, 'Color' , 'Blue' from dual union all 10 select 4, 'Weight', '20' from dual union all 11 select 4, 'Height', '10' from dual union all 12 select 5, 'Color' , 'Blue' from dual union all 13 select 5, 'Weight', '20' from dual union all 14 select 6, 'Color' , 'Blue' from dual union all 15 select 6, 'Weight', '20' from dual union all 16 select 6, 'Height', '10' from dual 17 / Tabel is aangemaakt. SQL> select p1.name 2 , p2.name 3 from products p1 4 , products p2 5 , product_specifications ps1 6 , product_specifications ps2 7 where p1.id = ps1.product_id 8 and p2.id = ps2.product_id 9 and p1.id < p2.id 10 group by p1.id 11 , p1.name 12 , p2.id 13 , p2.name 14 having sqrt(count(*)) = 15 count(case when ps1.spec_type = ps2.spec_type and ps1.spec_detail = ps2.spec_detail then 1 end) 16 / NAME NAME ---------- ---------- TV Cellphone TV Radio Cellphone Radio DVD Player VCR 4 rijen zijn geselecteerd.
But why devil you or your specifications product model predecessor like that? You are much more complicated that it should be. And the data type of size and weight should be not the same as those of color. But now they are. And how do limit you the allowed values for the colors? Color, weight and size are characteristic of your products so that they should have been modeled like this.
See how easily your questions becomes after remodeling it:
SQL> drop table product_specifications purge 2 / Tabel is verwijderd. SQL> drop table products purge 2 / Tabel is verwijderd. SQL> create table products (id,name,color,weight,height) 2 as 3 select 1, 'TV', 'Blue', 20, null from dual union all 4 select 2, 'Cellphone', 'Blue', 20, null from dual union all 5 select 3, 'Laptop', 'Blue', 25, null from dual union all 6 select 4, 'DVD Player', 'Blue', 20, 10 from dual union all 7 select 5, 'Radio', 'Blue', 20, null from dual union all 8 select 6, 'VCR', 'Blue', 20, 10 from dual 9 / Tabel is aangemaakt. SQL> select * from products 2 / ID NAME COLO WEIGHT HEIGHT ---------- ---------- ---- ---------- ---------- 1 TV Blue 20 2 Cellphone Blue 20 3 Laptop Blue 25 4 DVD Player Blue 20 10 5 Radio Blue 20 6 VCR Blue 20 10 6 rijen zijn geselecteerd. SQL> select p1.name 2 , p2.name 3 from products p1 4 , products p2 5 where p1.id < p2.id 6 and ( p1.color = p2.color or (p1.color is null and p2.color is null)) 7 and ( p1.weight = p2.weight or (p1.weight is null and p2.weight is null)) 8 and ( p1.height = p2.height or (p1.height is null and p2.height is null)) 9 / NAME NAME ---------- ---------- TV Cellphone TV Radio Cellphone Radio DVD Player VCR 4 rijen zijn geselecteerd.
I hope this helps.
Kind regards
Rob. -
Hauppauge support gave up. They never seemed very interested. TV card has been deleted, but its not returned. Nothing on the computer that is supposed to produce a sound made. Video functions on the TV card are fine. TV card is now back in.
Thanks for your suggestions
Ken
E-mail address is removed from the privacy *.
Most often when a device does not work, it is because the driver is damaged. Re-install a new copy should help -
Selection of understanding... from the query timestamp
Hello
I'm stuck with this scenario where we offer production data the developer to achieve a purpose test by altering the critical columns of the company by an arbitrary value continues the update statement.
Now the problem is when we fire select... from the timestamp request, we are able to display the old corrupted data. I created an example test case scenario:
CREATE TABLE test1 (identification number);
added values:
SQL > select * from test1;
ID
----------
1
2
3
4
5
5
5
5
5
5
10 selected lines.
SQL > update test1 ID = 3 where id = 5;
6 lines to date.
SQL > commit;
Validation complete.
Now the data in the table are:
SQL > select * from test1;
ID
----------
1
2
3
4
3
3
3
3
3
3
10 selected lines.
Now when I fire from the timestamp query I am able to see old data:
SQL > select * from test1 from sysdate timestamp - 5/1440;
ID
----------
1
2
3
4
5
5
5
5
5
5
10 selected lines.
SQL > select flashback_on from database v$.
FLASHBACK_ON
------------------
NO.
SQL > show parameter recyclebin;
VALUE OF TYPE NAME
------------------------------------ ----------- ------------------------------
Recyclebin OFF string
Now, I would like to know where oracle recover old data. According to my knowledge, it's going to be fetch these data to undo tablespace If yes then I would like to know is possible to stop this because this could expose the old data of the contracting authority.
Note:-this isn't a good way to hide the data, but it is a call from management for not no opt data tool because of the license of masking
You could do a DOF that is not actually change anything:
orclz > dept desc;
Name Null? Type
----------------------------------------------------------- -------- ----------------------------------------
DEPTNO NOT NULL NUMBER (2)
DNAME VARCHAR2(14)
LOC VARCHAR2(13)
orclz > alter table dept change (dname varchar2 (14));
Modified table.
orclz > select * from the Department as of timestamp(systimestamp-1/24);
Select * from the Department as of timestamp(systimestamp-1/24)
*
ERROR on line 1:
ORA-01466: unable to read data - table definition has changed
orclz >
--
John Watson
Oracle Certified MAster s/n
-
The response from the query web service
Hello
I would like to apply for assistance in creating an appropriate query to process the response from the web service.This is the outdated response from the web service and my unsuccessful attempt to treat.
PROCEDURE PRIMER_4B AS
XML_WS XMLTYPE.
CLOB DONNEES_XML
': = ' < s: Envelope xmlns:S = 'http://schemas.xmlsoap.org/soap/envelope/' > '.
< Body >
"< ns2:getDataResponse xmlns:ns2 ="http://service.anyxxx.com/">."
< return >
< id > 124 / < ID >
< name > Ana < / name >
< / return >
< / ns2:getDataResponse >
< / Body >
< / s: Envelope > ';CSR OF CURSOR IS
SELECT C.
FROM XMLTable)
XMLNamespaces)
' http://schemas.xmlsoap.org/SOAP/envelope/ ' LIKE 'SOAP'
, by default ' http://service.anyxxx.com/ '
)
, ': soap envelope / soap: Body/getDataResponse/back '
PASSAGE XML_WS
path id varchar2 columns (20) "id."
path of the varchar2 (30) name 'name '.
) C ;
rec_CSR CSR % ROWTYPE;BEGIN
XML_WS: = xmltype (donnees_xml);
Open the CSR;
LOOP
EXTRACT THE CSR IN REC_CSR;
DBMS_OUTPUT. Put_line (' Output: ' |) REC_CSR.ID |' '|| REC_CSR. (Name)
When the exit CSR % notfound;
end loop;
DBMS_OUTPUT. Put_line('Total:'||) CSR % ROWCOUNT);
close the CSR;
END PRIMER_4B;The result is:
Output:
Total 0
Thank you
KostadinHello
This part does not:
default 'http://service.anyxxx.com/'.
If you declare this uri as the default namespace uri, then 'return', 'id', 'name' nodes are supposed to be in this namespace, which is not correct, because they are in any workspace names.
Solution: give a specific prefix of the namespace above and reference it accordingly in the XQuery expression:
C. SELECT
FROM XMLTable)
XMLNamespaces)
"http://schemas.xmlsoap.org/soap/envelope/" AS "SOAP."
, 'http://service.anyxxx.com/' as 'ns2.
)
, ': soap envelope / soap: Body / ns2:getDataResponse / back '
PASSAGE XML_WS
Path id varchar2 COLUMNS (20) "id".
, path of the varchar2 (30) name 'name '.
) c ;
-
Need help with the query to get the County
Hello
Oracle 10 g 2 10.2.0.3 - 64 bit
I want back the number of accounts with two different types of funds (say A and B). Some accounts hold only one of the two funds, and some support both. I want to get the counts like this:
- account held funds - has only
- accounts holding funds-B only
- accounts holding the Fund-A and B funds
Here is what I started with but need assistance to meet the requirement above:
select count(distinct acct.bkoff_acct_no ) accounts_holding_fund_A from xe_account acct, xec_tal_investment_mandate iman, xec_tal_asset_allocation alloc, xe_benchmark bmark, xe_benchmark_usage bu, xe_object_description xod, xec_asset_class cls where iman.mandate_status_cd='A' and cls.asset_class_cd = alloc.asset_class_cd and iman.mandate_id = alloc.mandate_id and acct.account_id = iman.object_id and iman.object_type_cd = 'ACCT' and iman.mandate_id = xod.object_id and xod.field_nm='XEC_TAL_INVESTMENT_MANDATE.COMMENT_TXT' and xod.language_cd = 'E' and acct.acct_status_cd = 'O' and bu.object_type_cd(+) = 'TMAA' and bu.object_id(+) = alloc.asset_allocation_id and bmark.benchmark_id(+) = bu.benchmark_id and alloc.resp_txt like '%fund-A%'
And suppose that the Fund-B has resp_txt like ' % of Fund-B»
Please suggest.
Concerning
Hello
Here is another way, it is easier to adapt to different jobs and different numbers of jobs:
WITH got_distinct_jobs AS
(
SELECT DISTINCT deptno, job
FROM scott.emp
WHERE job IN ("ANALYST", "CLERKS") - or what
)
got_job_list AS
(
SELECT LISTAGG (job, ",") THE Group (ORDER BY work) AS job_list
OF got_distinct_jobs
GROUP BY deptno
)
SELECT job_list
COUNT (*) AS num_departments
OF got_job_list
GROUP BY job_list
;
This shows all the combinations of the jobs listed in the WHERE clause of got_distinct_jobs. You don't need to change anything else in the query. There may be any number of jobs.
Output:
JOB_LIST NUM_DEPARTMENTS
------------------------------ ---------------
CLERK 2
ANALYST, CLERK 1
-
Hi, can someone help me with the query. I try to display comm based on calculation below
SAL < 5000 then 10%
5000 - 10000 then 15%
> 10000 then 20%
This is the query
DECLARE
v_comm number (7.2);
v_Name emp.ename%type;
v_empno emp.empno%type;
v_sal emp.sal%type;
BEGIN
SELECT ename, empno, sal IN
v_Name, v_empno, v_sal
EMP;
v_comm: = (IF v_sal < v_sal*.10 then 5000;)
ELSIF v_sal between 5001 AND 10000 THEN v_sal*.15;
Of ANOTHER v_sal > 10001 THEN v_sal*.20;
END IF ;);
dbms_output.put_line(v_Name||) e with empno' | v_empno | "win a comm' | v_comm);
END; /
also tried
DECLARE
v_comm number (7.2);
v_Name emp.ename%type;
v_empno emp.empno%type;
v_sal emp.sal%type;
BEGIN
SELECT ename, empno, sal IN
v_Name, v_empno, v_sal
EMP;
IF v_sal < v_comm then 5000: = v_sal*.10;
ELSIF v_sal between 5001 AND 10000 THEN v_comm: = v_sal*.15;
Of ANOTHER v_sal > 10001 THEN v_comm: = v_sal*.20;
END IF ;);
dbms_output.put_line(v_Name||) e with empno' | v_empno | "win a comm' | v_comm);
END;
/
Hello
Look at the syntax of the IF in the PL/SQL manual. Comapre to the instruction BOX and also the expression BOX.
Perhaps, instead of an IF statement
v_comm: = (IF v_sal<5000 then="">5000>
ELSIF v_sal between 5001 AND 10000 THEN v_sal*.15;
ELSE v_sal > 10001 THEN v_sal*.20;
END IF ;);
you wanted to write an expression BOX, like this:
v_comm: = BOX
WHEN v_sal< 5000 ="" then="" v_sal="" *="">
WHEN v_sal BETWEEN 5001 AND 10000 THEN v_sal *.15
WHEN v_sal > 10001 THEN v_sal *.20
END;
Or perhaps cela:
v_comm: = v_sal * CASE
WHEN v_sal<= 5000="" then="">= >
WHEN v_sal<= 10000="" then="">=>
OF AUTRE.20
END;
You can also use a CASE expression in the SELECT statement.
Maybe you are looking for
-
Satellite Pro L10 will not start - the LED blinks
I have a pro l10 phone which, after sutting down as battery not return to life. All I get is 8 flashes on battery led when the button is pressed. It's the same area only, battery only or both.
-
Counter: Why is 'Task is' returns True after the time of the HIGH?
Realized that my other thread has been put out on the rails by... myself. Started testing the "task performed is" function on a counterexample over; Why is it returns "True" after time and not up AND down? And more still-so, how can I get him back 'T
-
problem solved need
-
I copied the tool to my hardrive and then burned it to a CD and then shut down the computer and restarted with the disc in the drive, but nothing happened. I tried to open the file but message says windows cannot open the file. I need to download a f
-
I have a new laptop. HP Pavilion g6. I have HP deskjet 3745. USB cable the printer plugged into the laptop. Outside the printer power button flashes.