Group by function use
I want to get an output using group by function of there is no data in the table to display a particular value
for eg:
SELECT TRUNC(updated_date) DATE1 , COUNT(1) COUNT FROM table
where TRUNC(updated_date) >=TRUNC(SYSDATE-18) AND TRUNC(updated_date) <=TRUNC(SYSDATE)
GROUP BY TRUNC(updated_date)
ORDER BY TRUNC(updated_date) DESC;
DATE1 COUNT
6/16/2012 14208
6/15/2012 307825
6/14/2012 172988
6/6/2012 138790
6/5/2012 167562
6/4/2012 51870
6/2/2012 130582
6/1/2012 239806
But i need the missed out date i.e 6/3/2012 - 0, 6/7/2012 - 0 to be displayed since there is no data on the repective dates.
Please post here {forum:id=75}
Similar Messages
-
I want to get an output using group by function of there is no data in the table to display a particular value
for eg:
SELECT TRUNC(updated_date) DATE1 , COUNT(1) COUNT FROM table
where TRUNC(updated_date) >=TRUNC(SYSDATE-18) AND TRUNC(updated_date) <=TRUNC(SYSDATE)
GROUP BY TRUNC(updated_date)
ORDER BY TRUNC(updated_date) DESC;
DATE1 COUNT
6/16/2012 14208
6/15/2012 307825
6/14/2012 172988
6/6/2012 138790
6/5/2012 167562
6/4/2012 51870
6/2/2012 130582
6/1/2012 239806
But i need the missed out date i.e 6/3/2012 - 0, 6/7/2012 - 0 to be displayed since there is no data on the repective dates.Hi,
You can only display things that are in a table (or result set, but from now on, I'll just say table), or that can be derived from a table. If you want to display dates that are not in your table, then you have to get them from another table, or derive them from some table.
Some people actually keep tables of possible dates for queries like this. In this case, all you need is a table of the last 19 dates, ending with today. That's easy to derive from dual:
WITH all_dates AS
SELECT TRUNC (SYSDATE) - LEVEL AS date1
, TRUNC (SYSDATE) + 1 - LEVEL AS date2
FROM dual
CONNECT BY LEVEL <= 19
SELECT a.date1
, COUNT (x.updated_date) AS count
FROM all_dates a
LEFT OUTER JOIN table_x x ON x.updated_date >= a.date1
AND x.updated_date < a.date2
GROUP BY a.date1
ORDER BY a.date1
;If you'd care to post CREATE TABLE and INSERT statements for some sample data, and the results you want from that data, then I could test this. -
To fetch data using group by function
Hi Guys,
I am having a table where it holds data with value with zero in one of the column and i need to fetch the records from the table using group by function but to display all the records if zero occurs in my table
for eg
table1
id,customer_name,country
0 sam aus
1 peter ind
1 peter ind
0 samy us
0 rayan nz
if i use select count(*),id from table1 group by id
i will get
count(*),id
3-0
1-2
but wat i need is like below
0 sam aus
0 samy us
0 rayan nz
2 peter ind
whenever zero is occurring i need to display all the records but group by should work for non zero recordsThe simplest way would be to have two queries and UNION them together. For example:
WITH test_data AS
( SELECT 0 AS id, 'sam' AS customer_name, 'aus' AS country FROM DUAL UNION ALL
SELECT 1 AS id, 'peter' AS customer_name, 'ind' AS country FROM DUAL UNION ALL
SELECT 1 AS id, 'peter' AS customer_name, 'ind' AS country FROM DUAL UNION ALL
SELECT 0 AS id, 'samy' AS customer_name, 'us' AS country FROM DUAL UNION ALL
SELECT 0 AS id, 'rayan' AS customer_name, 'nz' AS country FROM DUAL
SELECT cnt
, customer_name
, country
FROM ( SELECT id
, customer_name
, country
, COUNT(*) OVER (PARTITION BY id) AS cnt
, ROW_NUMBER() OVER (PARTITION BY id ORDER BY id) rn
FROM test_data
WHERE id != 0
WHERE rn = 1
UNION
SELECT id
, customer_name
, country
FROM test_data
WHERE id = 0
This gives the following results:
CNT CUSTO COU
0 rayan nz
0 sam aus
0 samy us
2 peter ind -
How to Use a Group by Function
Hi Gurus,
I have Requirment where i need to use the group by function to one column
below is my query , can anyone help how to use the group by for the column OCCASIONALS_QT_STATUS.
below is giving me the error not a group by expression
select distinct source_id,OCCASIONALS_QT_STATUS,
(SELECT sum(head_count)
FROM gen_dcsf_occasionals_count
where OCCASIONALS_QT_STATUS = 'QTS'
and source_id = gdoc.source_id
) OccasionalsQTS,
(SELECT sum(head_count)
FROM gen_dcsf_occasionals_count
where
OCCASIONALS_QT_STATUS = 'NOTQTS'
and source_id = gdoc.source_id
) OccasionalsNOTQTS,
(SELECT sum(head_count)
FROM gen_dcsf_occasionals_count
where
OCCASIONALS_QT_STATUS = 'NTKNWN'
and source_id = gdoc.source_id
) OccasionalsNOTKNWN
from gen_dcsf_occasionals_count gdoc group by OCCASIONALS_QT_STATUS;
any inputs on this is highly appreciable
Thanks in advance909577 wrote:
Hi Gurus,
I have Requirment where i need to use the group by function to one column
below is my query , can anyone help how to use the group by for the column OCCASIONALS_QT_STATUS.
below is giving me the error not a group by expression
select distinct source_id,OCCASIONALS_QT_STATUS,
(SELECT sum(head_count)
FROM gen_dcsf_occasionals_count
where OCCASIONALS_QT_STATUS = 'QTS'
and source_id = gdoc.source_id
) OccasionalsQTS,
(SELECT sum(head_count)
FROM gen_dcsf_occasionals_count
where
OCCASIONALS_QT_STATUS = 'NOTQTS'
and source_id = gdoc.source_id
) OccasionalsNOTQTS,
(SELECT sum(head_count)
FROM gen_dcsf_occasionals_count
where
OCCASIONALS_QT_STATUS = 'NTKNWN'
and source_id = gdoc.source_id
) OccasionalsNOTKNWN
from gen_dcsf_occasionals_count gdoc group by OCCASIONALS_QT_STATUS;
any inputs on this is highly appreciable
Thanks in advanceFor your own sanity, you should format your code to make it more readable
For the sanity of those from whom you seek help, you should preserve that formatting with the code tags:
select
distinct source_id,
OCCASIONALS_QT_STATUS,
(SELECT
sum(head_count)
FROM
gen_dcsf_occasionals_count
where
OCCASIONALS_QT_STATUS = 'QTS' and
source_id = gdoc.source_id
) OccasionalsQTS,
(SELECT
sum(head_count)
FROM
gen_dcsf_occasionals_count
where
OCCASIONALS_QT_STATUS = 'NOTQTS' and
source_id = gdoc.source_id
) OccasionalsNOTQTS,
(SELECT
sum(head_count)
FROM
gen_dcsf_occasionals_count
where
OCCASIONALS_QT_STATUS = 'NTKNWN' and
source_id = gdoc.source_id
) OccasionalsNOTKNWN
from
gen_dcsf_occasionals_count gdoc
group by
OCCASIONALS_QT_STATUS; -
Can i use Lead function with Group by function
I could use this query and get right ouput since i define product id =2000
select product_id, order_date,
lead (order_date,1) over (ORDER BY order_date) AS next_order_date
from orders
where product_id = 2000;
But can i run this query by Group by Function
for example
select product_id, order_date,
lead (order_date,1) over (ORDER BY order_date) AS next_order_date
from orders
group by product_id ;
since data would be like and i need
Product_id order Date
2000 1-jan-09
2000 21-jan-09
3000 13-jan-09
3000 15-jan-09
4000 18-jan-09
4000 19-jan-09
output would be like for eg
Product_id order Date Next_date
2000 1-jan-09 21-jan-09
3000 13-jan-09 15-jan-09
4000 18-jan-09 19-jan-09Thanks everybody for ur help
i could exactly mention what i requred
create table SCHEDULER
( REF VARCHAR2(10),
NO NUMBER ,
PORT VARCHAR2(10),
ARRIVAL DATE ,
DEPARTURE DATE
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA0677',1,'KUWAIT','1-Sep-09','02-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA0677',2,'INDIA','5-Sep-09','07-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA0677',3,'COLUMBO','8-Sep-09','09-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA0677',4,'IRAN','10-Sep-09','12-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA0677',5,'IRAQ','14-Sep-09','15-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA0677',6,'DELHI','17-Sep-09','19-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA0677',7,'POLAND','21-Sep-09','23-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA0678',1,'INDIA','5-Sep-09','07-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA0678',2,'COLUMBO','8-Sep-09','09-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA0678',3,'IRAN','10-Sep-09','12-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA0678',4,'IRAQ','14-Sep-09','15-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA0678',5,'DELHI','17-Sep-09','19-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA0678',6,'POLAND','21-Sep-09','23-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA0678',7,'GOA','1-Oct-09','02-Oct-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2372',1,'INDIA','1-Sep-09','02-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2372',2,'KERALA','3-Sep-09','03-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2372',3,'BOMBAY','4-Sep-09','04-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2373',1,'INDIA','5-Sep-09','06-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2373',2,'ANDHERI','6-Sep-09','07-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2376',1,'INDIA','5-Sep-09','07-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2420',1,'INDIA','5-Sep-09','06-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2420',2,'ANDHERI','7-Sep-09','08-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2420',3,'BURMA','10-Sep-09','11-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2420',4,'BENGAL','11-Sep-09','12-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2445',1,'INDIA','4-Sep-09','05-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2445',2,'BURMA','7-Sep-09','09-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2498',1,'BENGAL','8-Sep-09','08-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2498',2,'COCHIN','11-Sep-09','11-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2498',3,'LANKA','12-Sep-09','12-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2498',4,'COLUMBO','13-Sep-09','15-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2498',5,'INDIA','17-Sep-09','18-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2505',1,'COLUMBO','5-Sep-09','06-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2505',2,'GOA','8-Sep-09','09-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2505',3,'INDIA','13-Sep-09','15-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2510',1,'INDIA','4-Sep-09 06-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2510',2,'BENGAL','8-Sep-09 09-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2510',3,'GOA','10-Sep-09 11-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2513',1,'INDIA','7-Sep-09','09-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2513',2,'USA','11-Sep-09','11-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2513',3,'UK','12-Sep-09','13-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2520',1,'INDIA','4-Sep-09','06-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2520',2,'BENGAL','8-Sep-09','09-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2520',3,'GOA','10-Sep-09','11-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2526',1,'INDIA','5-Sep-09','07-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2526',2,'DUBAI','10-Sep-09','11-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2526',3,'GOA','13-Sep-09','15-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2526',4,'OMAN','17-Sep-09','18-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2526',5,'INDIA','19-Sep-09','20-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2527',1,'BURMA','7-Sep-09','08-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2527',2,'INDIA','9-Sep-09','10-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2527',3,'ANDHERI','10-Sep-09','16-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2532',1,'SHARJAH','3-Sep-09','04-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2532',2,'AEDXB','5-Sep-09','05-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2533',1,'AESHJ','2-Sep-09','02-Sep-09');
INSERT INTO SCHEDULER(REF,NO,PORT,ARRIVAL,DEPARTURE)
VALUES('VA2533',2,'INDIA','3-Sep-09','03-Sep-09');
COMMIT;
Suppose these records shows the REF travelling from one location to another with respect to date
We need to find out each REF GROUP WISE AND THE DATE OF TRAVELLING FOR SPECIFIED location travelling IE from STARTING FROM INDIA AND ENDING TO GOA
OUTPUT SHOULD BE LIKE DATA SHOWN BELOW
FROM LOCATION TO LOCATION
REF , NO , PORT , ARRIVAL ,DEPARTURE , REF , NO , PORT , ARRIVAL , DEPARTURE
VA0678 1 INDIA 5-Sep-09 07-Sep-09 VA0678 7 GOA 1-Oct-09 02-Oct-09
VA2510 1 INDIA 4-Sep-09 06-Sep-09 VA2510 3 GOA 10-Sep-09 11-Sep-09
VA2520 1 INDIA 4-Sep-09 06-Sep-09 VA2520 3 GOA 10-Sep-09 11-Sep-09
VA2526 1 INDIA 5-Sep-09 07-Sep-09 VA2526 3 GOA 13-Sep-09 15-Sep-09
---------------------------------------------------------------------------------------------------------------------------------------------------------------- -
Error in nested group function used with column name.
Hi Team,
If i used nested group function with column name its not working. Could you please any one suggest me.
How to use it.
Regards,
Venkat.
Please find Spool ........
SQL> select user_name,max(max(CNT)) from (select USER_NAME,count(*) CNT from v$open_cursor group by USER_NAME)
2 group by user_name,CNT;
select user_name,max(max(CNT)) from (select USER_NAME,count(*) CNT from v$open_cursor group by USER_NAME)
ERROR at line 1:
ORA-00937: not a single-group group function
SQL> select max(max(CNT)) from(select USER_NAME,count(*) CNT from v$open_cursor group by USER_NAME)
2 group by user_name;
MAX(MAX(CNT))
605Venkat wrote:
Hi Sayan
Its giving output like below, but not given maximum CNT.
SQL> select user_name,max(CNT)from (select USER_NAME,count(*) CNT from v$open_cursor group by USER_NAME)
2 group by user_name;
USER_NAME MAX(CNT)
BANES_LERG 6
VENE_USER 8
USER3 339
DBUS 106
VEL_USER 37
SYS 597
6 rows selected.Check it - Re: Error in nested group function used with column name.
and previous post -
Grouping vendor payments using Grouping key issue
Hello Gurus,
I created a new grouping key in config to be assigned to the vendor master (under Payments Transactions Accounting). The grouping key fields used were BUDAT (Posting Date) and ZFBDT (Baseline Payment Date). The automatic payment program should group payments to vendors based on this grouping key.
This solution works fine when the vendors have a negative amount in the automatic payment program run. However, if the vendor has a positive balance (due to payroll related adjustments), the payment program will not process the line item. Since we are grouping open vendor items by posting date and baseline payment date, the system treats this as a unique grouping key and is not clearing against any subsequent payment runs (because of different posting date and baseline date).
Is there a way to clear the positive balance without manual intervention? The solution works fine otherwise.
Thanks for your help.
- TarunHello,
Functionally, a credit amount means it is treated as an Invoice. Meaning that your company is required to make the payment to the vendor. In other words, your company liable to make the payment for the minus amounts.
Whereas, the debit entries are nothing but debit notes, in sap you call as credit memo. These are NOT to be paid to the vendor. You need to adjust them from the invoice amounts (minus figures) before making the payment.
I would suggest you run F-44 or F.13 to clear them (net of minus and plus values). Then you will have only minus figures. Later you run F110.
If you want to clear them automatically in F.13, you should have configuration (criteria) in OB74.
Please let me know if you need any further details.
Regards,
Ravi -
We're using the DIO Buffered handshake in VI (PCI 6503 Board) to read TTL pulses from a wavemeter. Sometimes we are able to collect data, but sometimes we get this error message: "specified Group is in use". No matter how long we wait between taking data, we sometimes (yet not always) get this message. We have one group of 2 ports that we're reading. Is there a way we can get rid of this problem?
Hi,
Are you running any example program or your own?
1. This problem happens when you abnormally terminate the program, such as, by clicking on the abort button.
Say first time you run the programd and it runs fine and then abort the program. In that case, the DIO group is not cleared and hence the subsequent runs give the error that you said.
In such case I would suggest you to open the Device Reset.vi which is under Functions Pallete>>Data Acquisition>>Calibration and Configuration>>Device Reset.vi.
On the front panel of the Device Reset.vi, enter the device number of your card and run the Device Reset.vi. If you get an error on the front panel, then run again so the error goes away. Now run you DIO program and it should run fine.
The botto
mline is, dont abort the program. If it has no functionality incorporated to stop it depending on some condition, then incorporate it.
Please do let me know if my suggestion helped.
Sincerely,
Sastry V.
Applications Engineer
National Instruments -
Repost Function using Variable is not working
Hello experts! I am on BW-BPS 3.5. I have set up a repost function using variables to change a characteristic value for Business Unit.
1. I created 2 variables as Bus.Unit From and Bus.Unit To in the Planning Area. I am not using the variables in my planning level.
2. I entered the variables in the parameter group New Values area for the From and To Values.
3. My goal is when the user executes the Repost Function for a Variable Prompt should appear and have the user select the From Business Unit and To Business Unit.
The Variables are set up as USERVALUE User-Defined Values, Restriction of Values required by user and I have tried with/without option of Input Allowed by User.
Can you tell me what I am doing wrong, I expected a variable prompt when executing the Repost Function but it does not work.
Thank you,
TeriRavi, Thank you for your reply however I contiue to have errors or the execution does not repost (change any value) as noted below.
1. I have 2 Variables in Planning area var1 (from) var2 (to) for the same charateristic which is Business Unit
2. Business Unit is in the level, on the selection tab to add the variable I can only add 1 variable, So I added var1 (from) to the level.
3. Parameter group for old and new values - I have Var1 (from), var2 (to)
4. Report Function - are you referring to Reporting variables in BPS? I have set this up as suggested in the "How to Use Reporting Variable in BW-BPS" document.
5. Enter plan data: I receive prompt for VAR1, mandatory. At this point there is no value in Var2.
6. Execute Repost function - I receive an error to "Restrict Var2"
7. If I set variable values and add a value for Var2 I receive an error "The generated data is not contained in the selection condition".
Next I removed VAR1 from my planning level and turned on the option 'Selection in package' for Business Unit. This seems to work well.
What do you recommend?
Thank you,
Teri -
Interactive report Group By functions support Number
Dear All,
I developed an interactive report that retrives its data from a package. Now i want to use a group by and use Max function.Since my columns' types are STRING, I cant use Max function.Does anyone know any solution for that?
MAny thanks in advance.
Best regards,
Zahrajohn2013 wrote:
Anybody installed the latest APEX? i believe it's 4.2.3.
You can find out for yourself by requesting a workspace on apex.oracle.com, which always runs the latest production release.
Could you please tell me
is the limitation for interactive report "group by" action increased? (3 columns max for my 4.2 version)
No. Patch releases like 4.2.3 are never likely to include significant changes in functionality. They only provide bug fixes.
I consider this is a major drawback...
Interactive reports follow the 80/20 rule. They satisfy 80% of the requirements of 80% of users 80% of the time. If your requirements fall into any of the remaining 20% categories then you have to build something yourself. APEX is a development tool after all... -
Hi All
very simple one but i just confused by it . i just want to display the rows in group by function .
example
SQL> select user_full_name,last_login_date,email_address from comit_user group by company_code
its giving an error .
could some one please help me in this .
thanks in advance .Hi there,
Group by is used with group functions such as SUM, AVG, MAX, MIN, etc
eg. select job, sum(sal) from emp group by job;
JOB SUM(SAL)
ANALYST 6000
CLERK 4150
MANAGER 8275
PRESIDENT 5000
SALESMAN 5600
In your query, it looks like you need to use ORDER BY instead
select user_full_name,last_login_date,email_address from comit_user
ORDER BY company_code
Regards,
John -
Hi frds
I wrote a code where there is a subquery in my select statement, when i use a group by function with my query it comes with an error
Example
This is how my select statement looks
SELECT
mt.subinventory_code,
item.description,
we.wip_entity_name,
SUM((mt.transaction_quantity)*-1),
sum(wro.required_quantity),
sum(wdj.start_quantity),
(SELECT SUM (transaction_quantity) FROM mtl_onhand_quantities
WHERE inventory_item_id = wro.inventory_item_id
AND organization_id = wro.organization_id) rm_stock
And my group by statement is of this way
group by
mt.subinventory_code,
item.description,
we.wip_entity_name
When i excute the query
It results in an error like this
ORA-00979: not a GROUP BY expression
When i remove the subquery from my select statement it works fine,but i want the result including the subquery plz help meI don't know the implications, but give this a try.
SELECT we.wip_entity_name JOB_NO,
mt.subinventory_code DEPARTMENT,
msi1.segment1 assembly_item,
msi1.description assm_desc,
sum(wdj.start_quantity) ASSL_QTY,
item.segment1 PART_CODE,
item.description PART_DESCRIPTION,
item.primary_uom_code UOM,
sum(wro.required_quantity) REQUIRED_QTY,
SUM((mt.transaction_quantity)*-1) ISSUED_QTY,
mfg.meaning JOB_STATUS,
SUM (mol.transaction_quantity) rm_stock
FROM mtl_material_transactions mt,
mtl_system_items item,
mtl_system_items msi1,
wip_e0ntities we,
wip_requirement_operations wro,
mfg_lookups mfg,
wip_discrete_jobs wdj
mtl_onhand_quantities mol
WHERE mt.inventory_item_id = wro.inventory_item_id
and mt.inventory_item_id=item.inventory_item_id
AND item.inventory_item_id = wro.inventory_item_id
AND we.wip_entity_id = wro.wip_entity_id
AND wdj.wip_entity_id = we.wip_entity_id
AND mfg.lookup_code = wdj.status_type
AND mt.organization_id = :org_id
AND mt.inventory_item_id = wro.inventory_item_id
AND item.organization_id = wro.organization_id
AND mt.transaction_source_id = we.wip_entity_id
AND msi1.inventory_item_id = wdj.primary_item_id
AND msi1.organization_id = wro.organization_id
AND we.wip_entity_id = wro.wip_entity_id
AND we.organization_id = wro.organization_id
AND mfg.lookup_code = wdj.status_type
AND mfg.lookup_type = 'WIP_JOB_STATUS'
AND mt.transaction_type_id = 35
AND wro.department_id <> 1001
AND wro.required_quantity > transaction_quantity*-1
AND mol.inventory_item_id = wro.inventory_item_id
AND mol.organization_id = wro.organization_id
group by mt.subinventory_code,
item.description,
item.segment1,
we.wip_entity_name,
mfg.meaning,
item.primary_uom_code,
msi1.segment1 ,
msi1.description;Cheers
Sarma. -
Usage of group by function on oracle 8i
Is it possible to use a group by function in a query involving two tables
say for example the emp table and the dept table .i tried the following query
but it never worked.could some one clarify this.iam aware of CUBE and ROLLUP in 8i but i still want to try with group by for the sake of interoperability with 7.3/8.0 .Thanking you
SELECT E.DEPTNO,AVG(SAL),D.DNAME,
FROM EMP E,DEPT D
WHERE E.DEPTNO = D.DEPTNO
GROUP BY E.DEPTNOHi,
try the following:
SELECT E.DEPTNO,D.DNAME,AVG(SAL)
FROM EMP E,DEPT D
WHERE E.DEPTNO = D.DEPTNO
GROUP BY E.DEPTNO, D.DNAME
Regards
-Sree Ram -
I want to get an output using group by function of there is no data in the table to display a particular value
for eg:
SELECT TRUNC(updated_date) DATE1 , COUNT(1) COUNT FROM table
where TRUNC(updated_date) >=TRUNC(SYSDATE-18) AND TRUNC(updated_date) <=TRUNC(SYSDATE)
GROUP BY TRUNC(updated_date)
ORDER BY TRUNC(updated_date) DESC;
DATE1 COUNT
6/16/2012 14208
6/15/2012 307825
6/14/2012 172988
6/6/2012 138790
6/5/2012 167562
6/4/2012 51870
6/2/2012 130582
6/1/2012 239806
But i need the missed out date i.e 6/3/2012 - 0, 6/7/2012 - 0 to be displayed since there is no data on the repective dates.You should probably ask this question in the SQL and PL/SQL forum:
PL/SQL
You'll find answers quicker. -
IR group by function and timestamp datatype
Is there any limitations on the group by function e.g. based on the datatype.
My problem\misunderstanding is with the IR:
USING "GROUP BY"-
I have a TIMESTAMP column (columnname TM_TIME) and I can schose it in the group by clause but not in the function section. Is there any reason why and could I get it to work.
regards
Thorsten
Edited by: Fischert on 02.05.2012 03:05It really depends on the granularity that you need from the timestamp to make it meaningful. The key word is aggregation. So you should ask what level of aggregation do I need?
You can reduce the granularity from the fractional seconds to some lower level of granularity like seconds, minute, hours or even date (equivalent of trunc(date_column) using CAST or Truncating or to_date(to_char(...)) with appropriate format mask.
It just depends on the application and data.
E.g. for the LHC at CERN chasing the Higgins, timestamp is just not fine grained enough (you need 10 exp -23 or lower I guess !)
E.g. if you look at seismic data for oil exploration a hell of a lot happens in 5th and 6th decimal places in the timestamp.
But if you are looking at data logged by a normal SCADA system then maybe a second is detailed enough for the purpose.
In normal business application we are better off "rounding" the timestamp to some meaningful level for aggregation/ reporting.
Regards,
Maybe you are looking for
-
Migrate database 8.1.7.3 to 10.2.0.2
Hi, I must migrate my database 8.1.7.3 to 10.2.0.2 but my question is First migrate 8.1.7.3 to 8.1.7.4 and 8.1.7.4 to 10.2.0.2 or migrate 8.1.7.3 to 9.2.0.2 and 9.2.0.2 to 10.2.0.2. Regards
-
Strange File name appearance, PLEASE HELP!
I have Mac OS X v 10.6.8; When I open any finder window, the below file name appears on all of them. I have deleted the item to "trash" it still shows when I open any finder window! I suspect it is some kind of virus, but I am not sure. I have Norton
-
Issue with Open Enrolment Link in ESS - Benefits
Hi Experts, We are facing two issues with open Enrolment Link in ESS for benefits, Need your help in resolving this. Please find the details below : 1. Benefits cost is not appearing in open enrolment Screen Details : Monthly Contribution cost
-
HT204407 get serial number for lost Ipod
My sons Ipod has been stolen and I need the serial number. It was registered with apple but they can not provide it. Is there any other way of getting it from icloud or any other source?
-
just plugged USB into laptop but the nano is not showing up in the iTunes window (left navigation)