Give query for
Hi all,
i am searching for an queryby using MS Access.I have a table called stock.
Stock Table:
stock_id comp_id prod_id item_id Quantity module
1 100 200 300 10 P
2 101 200 300 20 P
3 100 200 300 5 S
4 101 200 300 4 S
From this table I want to group by comp_id,prod_id and item_id by (sum(quantity) whose module='P' -
sum(quantity) whose module='S'). the result what I am expecting is given below:
comp_id prod_id item_id Quantity
100 200 300 5
101 200 300 16
So please go through and send me the single query for MS-Access.
Edited by: IRALALVIPIN on Oct 4, 2009 10:39 PM
So please find an SQL or MS Access forum and maybe they will do your work for you. This, however, has nothing to do with Java and we wouldn't do your work for you, anyway.
Similar Messages
-
Query for an ALERT to give items that haven't sold in 60 days
To the Experts.
Can someone help me with a query for an ALERT. I need items that haven't sold in the last 60 days?Try this query.
select max(t1.docdate) as [Last Inv Date], t0.itemcode, t0.dscription
from inv1 t0 inner join oinv t1 on t0.docentry = t1.docentry
where t1.doctype = 'I'
group by t0.itemcode, t0.dscription
having max(t1.docdate) <= getdate() - 60
order by t0.itemcode
The value getdate() is today, so getdate() - 60 will move the filter date back 60 days. This looks at A/R Invoices and only Items type documents.
I hope this helps.
Ross Unger - Third Wave Business Systems -
How to use the same POWL query for multiple users
Hello,
I have defined a POWL query which executes properly. But if I map the same POWL query to 2 portal users and the 2 portal users try to access the same page simultaneously then it gives an error message to one of the users that
"Query 'ABC' is already open in another session."
where 'ABC' is the query name.
Can you please tell me how to use the same POWL query for multiple users ?
A fast reply would be highly appreciated.
Thanks and Regards,
SandhyaBatch processing usually involves using actions you have recorded. In Action you can insert Path that can be used during processing documents. Path have some size so you may want to only process document that have the same size. Look in the Actions Palette fly-out menu for insert path. It inserts|records the current document work path into the action being worked on and when the action is played it inserts the path into the document as the current work path..
-
QUERY FOR CUSTOMERS FULL DEBIT AND CREDIT WITH CLOSING BALANCE
Hi Friends,
I need query for CUSTOMERS FULL DEBIT AND CREDIT WITH CLOSING BALANCE for selection criteria from date and to date.
I know the Trial Balance Report will sort out this issue... but i need routeday wise report
1. Business Partner Master Data - i created one UDF field called U_Routeday (MONDAY, TUESDAY, WEDNESDAY,THURSDAY,FRIDAY)
2. The query should be like selection criteria
- Routeday [%0]
- Posting Date [%1]
- Posting Date [%2]
CardCode
Debit
Credit
Balance
D10503
25031.50
24711.50
2962.00
D10641
5466.00
7460.00
285.00
D10642
2866.00
142.00
give any helpful query ASAP... Thanks in advanceHi,
Try this query:
Declare
@fromdate as datetime
Declare
@Todate as datetime
Declare
@Code as nvarchar(25)
set
@fromdate = ( select min(Ta.[RefDate]) from OJDT ta where
Ta.[RefDate] >= [%0])
set
@Todate = ( select max(Tb.[RefDate]) from OJDT tb where Tb.[RefDate]
<= [%1])
set
@code = (select max(Tc.[ShortName]) from JDT1 tC where Tc.[ShortName]
= [%2])
SELECT
[Name] as AcctName, [Jan]= sum([1]), [Feb]= sum([2]), [Mar]=
sum([3]), [Apr]= sum([4]), [May]= sum([5]), [June]= sum([6]),
[July]= sum([7]), [Aug]= sum([8]), [Sept]= sum([9]), [Oct]=
sum([10]), [Nov]= sum([11]), [Dec]= sum([12]), total = sum
(isnull([1],0)+ isnull([2],0) + isnull([3],0) + isnull([4],0) +
isnull([5],0) + isnull([6],0) + isnull([7],0) + isnull([8],0) +
isnull([9],0)+ isnull([10],0) + isnull([11],0) + isnull([12],0))
from
(SELECT
T0.[ShortName] as Name, sum(T0.[Debit]-T0.[Credit]) as T,
month(T2.[RefDate]) as month FROM JDT1 T0 INNER JOIN OACT T1 ON
T0.Account = T1.AcctCode INNER JOIN OJDT T2 ON T0.TransId =
T2.TransId WHERE T2.[RefDate] between @fromdate and @todate and
T0.[ShortName] = @code GROUP BY T0.[ShortName],T2.[RefDate] ) S
Pivot
(sum(T)
For Month IN ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12])) P
group
by [Name],[1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12]
Let me know your result.
Thanks & Regards,
Nagarajan -
Re:Query for Stock Statement for a particular item..!!!!
Dear SAP Experts,
I need a stock statement query for a particular item which contains:
1.ItemCode
2.Item Description
3.Item Price
4.Opening
5.Receipts
6.Issues
7.Closing
8. Value
The selection criteria are:
1.Warehouse code
2.Item Name
3.Posting Date
Plz give me a good solution for this issue.
With Regards,
RevathyCheck this
Declare @FromDate Datetime
Declare @ToDate Datetime
set @FromDate =
(Select min(S0.Docdate) from OINM S0 where S0.Docdate >='[%0]')
set @ToDate =
(Select max(S1.Docdate) from OINM S1 where S1.Docdate <='[%1]')
select * from
SELECT T0.itemcode,
min(T0.Dscription) as 'Item Description',
min(B1.ItmsGrpNam) as 'Item Group', W1.Whscode, C1.Location,
(isnull((
Select sum(isnull(inqty,0))
from OINM O1
where O1.itemcode=T1.itemcode
and O1.Warehouse=W1.Whscode
and O1.docdate<@FromDate ),0)-
isnull((
Select sum(isnull(outqty,0))
from OINM O1
where O1.itemcode=T1.itemcode
and O1.Warehouse=W1.Whscode
and O1.docdate<@FromDate),0)
) as [Opening Stock],
isnull((
Select sum(isnull(inqty,0))
from OINM O1
where O1.itemcode=T1.itemcode
and O1.Warehouse=W1.Whscode
and O1.docdate>=@FromDate
and O1.docdate<=@ToDate and O1.inqty>0
and O1.transtype in (20,18)),0
) as [Purchase Quantity],
isnull((
Select sum(isnull(outqty,0))
from OINM O1
where O1.itemcode=T1.itemcode and O1.Warehouse=W1.Whscode
and O1.docdate>=@FromDate and O1.docdate<=@ToDate
and O1.outqty>0 and O1.transtype in (21,19)),0
) as [Purchase Return Quantity],
isnull((
Select sum(isnull(outqty,0))
from OINM O1
where O1.itemcode=T1.itemcode and O1.Warehouse=W1.Whscode
and O1.docdate>=@FromDate and O1.docdate<=@ToDate and O1.outqty>0
and O1.transtype in (13,15)),0
) as [sale Quatity],
(isnull
Select sum(isnull(inqty,0))
from OINM O1
where O1.itemcode=T1.itemcode and O1.Warehouse=W1.Whscode
and O1.docdate<=@ToDate),0
isnull((
Select sum(isnull(outqty,0))
from OINM O1
where O1.itemcode=T1.itemcode and O1.Warehouse=W1.Whscode
and O1.docdate<=@ToDate),0)
) as [Closing Stock]
FROM OINM T0
INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode
INNER JOIN OITW T2 ON T1.ItemCode = T2.ItemCode
INNER JOIN OITB B1 ON T1.ItmsGrpCod=B1.ItmsGrpCod
INNER JOIN OWHS W1 ON T2.WhsCode = W1.WhsCode
INNER JOIN OLCT C1 ON W1.Location=C1.Code
Group by T1.itemcode, T0.Itemcode, W1.WhsCode, C1.Location
) a
where (a.[Opening Stock]
+a.[Purchase Quantity]
+ a.[Purchase Return Quantity]
+a.[sale Quatity]+a.[Closing Stock]
) !=0
Regards,
Bala -
Hello Gurus-
I am trying to build a query for Aging report, and would like to include something like this:
Customer-Reference-Payment terms-Due date-Current-31-60days-61-90days-91-120days-over120days-toatal amount.
I have an infoset which includes BSID, KNA1, KNB1. I have maintained local fields:
Due Date = Baseline date + cash discount days
Statement Date = My input date.
Current = Condition (DUEDTE >= STATDTE - 30) formula (Amount)
31 - 60 Days = Condition (DUEDTE >= STATDTE - 60 AND DUEDTE < STATDTE - 30) formula (Amount)
61 - 90 Days = similar to above
91 - 120 Days = similar to above
Amount = - 1 * (If Debit credit indicator = "H" then "Amount in local currency") otherwise "Amt in Loc.Cur"
Over 120 Days = similar to above
When I enter a statement date of today it works hunky dory...it all looks good...my current column looks good and do the rest. When i want to run this query as of couple of months ago (if today is 12/19/08 and i wanted to run my aging report for 10/31/08) it should give me aging as of my statement date 10/31/08 but it does not. It calculates the total amount as of today. I know because of local field "Amount" where i gave amount in local currency, but how would I tell that it should pick up amount in local currency till the statement date?
Any input in this regards is highly helpful.
Thanks,
RNarayanHi Ram,
On your aging report you want to see invoices which are still not paid (or still open) as of a certain date. This date is "key date". You need to define a variable for key date (which is normally system date if you run today) but it could be a past date.
So key date is let us say Oct 31st (X) and the system date is Dec 19th. When you run the report as of Oct 31st all invoices that are posted prior to Oct 31st (posting date less than X) and are still in BSID will show on your report. There is no issue here.
Let us say an invoice was created on Oct 25th (Y) and was paid on Nov 15th (Z). The clearing date is Z. That means if you run the aging report today this invoice will not show.
But you want to run the report on Oct 31st. This means X is greater than Y but is less than Z.
Clearing date and posting date are part of BSAD. Report run date is the user input and is a variable.
With the above concept and with the help of an ABAP programmer you should be able to solve the problem.
Regards
Sharabh -
How to find the name of query for a given report
Hi All,
I am having the name of a report and i need to find out the name of query for that report . Plz tell me how to find out the name of the query for a given report.
Thanks.
Regards,
Pooja Joshi.Use this FM
RSAQ_DECODE_REPORT_NAME
This FM takes program name as I/P and gives Query Name as O/P.
This FM uses the structure AQADEF to fetch the data.
Hope this helps.
Regards
Vinayak -
How can I get the elapse time for execution of a Query for a session
Hi ,
How can I get the elapse time for execution of a Query for a session?
Example - I have a report based on the procedure ,when the user execute that it takes say 3 min. to return rows.
Is there any possible way to capture this session info. for this particular execution of query along with it's execution elapse time?
Thanks in advance.Hi
You can use the dbms_utility.get_time tool (gives binary_integer type value).
1/ Initialize you time and date of beginning :
v_beginTime := dbms_utility.get_time ;
2/ Run you procedure...
3/ Get end-time with :
v_endTime := dbms_utility.get_time ;
4/ Thus, calculate elapsed time by difference :
v_elapsTime := v_endTime - v_beginTime ;
This will give you time elapsed in of 100th of seconds...
Then you can format you result to give correct print time.
Hope it will help you.
AL -
Problem writing a sql query for a select list based on a static LOV
Hi,
I have the following table...
VALIDATIONS
ID Number (PK)
APP_ID Number
REQUESTED Date
APPROVED Date
VALID_TIL Date
DEPT_ID Number (FK)
I have a search form with the following field item variables...
P11_DEPT_ID (select list based on dynamic LOV from depts table)
P11_VALID (select list based on static Yes/No LOV)
A report on the columns of the Validations table is shown based on the values in the search form. So far, my sql query for the report is...
SELECT v.APP_ID,
v.REQUESTED,
v.APPROVED,
v.VALID_TIL,
d.DEPT
FROM DEPTS d, VALIDATIONS v
WHERE d.DEPT_ID = v.DEPT_ID(+)
AND (d.DEPT_ID = :P11_DEPT_ID OR :P11_DEPT_ID = -1)
This query works so far. My problem is that I don't know how to do a search based on the P11_VALID item - if 'yes' is selected, then the VALID_TIL date is still valid. If 'no' is selected then the VALID_TIL date has passed.
Can anyone help me to extend my query to include this situation?
Thanks.Hello !
Let's have a look at my example:create table test
id number
,valid_til date
insert into test values( 1, sysdate-3 );
insert into test values( 2, sysdate-2 );
insert into test values( 3, sysdate-1 );
insert into test values( 4, sysdate );
insert into test values( 5, sysdate+1 );
insert into test values( 6, sysdate+2 );
commit;
select * from test;
def til=yes
select *
from test
where decode(sign(trunc(valid_til)-trunc(sysdate)),1,1,0,1,-1)
=decode('&til','yes',1,-1);
def til=no
select *
from test
where decode(sign(trunc(valid_til)-trunc(sysdate)),1,1,0,1,-1)
=decode('&til','yes',1,-1);
drop table test; It's working fine, I've tested it.
The above changes to my first idea I did because of time portion of the DATE datatype in Oracle and therefore the wrong result for today.
For understandings:
1.) TRUNC removes the time part of DATE
2.) The difference of to date-values is the number of days between.
3.) SIGN is the mathematical function and gives -1,0 or +1 according to an negative, zero or positiv argument.
4.) DECODE is like an IF.
Inspect your LOV for the returning values. According to my example they shoul be 'yes' and 'no'. If your values are different, you may have to modify the DECODE.
Good luck,
Heinz -
Help needed in query for Materialized View
Hi,
I want to create a materialized view which has some precalcultaed values.
I have four dimension tables out of which one is a Time Dimension table with levels as Year->Quarter->Month.
The precalculations are the moving averages and cummulative values of Sales Amt on the dimension values over a period of 4 Months.
The dimension tables are Clients, Products, Channel, Time.
Fact Table is Sales_Fact which will have the sales amount for different members of the dimension.
Since my fact table is very huge, i want to create a materialized view where i could store the required calculated measures, here Moving Average of Sales Amt for each Client, Product, Channel dimensions over a period of 4 Months.
Can anybody help with writing the query for this..Any help in this regard will be appreciated..
Please give me suggestions for this..Check this link.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14223/aggreg.htm#sthref1612
Regards
Raj -
Alert message(Query) for a Production order?
Hi Experts,
I want to get an alert message for the production order doucument based on the due date of it. The user must get the alert a one day before the duedate of the document. How to write the Query for it? Urgent ,waiting for earliest reply.
Regards ,
Magesh.Create a Formatted Seach with the following Query
SELECT T0.DocNum AS 'Document Number', T0.CreateDate AS 'Creation Date', T0.DueDate AS 'Due Date'
FROM [dbo].[OWOR] T0 WHERE DATEDIFF(Day,GetDate(),T0.DueDate) = 1
Then, Create an Alert from Adminis..> Alerts Management and Give a Name, Click Open Saved Query, Select the query you saved, Tick the Int. check box against the user who gets the Alert. Check Active. Select Frequency.
Good luck
Suda -
Count() function throws error in EQL query for metric
Hi
I am trying to use count function in EQL query for Metric Bar to show the number of occurrences of a record.
When the record type doesn't exist i expect the function to return count as 0. Instead the function throws a runtime exception and the whole Metric Bar portlet fails, with error No Results Available. Even though other components in the metric bar have valid results.
2013-02-21 13:03:51,216 WARN [MetricsBarQueryProcessor] The EQL query does not return any results.
2013-02-21 13:03:51,216 ERROR [MetricsBarQueryProcessor] The EQL query does not return any results.
2013-02-21 13:03:51,216 WARN [MetricsBarResultsProcessor] No statement results to process.
The EQL query i am using is
RETURN NUMBER_OCCURS AS SELECT COUNT(EMP_ID) AS NUMBER_OCCURS where EMP_NAME IS NOT NULL group;
I tried using COALESCE but that doesn't help.
Can some one please suggest a workaround to this?Srikanth,
Two statements are used here because the original question was pertaining to the null set (where there are employees in the nav state but no employees that fit the special analytics criteria in the navigation state). The question/answer has nothing to do with what is in the COUNT parentheses clause as Counting a null set will always give you NULL, not 0, no matter what you put in there.
What we're really doing, in the second part of the query, is writing a query over a set of data that is not the null set (i.e. the current navigation state). This allows the 0 value to come through in the case where the first analytics statement is evaluated over a null set of records. If there were truly no records in the navigation state, this too would return a null set and not zero.
Hope that makes sense, feel free to respond (either on here or offline) if it's unclear.
Regards,
Patrick Rafferty
http://branchbird.com -
Select Query for smart form-invoice
Hi Folks,
I have to fetch the following fields as per the requirement for desiging a invoice smartform.I had copied lb_bill_invoice smartform into z format.
Can anyone here please give me the select query for the same.
fields to fetched are as follows:-
1.vbrp-arktx,
2.vbrp-fkimg,
3.konv-kbetr with respect to vbrk-knumv
4.konv-kwert.
And also what all I have to give in format interface and global definitions of the smartform.
please help me in this regard.
Points will be given.
K.Kiran.Hi,
declare the variables V_arktx(40) and v_Qty like vbrp-fkimp and other varaibles for Kbetr, kwert, knumv on the global definitions.
select single arktx fkimg into (v_arktx, v_qty) from vbrp
where vbeln = LBBIL_IT_REFPURORD-BIL_NUMBER.
select single knumv into v_knumv from vbrk where where vbeln = LBBIL_IT_REFPURORD-BIL_NUMBER.
this select has to fire in the item level and in the loop.
so have to write in the correct place.
select kbetr kwert into (v_kbetr, v_kwert) from konv
where where knumv = v_knumv and kposn = LBBIL_IT_REFPURORD-ITM_NUMBER.
regards,
anji -
Select query for fields in selection screen
SELECT * FROM hrus_d2
INTO TABLE ta_list
WHERE us_name IN subs_obj
and begdat in date_ran.
and enddat in date_ran
How can I rewrite the above query for high and low ranges of date_ran field in condition? It doesn't allow in operator with date_ran-low.Can u please help me outHi
rahul
SELECT *
FROM hrus_d2
INTO TABLE ta_list
WHERE us_name IN subs_obj
and begdat = date_ran-low
and enddat = date_ran -high.
u can write like this or i amnot getting why u r expliciting this date u can give directly as
SELECT *
FROM hrus_d2
INTO TABLE ta_list
WHERE us_name IN subs_obj
date in date_ran.
plzz reward if i am usefull to u in any way.. plzz dont forget to reward -
[Oracle 8i] Query for N rows by column value?
I was just wondering if what I want to do is possible within my query (rather than programmatically)...
I want to return the N most recent records for each unique value in a particular column.
Here's a sample table:
CREATE TABLE orders
( order_no numeric(10)
part_no varchar(5)
close_date date
order_qty numeric(10)
scrap_qty numeric(10)
CONSTRAINT order_pk PRIMARY KEY (order_no)
);And some sample data....
INSERT INTO orders VALUES
(0000012345,'ABC-1',TO_DATE('01-01-2010','mm-dd-yyyy'),10,1);
INSERT INTO orders VALUES
(0000013498,'ABC-1',TO_DATE('01-05-2010','mm-dd-yyyy'),12,2);
INSERT INTO orders VALUES
(0000033452,'ABC-1',TO_DATE('01-10-2010','mm-dd-yyyy'),5,0);
INSERT INTO orders VALUES
(0000001468,'ABC-1',TO_DATE('01-15-2010','mm-dd-yyyy'),15,1);
INSERT INTO orders VALUES
(0000022349,'BR723',TO_DATE('01-03-2010','mm-dd-yyyy'),8,1);
INSERT INTO orders VALUES
(0000069581,'BR723',TO_DATE('01-05-2010','mm-dd-yyyy'),5,0);
INSERT INTO orders VALUES
(0000436721,'BR723',TO_DATE('01-10-2010','mm-dd-yyyy'),14,1);
INSERT INTO orders VALUES
(0000213446,'A5001',TO_DATE('01-06-2010','mm-dd-yyyy'),5,1);
INSERT INTO orders VALUES
(0000327987,'A5001',TO_DATE('01-08-2010','mm-dd-yyyy'),5,0);
INSERT INTO orders VALUES
(0000041353,'A5001',TO_DATE('01-14-2010','mm-dd-yyyy'),12,1);
INSERT INTO orders VALUES
(0000011241,'A5001',TO_DATE('01-15-2010','mm-dd-yyyy'),5,1);In this example, what I want to return are the 2 most recent orders (by close_date) for each part number.
Here is a table with the results I want to get, based on the scenario above:
order_no part_no close_date order_qty scrap_qty
0000001468 'ABC-1' '01-15-2010' 15 1
0000033452 'ABC-1' '01-10-2010' 5 0
0000436721 'BR723' '01-10-2010' 14 1
0000069581 'BR723' '01-05-2010' 5 0
0000011241 'A5001' '01-15-2010' 5 1
0000041353 'A5001' '01-14-2010' 12 1Is it possible to write a query to get these results, or am I going to have to query for all available data, and find the 2 most recent rows programmatically?
Thanks in advance!Hi,
user11033437 wrote:
I'm going to test that out right now. I think if it works, I may need to use dense_rank() rather than rank(), because it is possible that two orders for the same part number could have the same close date, and according to what I've looked up on the rank() and dense_rank() functions, rank() can give non-consecutive results if the values are the same.What's wrong with non-consecutive values?
Use RANK, DENSE_RANK or ROW_NUMBER depending on what you want.
For example; say a certain part has been ordered 8 times:
3 times with close_date January 29, 2010 (all at exactly the same time),
4 times with close_date January 28, 2010 (all at exactly the same time), and
1 time with close_date January 27, 2010.
If you ask for the last 2 rows:
RANK will give you the 3 rows from January 29. (All 3 have an equal claim to being in the top 2.)
DENSE_RANK will give you the 7 rows from January 28-29 (the last two values , regardless of how many rows have them).
ROW_NUMBER will give you 2 rows from January 29. (Which 2? It's arbitrary unless you add a tie-breaker to the ORDER BY clause.)
All these functions are available in Oracle 8.1.
Maybe you are looking for
-
Windows 8 RTM won't boot on W520
Hi, I have the W520 (configuration bellow). When I install Windows 8 as a dual boot along with Windows 7, the installation process is fine, the system starts and everything seems to work until the first reboot. Then the boot process freezes shortly a
-
Has anyone found the correct driver for Canon MF4018 printer?
I have tried installing all of the available drivers including MF4010 which other users have reported works- I keep getting Error-50 and cannot print anything. If anyone has used any driver for this printer that is compatible with my macbook pro - th
-
When i placed a video from my camera roll on my ipad to my keynote presentation on my ipad I lost sound how do I get sound?
-
We have a mysterious problem here. In out ABAP system we had a WebService created. With "New - Web Service Client" we created a web service client on the java side for that one and we were able to invoke it. We had to recreate this Web service due to
-
Video 100% Audio 0%
I've an interesting problem. I can do audio chat with no problem at all. When I try a video chat I get pictures at both ends but no audio. Looking at the Connection Doctor shows a 0% Audio quality. Both ends have 2Mbps DSL with 384 Kbps upload speed.