help with a query mysql in advance
I use 7 CF to query a MySQL 5 DB.I was wondering if it is possible to add an OR operator in a subquery or at the end of a conditional statement. Let's say in my statement, WHERE after a few conditions inclusive, I wanted to add a logic "AND & or.
perhaps by including the part of my code, I can be a little clearer:
< cfquery name = "domysearch"... >
SELECT
a.ID as id,
.....
b.Company company
.....
c.add_line1 as add_line1,
.....
OF registratn_contacts a, registratn b, registratn_addresses c
WHERE a.owner = #arguments.owner #.
AND b.id = a.master_record
AND a.address_id = c.id
AND c.state = 'NY '.
OR c.state = 'CA '.
I would like to know if I can or should accomplish this in my application or if I should have this logic outside the query?
Thanks for any help!
Carlos
WHERE THE...
AND (c.state = 'NY' GOLD c.state = 'CA')
You can use a RC, it is probably preferable to use an IN clause but it is essentially a RC and would be more effective.
AND c.state ('NY', 'CA')
Phil
Tags: ColdFusion
Similar Questions
-
Need help with a query MySQL =)
The following query displays the arguments in the order of how many times that each bid was seen by a visitor in the last 7 days, from the highest to the lowest. How can I show him each record in the table 'submission_data', even if there is no matching record in the table 'submission_views '? Basically I want the presentations with a 'id_count' of 0 to display at the end.
SELECT COUNT (Distinct submission_views.submission_id, submission_views.ip_address) AS id_count, submission_data.id, submission_data.thumbnail_source, submission_data.title, submission_data.type
FROM submission_data LEFT JOIN submission_views ON submission_views.submission_id = submission_data.id
WHERE submission_views.timestamp > DATE_SUB (NOW (), INTERVAL of 7 DAYS)
GROUP BY submission_data.id
ORDER BY id_count DESC> WHERE (submission_views.timestamp > DATE_SUB (NOW (), INTERVAL of 7 DAYS))
(> OR submission_views.timestamp = NULL)Use the IS NULL, not the = operator.
-
Oracle Version: 11.2.0.2.0
I need assistance with the output of the query. Here is the table.
With Tbl_Nm as
(
Select 'ABC1' SYSTEM_ID, REGION 'US', 'CHI' SUB_REGION 4000 BALANCE, to_date('1-JUN-2012 10:45:00 am', 'dd-mon-yyyy hh:mi:ss am') LAST_UPD_TIME, 'A' FLAG of union double all the
Select 'PQR2', 'UK', 'LN', 2000, To_Date('1-JUL-2012 10:46:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' starting from dual Union All
Select 'ABC1', 'IND","MAMA", 3500, To_Date('1-AUG-2012 11:47:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All
Select "LMN3", "US", "NJ", 2500, To_Date('1-SEP-2012 09:49:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All
Select "PQR2", "UK", "MC", 2600, To_Date('1-OCT-2012 04:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All
Select 'ABC1', 'US', 'NY', 3200, To_Date('1-OCT-2012 06:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' starting from dual Union All
Select "LMN3", "UK", "BT", 2400, To_Date('1-NOV-2012 07:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' From Dual
)
Select * from tbl_nm
I need the output below.
PQR2 UK MC 2600 1 OCTOBER 2012 04:45
ABC1 US NY 3500 October 1, 2012 06:45
LMN3 UK BT 2500 November 1, 2012 07:45
The need the disc according to this system_id flagged as "A". But if the last disc of 'd' then it must show that the amount, but the file should be displayed in 'A '.
I've tried a few and got stuck. Help, please. Not able to get a balance '.
This question is a bit similar to needing help with a query result
With Tbl_Nm as
(
Select 'ABC1' System_Id, region 'US', 'CHI' Sub_Region, 4000 balance, To_Date('1-JUN-2012 10:45:00 am', 'dd-mon-yyyy hh:mi:ss am') Last_Upd_Time, 'A' flag of double Union All
Select 'PQR2', 'UK', 'LN', 2000, To_Date('1-JUL-2012 10:46:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' starting from dual Union All
Select 'ABC1', 'IND","MAMA", 3500, To_Date('1-AUG-2012 11:47:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All
Select "LMN3", "US", "NJ", 2500, To_Date('1-SEP-2012 09:49:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All
Select "PQR2", "UK", "MC", 2600, To_Date('1-OCT-2012 04:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All
Select 'ABC1', 'US', 'NY', 3200, To_Date('1-OCT-2012 06:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' starting from dual Union All
Select "LMN3", "UK", "BT", 2400, To_Date('1-NOV-2012 07:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' From Dual
)
Select System_Id, region, Sub_Region, Balance, Last_Upd_Time of Tbl_Nm T1
where t1. Last_Upd_Time = (select max (Last_Upd_Time) in the Tbl_Nm T2 where T1.) SYSTEM_ID = T2. SYSTEM_ID)
So maybe you'd then
ORDER BY DECODE(flag,'D',9,1) ASC...
to get the Ds at the end of the list.
or
ORDER BY CASE WHAT flag = has ' (your other filters) AND then 9 or 1 end CSA,...
HTH
-
Dialog box that says ' Creative Cloud Installer wants to make changes. Type your password for this purpose"- I type my password for Adobe ID (creative cloud), but it will not accept it. who should I go for help with this query?
It does not ask the cloud your computer admin password password!
-
Get error 207 trying to download creative Cloud and someone please help with this problem, thanks in advance please.
Please refer to
-
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
-
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 -
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;
-
Help with the query to create hourly statistics
Hello!
I have an array of jobs. Each task has a start_date and a column end_date. end_date can be null if the job is still running.
I need to create a query to display the number of jobs running for all hours during the last two weeks.
A job can run for more than an hour.
I tried to define what it means for a job during an interval:
Job.Start_date < = Interval.end AND Job.Finish_date > = Interval.start
Can help you with this query?
Thank you!
Mihai
Hi, Mihai,
User810719-Oracle wrote:
Hello!
I have an array of jobs. Each task has a start_date and a column end_date. end_date can be null if the job is still running.
I need to create a query to display the number of jobs running for all hours during the last two weeks.
A job can run for more than an hour.
I tried to define what it means for a job during an interval:
Job.Start_date <= interval.end="" and="" job.finish_date="">= Interval.start...
=>
You gave essentially the solution yourself. You just need to outside join your jobs table to a table (or, in the example below, a result set that acts like a table) containing 1 row for each interval. You can use NVL to equate finish_dates with an effective DATE NULL, so they will be counted:
WITH intervals AS
(
SELECT TRUNC (SYSDATE, 'HH') - ((LEVEL-1)/24) AS interval_start
, TRUNC (SYSDATE, 'HH') - ((LEVEL-2)/24) AS interval_end
OF the double
CONNECT BY LEVEL<= 14="" *="">=>
)
SELECT i.interval_start
EARL of (j.start_date) AS jobs_running
Intervals I have
LEFT OUTER JOIN jobs j WE j.start_date<=>=>
AND NVL (j.finish_date
i.interval_end
) > = i.interval_start
;
If you would care to post a small example of data (CREATE TABLE and INSERT statements) and the results desired from this data, I was able to test this.
Simplify the problem for display. Do what you are interested only for the past 6 hours, not the last 2 weeks. We will find a solution that can easily adapt to any number or intervals.
-
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.
-
Help with sql query / a subquery to perform the COUNT
Hello everyone,
Co-worker colleague asked me to post a request here in hopes of getting more support. Here's the question:
There are 3 tables associated with this request. A table of the application, which displays a number of application open for a particular request, an audit table that shows you all employees who worked on this application and one employee who shows you the details of the employee table. My colleague is trying to understand what, how to see only applications that have been published by a wizard, but not a Manager. There are a few applications that worked on both, but he won't see this request in its results.
Here are the tables
EMP
ID FULL_NAME 1234 John Doe 5467 Jane Doe 2345 Clark Kent 5432 June Cleaver Unfortunately, this table does not have a title column (which was created provider, so we cannot change the internal structure). My colleague knows who is the Assistant and the Director, then in this case, the first two of the id:
1234 and 5467 are managers and the other 2 are assistants
T_APPLICATION
app_id app_number date_opened app_type 9018 54778 JANUARY 10, 2014 NETWORK 9019 54779 JANUARY 11, 2014 DATABASE 9010 55000 MARCH 12, 2014 MATERIAL T_APP_AUDIT
APP_ID PROCESSED_BY 9018 1234 9018 2345 9018 5432 9019 2345 9019 5432 9010 5432 So, here is the actual query, I was given: it is actually to check the number of times that each application has been published per person:
Select a.app_id, c.full_name, count (*) that controls
t_application a, t_app_audit b, c of the emp
where a.app_id = b.app_id and b.processed_by = c.id and
a.app_type in ('NETWORK', "DATABASE")
and b.processed not in ('1234, ' 5467')
GROUP OF A.APP_ID, c.full_name;
IF I won't see 9018 in my results, since at one time it was edited by a Manager (1234). Unfortunately, this request does not eliminate the app_id 9018, it eliminates only the name of handlers appear in the query. I hope I've explained this properly, and any help to point us in the right direction is welcomed. Thanks in advance.
Select
a.app_id
c.full_name
, count (*) as the controls
of t_application one
t_app_audit b
c of the emp
where a.app_id = b.app_id
and b.processed_by = c.id
and a.app_type in ('NETWORK', "DATABASE")
and b.app_id by (not in
Select app_id
of t_app_audit
where processed_by in ('1234, ' 5467')
)
GROUP OF A.APP_ID, c.full_name;
-
Hello
I have a customer as requirement below
We have the table header and contains data such as
ID, custname, socket
101, raju, 514
102, ratna, 12
103, rakesh, 16
104, joseph, 129
and we mappingtable like below as
sampval, socket
244094,512
244095,2
244096,4
244097,8
244098,16
244102,128
244103,1
If header.mapvalue is 514 analysis then it out on the mappingtable basis to be exported for a value of 244094. 244095.
Header.mapvalue is 12 parsing it out based on mappingtable to be exported for a value of 244096. 244097 and so on...
Could you please help me how to get the functionality in a database query.
Thanks in advance
Try to query below and let me know
SELECT id,
custName,
HT.mapvalue,
req_val
From ht header_tbl,
(SELECT SAMPVAL,
socket,
CITY,
SUMVAL,
REQ_VAL
Of
(SELECT SAMPVAL,
socket,
CITY,
SUMVAL,
REQ_VAL,
ROW_NUMBER() over (ORDER BY lvl SUMVAL PARTITION) rn
Of
(SELECT sampval,
socket,
City,
LEVEL lvl,
CASE
WHEN ((= LEVEL 2)
AND (socket = socket connect_by_root))
THEN socket
ANOTHER socket + connect_by_root socket
END as sumval,
CASE
WHEN ((= LEVEL 2)
AND (socket = socket connect_by_root))
THEN TO_CHAR (sampval)
Of OTHER TO_CHAR (CONNECT_BY_ROOT sampval
||'|'
|| sampval)
END AS req_val
A mapping
CONNECT BY LEVEL<=>=>
)
WHERE the lvl = 2
)
WHERE rn = 1
) qry_rslt
WHERE ht.mapvalue = qry_rslt.sumval;
An alternative with xmlagg, you can use this query to achieve your requirement
SELECT id, custname, RTRIM (xmlagg (xmlelement(e,mp.sampval||'|')). Extract ('//Text ()'),'| ') req_val
From header_tbl, mapping mp ht
WHERE mp.mapvalue = BITAND (mp.mapvalue, ht.mapvalue)
GROUP BY id, custname;
-
NB100 - need help with Toshiba Eco Utility to advanced user
I want to ask the advanced user (knowing regedit, windows services and processes) and Eco Utility installed to help me with Toshiba Eco Utility.
(1) I need the registry branch where Eco Utility to store preferences.
(2) screenshot for TecoService services. With params.
(3) screen capture of process. Looking for TPCMpwr.exe itWhy I need?
I have Toshiba NB100 netbook where Toshiba has not released Eco Utility.
NB200 there, but not for NB100.
I don't know why... It will work, only I need the registry and services information.P.S. If Toshiba engineers will read this post.
Why Toshiba release Eco Utility for NB100?Hi Lrrrr,
Just a simple question: what installation Eco Utility on your NB100?
But normally you don't need this utility of Eco. As much I know this tool only changes power settings Windows you can do it yourself too. It s a nice tool where you can reduce the energy consumption in a single click, but you can do it yourself if you create the own power profile or change.
-
Please help in the slot provided.
I have two columns A and B in a table with data as below,
A AND B
1 INACTIVE
ACTIVE 1
2 ACTIVE
DEFAULT 2
2 DEGENERATE
2 INACTIVE
3 PASSED
3 DEFAULT
3 DEGENERATE
3 DEGENERATE
INACTIVE 3
4 INACTIVE
DEFAULT 4
5 BY DEFAULT
5 ACTIVE
I want to write a query that will give the values in column A where column B must not have value as 'ACTIVE' after group the data in column A.
That is to say of the above example data that the outcome should be 3 and 4 since only 3 and 4 was not ACTIVE as a value in column B.
My database is version 11g 11.2.0.3 on OS linux.
nothing... just use
SELECT A
FROM THE DATA
Group by one
having MAX (CASE b WHEN "ACTIVE", THEN b ELSE NULL END) is null;
because you have a table named somehow (icies data) and you have columns in it with a name, I just don't want to create tables, insert data, and remove the tables afterwards - it's the reason why the with.
HTH
-
Dear all,
I have a sql like query below
SELECT min (G.TRANSACTION_DATE), D.REQUEST_NUMBER
MTL_TXN_REQUEST_HEADERS D,.
MTL_TXN_REQUEST_LINES, E.
MTL_MATERIAL_TRANSACTIONS G,.
Mtl_Transaction_Types I have
WHERE D.HEADER_ID = E.HEADER_ID
AND G.TRANSACTION_TYPE_ID = I.TRANSACTION_TYPE_ID
AND Upper (I.Transaction_Type_Name) = Upper ('TEC outcome')
AND E.LINE_ID = G.MOVE_ORDER_LINE_ID
AND D.MOVE_ORDER_TYPE = 5
TO_DATE (G.TRANSACTION_DATE) BETWEEN TO_DATE('01-JAN-2014') AND TO_DATE('31-DEC-2014')
D.REQUEST_NUMBER GROUP
I need to get the first number of the application and finally ask for number based on the date of the transaction, how can I get the number of name application and based on the date of the transaction for the same query, please help me.
above query is back under results
If the query should return a line with the number of application like 2383 based on minimum transaction date and another column based on the maximum transaction date, please help me.
so in the example above, it must return
FIRST REQUEST NUMBER LAST NUMBER
2383 1886
Thank you
select min(request_number) keep(dense_rank first order by transaction_date asc ) request_number_min , min(request_number) keep(dense_rank first order by transaction_date desc) request_number_max from ( select min(g.transaction_date) transaction_date , d.request_number from mtl_txn_request_headers d , mtl_txn_request_lines e , mtl_material_transactions g , mtl_transaction_types i where d.header_id = e.header_id and g.transaction_type_id = i.transaction_type_id and upper(i.transaction_type_name) = upper('WIP Issue') and e.line_id = g.move_order_line_id and d.move_order_type = 5 and to_date(g.transaction_date) between to_date('01-jan-2014') and to_date('31-dec-2014') group by d.request_number )
Maybe you are looking for
-
I have iTunes on Windows 10. iTunes does not recognize my internal speakers when other applications will recognize them. I can use the helmet without a problem. Why is this?
-
smart photo Media does not
-
Can I put the DVD Blu Ray player on my DV4 WE 1430? With the core 2 duo, W7 64-bit. DV4 1430US
-
I bought a Toshiba laptop through my former employer. After I left the company, I found that they did not provide records of software to me, that I bought with the laptop. Now, nobody seems to know where are my records of software. My certificate
-
transfer lightroom 5 computer dead to the new computer
Old computer with Lightroom5 installed is dead. Bought new computer and want to install LR5. How?