T sql query urgent pls
hi ,
i have data like this
cola colb colc
123 12 a
123 12 b
123 12 a
124 12 d
124 12 f
we have to loop throuhj all the values associated with colc for each cola and colb, if all the values are not in (a and b), then i return the distinct on cola and colb
in the above instnace , the retruned value is 124 12, since none of the values in colc are in (a and b)
pls help, tx
Please see below...
DECLARE @TABLE TABLE
(cola INT, colb INT, colc CHAR(10))
INSERT INTO @TABLE VALUES(123, 12, 'a'), (123, 12, 'b'), (123, 12, 'a')
, (124, 12, 'd'), (124, 12, 'f'), (123, 12, 'c')
SELECT * FROM @TABLE b WHERE b.colc = 'a' OR b.colc = 'b'
;WITH CTE AS
(SELECT DISTINCT cola, colb FROM @TABLE b WHERE b.colc = 'a' OR b.colc = 'b')
SELECT DISTINCT a.cola, a.colb
FROM @TABLE a
LEFT JOIN CTE b ON a.cola = b.cola AND a.colb = b.colb
WHERE b.cola IS NULL AND b.colb IS NULL
Please mark as answer, if this has answered your question.
Good Luck :) .. visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles.
Similar Messages
-
Hi Gurus,
Select * from xxa_test1
invoice_type || LOC_CODE|| seq_no
=========================
DOMESTIC A 1
DOMESTIC B 2
DOMESTIC C 3
Select * from xxa_test2
cust_no || cust_name || loc_code
=======================
1001 Test B
1001 Test C
The Requirement is i want sql query to retrive only one record based on seq no if suppose 2 records retrive in that
B is having seqno 2 and c having seq no 3
that sql query should return only one record which is having min seq no. for example in that B, C only B record should return.
If multiple values returned then the program must check based on the seq no it should take min seq no.
i have written this query
Select *
from xxa_test2 t2
where t2.loc_code in (select t1.loc_code
from xxa_test1 t1
order by Seq_no
where above query is correct or not , i am getting problem with this query.
Please let me know its very urgent
Thanks
Manju
Edited by: venu on Jul 26, 2011 12:50 AMSomething like:
SELECT cust_no, cust_name, loc_code
FROM
(with xxa_test1
as (SELECT 'DOMESTIC' invoice_type, 'A' loc_code, 1 seq_no FROM dual
union all
SELECT 'DOMESTIC', 'B', 2 FROM dual
union all
SELECT 'DOMESTIC', 'C', 3 FROM dual),
xxa_test2
as (SELECT 1001 cust_no, 'Test' cust_name, 'B' loc_code FROM dual
union all
SELECT 1001 , 'Test' , 'C' FROM dual)
SELECT cust_no, cust_name, t2.loc_code, seq_no, min(seq_no) over() min_seq
FROM xxa_test2 t2,xxa_test1 t1
WHERE t2.loc_code = t1.loc_code)
WHERE seq_no = min_seq
SQL> /
CUST_NO CUST L
1001 Test B -
Help me write a SQL query; urgent
Hi, can somebody please help me write a SQL query.
I have 3 tables each with the same column names (Col1, Col2, Col3). Col1 is PK with Unique Constraint.
I wanted to add values of Col2 and Col3 (from all 3 tables) and put it in a separate table (i.e aggregated) of all values found in Col1.
Does anybody help me please ?
thanks alot.Please don't mark your question as urgent. You've been around here long enough that you should know that it will not get your question anwered any faster, and may just irritate people into not answering at all.
I'm not sure exactly what you want.
Are you saying you want t1.c2 + t1.c3 + t2.c2 + t2.c3+ t3.c2 + t3.c3 for the rows that have the same c1 in all three tables?
If so, it would be like this, I think: insert into t4
select t1.c1
, t1.c2 + t1.c3 + t2.c2 + t2.c3+ t3.c2 + t3.c3
from t1, t2, t3
where t2.c1 = t1.c1
and t3.c1 = t1.c1If that's not what you want, please clarify.
And next time maybe you should post your SQL question in a SQL forum. -
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
); -
Sql query - urgent major problem
If I have the following sql query and I would like to perform a select on this how would I do it.
select StudentNo, CourseCode, Year, ExamMark from **
where CourseCode='ELE304' AND Year=1999;
**select COURSESTUDENT.StudentNo, COURSESTUDENT.CourseCode, COURSESTUDENT.Year, MARKS.ExamMark, MARKS.EntryNo AS RESULT FROM
COURSESTUDENT LEFT JOIN MARKS ON COURSESTUDENT.StudentNo=MARKS.StudentNo AND COURSESTUDENT.CourseCode='ELE304' AND
MARKS.CourseCode='ELE304' AND COURSESTUDENT.Year=1999 AND MARKS.Year=1999;Ive been trying to get this sql query correct the whole day this is a joke .......
Someone must know what the prob is...
thanks
tzaf -
How to join two pl/sql tables .,.,,Urgent pls help
Hi,
Please tell me how to join to pl/sql tables with example
thanks
aspIf your main intention is to get the common records/or getting whole records from the 2 different pl/sql arrays then , pls check this piece of code & explanation
The SQL language has long offered the ability to apply set operations (UNION, INTERSECT, and MINUS) to the result sets of queries. In Oracle Database 10g, you can now use those same high-level, very powerful operators against nested tables (and only nested tables) in your PL/SQL programs and on nested tables declared as columns inside relational tables.
Let's take a look at some of the syntax needed to do this, starting with UNION.
First, I create a schema-level nested table type:
CREATE OR REPLACE TYPE strings_nt
IS TABLE OF VARCHAR2(100);
Then I define a package and within it create and populate two nested tables of this type, each containing some of my father's and my favorite things:
CREATE OR REPLACE PACKAGE favorites_pkg
IS
my_favorites strings_nt
:= strings_nt ('CHOCOLATE'
, 'BRUSSEL SPROUTS'
, 'SPIDER ROLL'
dad_favorites strings_nt
:= strings_nt ('PICKLED HERRING
, 'POTATOES'
, 'PASTRAMI'
, 'CHOCOLATE'
PROCEDURE show_favorites (
title_in IN VARCHAR2
, favs_in IN strings_nt
END;
In this package, I also include a procedure to show the contents of a strings_nt nested table. This will come in very handy shortly.
By defining these collections in a package, outside any program, they persist (they maintain their state and values) for the duration of my session or until I change or delete them. This means that I can now write programs outside the package to manipulate the contents of those collections.
Note that this package has been simplified for the purposes of presenting collection functionality. In a production application, you should always take care to "hide" your package data, as with these collections, in the package body, and then provide procedures and functions to manage the data.
Suppose, for example, that I would like to combine these two collections into a single collection of our favorites. Prior to Oracle Database 10g, I would have to write a loop that transfers the contents of one collection to another. Now, I can rely on the MULTISET UNION operator, as shown below:
DECLARE
our_favorites
strings_nt := strings_nt ();
BEGIN
our_favorites :=
favorites_pkg.my_favorites
MULTISET UNION ---- Use INTERSECT , if you want to know common records
favorites_pkg.dad_favorites;
favorites_pkg.show_favorites (
'ME then DAD', our_favorites);
END;
The output from this script is:
ME then DAD
1 = CHOCOLATE
2 = BRUSSEL SPROUTS
3 = SPIDER ROLL
4 = PICKLED HERRING
5 = POTATOES
6 = PASTRAMI
7 = CHOCOLATE
------------------------------ -
SQL Query Urgent..pls help
Dear Experts,
Table.
C_id Purity
1 100
2 100
10 100
11 100
12 100
Ranking Regions by Size You have to list all regions in the table, and you have to list them according to their size.
you need to list all regions of two or more containers with a purity of 100, and you need to sort that list by the number of containers in each region.
The output should be something like this:
RegBeg RegEnd RegionSize
10 12 3
1 2 2
Kindly help me,
BasavLooks like a homework assignment.
Perhaps you can explain to your tutor how the tabbibitosan method works...
SQL> ed
Wrote file afiedt.buf
1 with t as (select 1 as C_id, 100 as Purity from dual union all
2 select 2, 100 from dual union all
3 select 4, 100 from dual union all
4 select 5, 100 from dual union all
5 select 6, 50 from dual union all
6 select 7, 100 from dual union all
7 select 10, 100 from dual union all
8 select 11, 100 from dual union all
9 select 12, 100 from dual)
10 --
11 -- use tabbibitosan method to group data
12 select min(c_id) as min_c_id
13 ,max(c_id) as max_c_id
14 ,count(*) as grp_size
15 from t
16 where purity = 100
17 group by c_id-rownum
18 having count(*) > 1
19* order by 3 desc, 1
SQL> /
MIN_C_ID MAX_C_ID GRP_SIZE
10 12 3
1 2 2
4 5 2... if you can understand it. ;) -
In the problem iam calculating a Stock report.In the SQL suppose the relation F does not return any rows , then (D.ACC_QTY + F.RET_QTY) gives null. How to avoid this problem..
SELECT A.CLASSIFICATION_CODE, A.ITEM_ABBR, A.ITEM_DESC,
A.ALT_ITEM_CODE, A.UOM_DESC, A.BASIC_PRICE,
(A.OPENING_QTY + B.ACC_QTY - C.ISS_QTY)
OPENING_STOCK, (D.ACC_QTY + F.RET_QTY) ACCEPT_QTY, E.ISS_QTY,
((A.OPENING_QTY + B.ACC_QTY - C.ISS_QTY)
+ (D.ACC_QTY + F.RET_QTY) - E.ISS_QTY)
QTY_IN_HAND
FROM (SELECT CLASSIFICATION_CODE, ITEM_ABBR, ITEM_DESC,
ALT_ITEM_CODE, NVL(OPENING_QTY, 0)
OPENING_QTY, UOM_MASTER.UOM_DESC,
BASIC_PRICE
FROM ITEM_MASTER, UOM_MASTER
WHERE ITEM_MASTER.UOM_CODE = UOM_MASTER.UOM_CODE)
A,
(SELECT GRN_DETAIL.ITEM_CODE,
SUM(NVL(GRN_DETAIL.ACCEPT_QTY, 0))
ACC_QTY
FROM GRN_HEADER, GRN_DETAIL
WHERE GRN_HEADER.GRN_NO = GRN_DETAIL.GRN_NO AND
GRN_HEADER.GRN_DATE < '01-JAN-2006'
GROUP BY GRN_DETAIL.ITEM_CODE) B,
(SELECT MRN_DETAIL.ITEM_CODE,
SUM(NVL(MRN_DETAIL.ISSUED_QTY, 0))
ISS_QTY
FROM MRN_HEADER, MRN_DETAIL
WHERE MRN_HEADER.MRN_NO = MRN_DETAIL.MRN_NO AND
MRN_HEADER.MRN_DATE < '01-JAN-2006'
GROUP BY MRN_DETAIL.ITEM_CODE) C,
(SELECT GRN_DETAIL.ITEM_CODE,
SUM(NVL(GRN_DETAIL.ACCEPT_QTY, 0))
ACC_QTY
FROM GRN_HEADER, GRN_DETAIL
WHERE GRN_HEADER.GRN_NO = GRN_DETAIL.GRN_NO AND
GRN_HEADER.GRN_DATE BETWEEN
'01-JAN-2006' AND '31-DEC-2006'
GROUP BY GRN_DETAIL.ITEM_CODE) D,
(SELECT MRN_DETAIL.ITEM_CODE,
SUM(NVL(MRN_DETAIL.ISSUED_QTY, 0))
ISS_QTY
FROM MRN_HEADER, MRN_DETAIL
WHERE MRN_HEADER.MRN_NO = MRN_DETAIL.MRN_NO AND
MRN_HEADER.MRN_DATE BETWEEN
'01-JAN-2006' AND '31-DEC-2006'
GROUP BY MRN_DETAIL.ITEM_CODE) E,
(SELECT B.ITEM_CODE,
SUM(NVL(B.QUANTITY_ISSUE,0))
RET_QTY
FROM MATERIAL_MOVEMENT_HEADER A,MATERIAL_MOVEMENT_DETAIL B
WHERE A.SLIP_NO = B.SLIP_NO AND
A.SLIP_DATE BETWEEN
'01-JAN-2006' AND '31-DEC-2006' AND
B.TO_JOB_CODE IS NULL
GROUP BY B.ITEM_CODE) F
WHERE A.ALT_ITEM_CODE = B.ITEM_CODE (+) AND
A.ALT_ITEM_CODE = C.ITEM_CODE (+) AND
A.ALT_ITEM_CODE = D.ITEM_CODE (+) AND
A.ALT_ITEM_CODE = E.ITEM_CODE (+) AND
A.ALT_ITEM_CODE = F.ITEM_CODE (+) AND
A.ALT_ITEM_CODE LIKE 'BOBRNG%017' AND
A.CLASSIFICATION_CODE = 'BO';Sorry members for writing the word 'Urgent'..and really cutting down on your work.
I am thankful to the person who pointed out my error in the query..it was really simple..should hv solved myself, but even after changing the query with Nvl and changing the business logic to some extent it again fetches no rows..
The sql given underneath is basically a job-wise stock allocation report..
SELECT B.JOB_CODE, A.CLASSIFICATION_CODE, A.ITEM_ABBR,
A.ITEM_DESC, A.ALT_ITEM_CODE, A.UOM_DESC,
A.BASIC_PRICE, (A.OPENING_QTY + (NVL(B.ACC_QTY, 0)
+ NVL(F.RET_IN, 0)) - (NVL(C.ISS_QTY, 0) + NVL(G.RET_OUT,
0))) AS OPENING_STOCK, (NVL(D.ACC_QTY, 0)
+ NVL(H.RET_IN, 0)) RECEIVED, (NVL(E.ISS_QTY, 0)
+ NVL(I.RET_OUT, 0)) ISSUED,
((A.OPENING_QTY + (NVL(B.ACC_QTY, 0) + NVL(F.RET_IN, 0))
- (NVL(C.ISS_QTY, 0) + NVL(G.RET_OUT, 0)))
+ (NVL(D.ACC_QTY, 0) + NVL(H.RET_IN, 0)) - (NVL(E.ISS_QTY,
0) + NVL(I.RET_OUT, 0))) QTY_IN_HAND
FROM (SELECT CLASSIFICATION_CODE, ITEM_ABBR, ITEM_DESC,
ALT_ITEM_CODE, UOM_MASTER.UOM_DESC,
BASIC_PRICE, 0 OPENING_QTY
FROM ITEM_MASTER, UOM_MASTER
WHERE ITEM_MASTER.UOM_CODE = UOM_MASTER.UOM_CODE)
A,
(SELECT GRN_HEADER.JOB_CODE,
GRN_DETAIL.ITEM_CODE,
SUM(NVL(GRN_DETAIL.ACCEPT_QTY, 0))
ACC_QTY
FROM GRN_HEADER, GRN_DETAIL
WHERE GRN_HEADER.GRN_NO = GRN_DETAIL.GRN_NO AND
GRN_HEADER.GRN_DATE < '01-JAN-2006'
GROUP BY GRN_HEADER.JOB_CODE,
GRN_DETAIL.ITEM_CODE) B,
(SELECT B.TO_JOB_CODE, B.ITEM_CODE,
SUM(NVL(B.QUANTITY_ISSUE, 0)) RET_IN
FROM MATERIAL_MOVEMENT_HEADER A,
MATERIAL_MOVEMENT_DETAIL B
WHERE A.SLIP_NO = B.SLIP_NO AND
A.SLIP_DATE < '01-JAN-2006'
GROUP BY B.TO_JOB_CODE, B.ITEM_CODE) F,
(SELECT MRN_HEADER.JOB_CODE,
MRN_DETAIL.ITEM_CODE,
SUM(NVL(MRN_DETAIL.ISSUED_QTY, 0))
ISS_QTY
FROM MRN_HEADER, MRN_DETAIL
WHERE MRN_HEADER.MRN_NO = MRN_DETAIL.MRN_NO AND
MRN_HEADER.MRN_DATE < '01-JAN-2006'
GROUP BY MRN_HEADER.JOB_CODE,
MRN_DETAIL.ITEM_CODE) C,
(SELECT B.JOB_CODE, B.ITEM_CODE,
SUM(NVL(B.QUANTITY_ISSUE, 0)) RET_OUT
FROM MATERIAL_MOVEMENT_HEADER A,
MATERIAL_MOVEMENT_DETAIL B
WHERE A.SLIP_NO = B.SLIP_NO AND
A.SLIP_DATE < '01-JAN-2006'
GROUP BY B.JOB_CODE, B.ITEM_CODE) G,
(SELECT GRN_HEADER.JOB_CODE,
GRN_DETAIL.ITEM_CODE,
SUM(NVL(GRN_DETAIL.ACCEPT_QTY, 0))
ACC_QTY
FROM GRN_HEADER, GRN_DETAIL
WHERE GRN_HEADER.GRN_NO = GRN_DETAIL.GRN_NO AND
GRN_HEADER.GRN_DATE BETWEEN
'01-JAN-2006' AND '31-DEC-2006'
GROUP BY GRN_HEADER.JOB_CODE,
GRN_DETAIL.ITEM_CODE) D,
(SELECT B.TO_JOB_CODE, B.ITEM_CODE,
SUM(NVL(B.QUANTITY_ISSUE, 0)) RET_IN
FROM MATERIAL_MOVEMENT_HEADER A,
MATERIAL_MOVEMENT_DETAIL B
WHERE A.SLIP_NO = B.SLIP_NO AND
A.SLIP_DATE BETWEEN '01-JAN-2006' AND
'31-DEC-2006'
GROUP BY B.TO_JOB_CODE, B.ITEM_CODE) H,
(SELECT MRN_HEADER.JOB_CODE,
MRN_DETAIL.ITEM_CODE,
SUM(NVL(MRN_DETAIL.ISSUED_QTY, 0))
ISS_QTY
FROM MRN_HEADER, MRN_DETAIL
WHERE MRN_HEADER.MRN_NO = MRN_DETAIL.MRN_NO AND
MRN_HEADER.MRN_DATE BETWEEN
'01-JAN-2006' AND '31-DEC-2006'
GROUP BY MRN_HEADER.JOB_CODE,
MRN_DETAIL.ITEM_CODE) E,
(SELECT B.JOB_CODE, B.ITEM_CODE,
SUM(NVL(B.QUANTITY_ISSUE, 0)) RET_OUT
FROM MATERIAL_MOVEMENT_HEADER A,
MATERIAL_MOVEMENT_DETAIL B
WHERE A.SLIP_NO = B.SLIP_NO AND
A.SLIP_DATE BETWEEN '01-JAN-2006' AND
'31-DEC-2006'
GROUP BY B.JOB_CODE, B.ITEM_CODE) I
WHERE A.ALT_ITEM_CODE = B.ITEM_CODE (+) AND
A.ALT_ITEM_CODE = C.ITEM_CODE (+) AND
A.ALT_ITEM_CODE = D.ITEM_CODE (+) AND
A.ALT_ITEM_CODE = E.ITEM_CODE (+) AND
A.ALT_ITEM_CODE = F.ITEM_CODE (+) AND
A.ALT_ITEM_CODE = G.ITEM_CODE (+) AND
A.ALT_ITEM_CODE = H.ITEM_CODE (+) AND
A.ALT_ITEM_CODE = I.ITEM_CODE (+) AND
B.JOB_CODE = C.JOB_CODE AND
B.JOB_CODE = D.JOB_CODE AND
B.JOB_CODE = E.JOB_CODE AND
B.JOB_CODE = F.TO_JOB_CODE AND
B.JOB_CODE = G.JOB_CODE AND
B.JOB_CODE = H.TO_JOB_CODE AND
B.JOB_CODE = I.JOB_CODE AND
A.ALT_ITEM_CODE = 'BOSNVL0004-006-002';
regards, -
Need a SQL Query (URGENT)
Hi Folks,
I have 2 tables, in which the 1st one has 200 columns and 2 table had 2 columns.. There is one common column for both the tables, but there is little change in schema of the tables...The common col in 2nd table is a primary key but the same column in the 1st table is a ordinary one..The data type for the common column is same...
Now i need to write a query to select 199columns(except the common column)from the 1st table and the other column(2nd col)other than the common column frm the 2nd table for "table1.commoncolumn=table2.commoncolumn"......
I had tried the natural join but its nt working in my informix sql database....I also tried by explicitly mentioning column names like "select column1,column2....column199,table2.column2 from table1,table2 where table1.commoncolumn=table2.commoncolumn", but its having a severe performance impact.......
Can some please suggest a query for the above one?? Thankx in advance..Please gimme possible solutions & suggestions regarding the above query....
The informix z forum very slow...The problem is, you labeled your questions badly. As this is a forum of volunteers people tend to react badly to the use of the word "urgent" in the subject line. Nobody's question matters more than anybody else's. In fact some regulars won't answer questions with "urgent" in the strapline as a matter of principle.
Then when we get to actually read your question it turns out to be a question about Informix. I guess not many people here use Informix so your potential pool of responders is pretty small (for instance I'm not even sure how to spell it).
It's not our fault the Informix forums are so lame.
Anyway, what I suggest is you repost your question with a new title: (Off topic) Need help with an INFORMIX query.
At least that will attract people who might be able to answer your question. Then you need to include the actual query you're running and all the supporting details necessary for people to understand the nature of the performance impact.
You need to ask the right people and you need to ask the right question. This is standard etiquette (and indeed common sense) regardless of which forum you're using.
Cheers, APC
Blog : http://radiofreetooting.blogspot.com/ -
Access SQL Query Problem - Pls help
Hi,
I'm connecting to an Access database and have a query which looks somehting like this:
SELECT Accept.ACCEPT_NO,
Accept.CURRENCY,
Accept.INT_RATE,
Accept.F_AMOUNT,
Accept.DEALER,
Accept.MATURITY,
Accept.START_DATE,
Accept.DEAL_DATE,
Accept.DEALTICKET,
Accept.BANK_NAME,
Accept.CALC_DAYS,
"2001/11/22" AS CurrentDate
FROM Accept;
It works fine without the line with CurrentDate so i'm sure something's wrong there. What i want to do is set CurrentDate as a constant ("2001/11/22") i dont have any experience with Access so any help you could give me would be greatly appreciated.
Thanx in advance.I was able to successfully query an access 97 database using the following SQL:
String sql = "SELECT emp.emp_fname, emp.emp_lname, '2001/11/22' AS CurrentDate FROM emp";don't know why your's wouldn't work. Was there a SQLException? Or are you trying to get it to work using the Access SQL editor?
Jamie -
I would be thankful if anyone could please advise on the sql question as follows:
id1,dept1,JOHN,12-12-1991
id2,dept1,JOHN,12-12-1992
id3,dept1,JOHN,12-12-1993
id4,dept1,SMITH,11-10-1994
id5,dept1,SMITH,12-12-1995
id6,dept1,SMITH,12-12-1996
id7,dept1,CHRIS,07-07-1997
id8,dept1,CHRIS,12-12-1998
I need a query to get the the data when a particular employee was replaced
as follows:
name,date_replaced
JOHN,11-10-1993
SMITH,07-07-1997
CHRIS,null
Any suggestions are most welcome.1 select distinct name, last_value(NextHired) over (ORDER BY dept,name)
2 from
3 (with emp as
4 (select 'id1' id,
5 'dept1' dept,
6 'JOHN' name,
7 to_date('12-12-1991' ,'DD-MM-YYYY') hiredate from dual
8 union
9 select 'id2','dept1','JOHN',to_date('12-12-1992' ,'DD-MM-YYYY') from dual
10 union
11 select 'id3','dept1','JOHN',to_date('12-12-1993' ,'DD-MM-YYYY') from dual
12 union
13 select 'id4','dept1','SMITH',to_date('11-10-1994','DD-MM-YYYY') from dual
14 union
15 select 'id5','dept1','SMITH',to_date('12-12-1995','DD-MM-YYYY') from dual
16 union
17 select 'id6','dept1','SMITH',to_date('12-12-1996','DD-MM-YYYY') from dual
18 union
19 select 'id7','dept1','CHRIS',to_date('07-07-1997','DD-MM-YYYY') from dual
20 union
21 select 'id8','dept1','CHRIS',to_date('12-12-1998','DD-MM-YYYY') from dual)
22 select id,name, dept,lead (hiredate,1) OVER (ORDER BY hiredate) AS NextHired
23 from emp
24 order by id, dept)
25* order by last_value(NextHired) over (ORDER BY dept,name)
SQL> /
JOHN 11/10/94
SMITH 07/07/97
CHRIS
SQL> Nicolas.
Message was edited by:
N. Gasparotto
Hmm, rajeevm, you wrote JOHN,11-10-1993, but it seems it's a mistake... isn't it ? -
SQL QUERY, URGENT PLEASE HELP .....
Hi,
There is a table which stores the sales record, weekly basis.
For example
WEEK______ ITEMNO______SALES______QTY
200201_____10001______10,000______50
200202_____10001______18,000______55
200230_____10001______55,000_____330
Now the report should display the week nos and a Cumulative average.
like
ITEM NO - 10001
WEEKNO____WK-AVG____13WK-AVG____26WK-AVG____52WK-AVG
200201
200202
200203
200230
The WK-AVG is calculated for that perticular (weeks sales /weeks qty) but for 13WK-AVG,26-AVG and 52WK-AVG , The calculationis the (cumulative of last 13 week sales /cumulative of last 13 wk qty)
for example at week 200230 the 13WK-AVG should be
(cumulative sales from week 200218 to 200230 / cumulative qty from week 200218 to 200230 )
the same hold good for 26WK-AVG AND 52WK-AVG. Please suggest me how to do it . This is very urgent . Please help me .
Thanks
FerozFeroz,
One way is to use subselects. E.g.,
SELECT WK_AVG, 13WK_AVG, 26WK_AVG, 56WK_AVG FROM
(SELECT (SALES/QTY) AS WK_AVG FROM TABLE WHERE ITEMNO=x AND WEEK = ...),
(SELECT (SUM(SALES)/SUM(QTY)) AS 13WK_AVG WHERE ITEMNO=X AND WEEK > Y AND WEEK <= Z),
hope this helps.
regards,
Stewart -
SQL query urgent helps needed!!!
Hi all,
I got the following query :-
SELECT RH.REQUEST_NUMBER,
MSIK.CONCATENATED_SEGMENTS,
MSIK.DESCRIPTION,
RL.FROM_SUBINVENTORY_CODE,
RL.UOM_CODE,
RL.QUANTITY,
PP.FULL_NAME ,
M.TRANSACTION_QUANTITY
FROM MTL_TXN_REQUEST_HEADERS RH,
MTL_TXN_REQUEST_LINES RL,
MTL_SYSTEM_ITEMS_KFV MSIK,
FND_USER FU,
PER_PEOPLE_V7 PP,
( SELECT MSIK2.CONCATENATED_SEGMENTS, MOQ.SUBINVENTORY_CODE, SUM(MOQ.TRANSACTION_QUANTITY)
FROM MTL_ONHAND_QUANTITIES MOQ, MTL_SYSTEM_ITEMS_KFV MSIK2
WHERE MSIK2.INVENTORY_ITEM_ID = MOQ.INVENTORY_ITEM_ID
AND MSIK2.ORGANIZATION_ID = 8
AND MOQ.SUBINVENTORY_CODE LIKE 'ST%'
GROUP BY MSIK2.CONCATENATED_SEGMENTS, MOQ.SUBINVENTORY_CODE) M
WHERE
RH.HEADER_STATUS IN(3,7,8)
AND RH.MOVE_ORDER_TYPE IN(1,2)
and rh.header_id = rl.header_id
AND MSIK.INVENTORY_ITEM_ID = RL.INVENTORY_ITEM_ID
AND MSIK.ORGANIZATION_ID = 8
AND RL.FROM_SUBINVENTORY_CODE LIKE 'ST%'
AND RH.CREATED_BY = FU.USER_ID
AND FU.EMPLOYEE_ID = PP.PERSON_ID
However, when I try to run I got the invalid column for m.transaction_quantity ??? why? does it b'cos of the group sum that I used ?
My intention of this query to display the sum of total qty from the mtl_onhand_quantities table.
Please helps.
Thanks.
Rgds
Limsorry if its too late.....
my guess is alias the SUM(MOQ.TRANSACTION_QUANTITY) in the sub-query table (M) as TRANSACTION_QUANTITY.
-------- code snippet---------
FND_USER FU,
PER_PEOPLE_V7 PP,
( SELECT MSIK2.CONCATENATED_SEGMENTS, MOQ.SUBINVENTORY_CODE,
SUM(MOQ.TRANSACTION_QUANTITY) TRANSACTION_QUANTITY <------------------------------------This is important
FROM MTL_ONHAND_QUANTITIES MOQ, MTL_SYSTEM_ITEMS_KFV MSIK2
WHERE MSIK2.INVENTORY_ITEM_ID = MOQ.INVENTORY_ITEM_ID
AND MSIK2.ORGANIZATION_ID = 8
AND MOQ.SUBINVENTORY_CODE LIKE 'ST%'
GROUP BY MSIK2.CONCATENATED_SEGMENTS, MOQ.SUBINVENTORY_CODE) M
WHERE
RH.HEADER_STATUS IN(3,7,8)
AND RH.MOVE_ORDER_TYPE IN(1,2)
--------------code snippet ends------------------------
hope this helps, -
Cancellation of iCloud account query - URGENT PLS
I received an email purportedly from 2015 Apple Inc. 31-23, rue Sainte Zithe,
L-2763 Luxembourg. email address Apple/iCloud Genius Care <[email protected]>
saying that my account will be terminated unless I verify my Apple account and the link takes me
to a form that does look like an Apple form with some of my correct information filled in. Before I
fill it in completely which includes my credit card info, I would like someone to please let me know
if this is legitimate.
Many thanks.
EllenEllen ..
It's phishing. Do not respond. It's not legitimate.
Please forward the email to: [email protected]
Never reply to an email from: "Your AppleCare support center" or "Apple / iCloud Genius Care".
Apple will never send you an email asking you to verify your Apple ID credentials or your credit card information.
If you ever receive an email such as this again. do not reply, do not call. Forward the email to the reportphisihing email address above then delete that email.
Identifying fraudulent "phishing" email -
Need a SQL query(Pls Its urgent)
Hi,
I want a SQL query for the foll..
Details r below..
Table AFPFTRAN
BU TRansactiondate Amt
13202 10-04-05 10,000
13203 11-05-05 20,000
13202 20-04-05 5,000
Table AFGENCOD
BU Clerk Name Clerk Code
13202 Amit TFBG
13203 Anand TFMG
I want a query to get data as below..
Tr Date TFBG TFMG
Apr 15,000 0
May 0 20,000
JUn 0 0
Jul 0 0
Aug
Sep
Aug
Nov
DEc
Jan
Feb
Mar
I want this to achieve using a single query...?How can I achive this?
Pls give the sol...
Adios...
Prashanth DeshmukhDoes it look like you need ?
SQL> select * from t;
BU TDATE AMT
13202 10.04.05 10000
13203 11.05.05 20000
13202 20.04.05 5000
SQL> select * from t1;
BU NAME CODE
13202 Amit TFBG
13203 Anand TFMG
SQL> SELECT pivot_month.mname, tops.TFBG, tops.TFMG
2 from
3 (
4 select to_char(t.tdate,'MM') month_no,
5 sum(decode(t1.code,'TFBG',t.amt,0)) TFBG,
6 sum(decode(t1.code,'TFMG',t.amt,0)) TFMG
7 from t1, t
8 where t.bu=t1.bu
9 and to_char(t.tdate,'yyyy') = 2005
10 GROUP BY t1.code, to_char(t.tdate,'MM')
11 ) tops,
12 (select rownum mn, to_char(to_date(rownum,'MM'),'MON') mname,
13 case when rownum between 1 and 3 then rownum + 9
14 else rownum - 3 end rn
15 from dict where rownum < 13) pivot_month
16 where pivot_month.mn = tops.month_no (+)
17 order by pivot_month.rn
18 /
MNA TFBG TFMG
APR 15000 0
MAY 0 20000
JUN
JUL
AUG
SEP
OCT
NOV
DEC
JAN
FEB
MAR
12 rows selected.Rgds.
Maybe you are looking for
-
Problem in sorting numeric string
hii i have created one method using comparator and passed a list with list of strings as argument to sort method of Collections class.The string ,which is combined a string and numeric value for example A1,A2,A11,A3 .....So i wanted the result as A1,
-
Hi Guys! I am an Web Admin with windows background now need to work in Linux and OAS background. Need groudup help on Linux please, good links? Perhaps a cheat sheet would be great to start? Thanks
-
Virtualbox and Windows 7 clones - registration
I have created a virtual machine using virtualbox. I purchased a version of Windows 7 to support this virtual machine since I do experimentation with the "base" installation of a prodcut I support. I always go backto my original version (clone) of my
-
Problems App-v sequencing snagIT v11
Hi Guys, I'm attempting to sequence SnagIt 11 with app-v 4.6 to deploy it to a Windows 7 PC using SCCM 2012. During sequencing when I attempt to launch snagIT I get an error "Unable to start snagpriv.exe" I have checked the net and have found a solut
-
Canadian Multilingual Keyboard in the USA
Hi there, Does anyone know if canadian multilingual keyboards are available in the US ? The store proposes US, spanish or french layout, but not the canadian one. Thanks