Query- not to repeat column value
Hello,
tried find the solution from the forum... but no luck ....if it repeation please excuse me.
Data on the Table.
ID U_ID NAME
100 1 AAA
100 3 BBB
200 1 CC
200 2 DDD
200 3 EEEEMy output Should be
ID U_ID NAME
100 1 AAA
3 BBB
200 1 CC
2 DDD
3 EEEENo repetation of ID
Kindly suggest me.
Thanks,
Amuly
with t as
(select '100' ID,'1' U_ID,'AAA' NAME from dual union all
select '100','3','BBB' from dual union all
select '200','1','CC' from dual union all
select '200','2','DDD' from dual union all
select '200','3','EEEE' from dual)
select decode(row_number() over(partition by ID order by name),1,id) ID,u_id,name
from t;
ID U NAME
100 1 AAA
3 BBB
200 1 CC
2 DDD
3 EEEE
Thanks,
Ramadurga
Edited by: 968136 on Nov 2, 2012 12:20 PM
Similar Messages
-
How to deselect query property 'suppress repeated key values'
hj gurus,
In BEx analyser there is a query property 'suppress repeated key values' which can be de-selected.
regards,
PreetyHello preety.
Is simple.
In BEx query designer push the button designated by "query properties" (the 13 button from left to right).
Go to the tab "Display" and mark the second option "Hide Repeated Key Values"
And there you go.
Please assign points.
Diogo. -
Repeat Column Value derived from formulae
I need to repeat a value derived for a particular column &row combination to all rows in the table. however when I put the 'case' function it does not repeat the values as I expect. The value is only shown in the 1at row
The formulae used is as follows
CASE WHEN D_MILLS.MILL_NO =1 THEN (F_MILL_PRODUCTION.FN_YTD_CPO_PRODUCED/F_MILL_PRODUCTION.FN_YTD_CROP_PROCESSED ) ELSE (FILTER(F_MILL_PRODUCTION.FN_YTD_CPO_PRODUCED/F_MILL_PRODUCTION.FN_YTD_CROP_PROCESSED USING (D_MILLS.MILL_NO = 1.00)) ) END
Note : Mill No is the Dimension Field that I user for the report. and I require the value of derived for mill No =1 to be repeated to all other mills (Mill No =2,3 etc)
Edited by: Shaz01 on Aug 7, 2010 1:45 AMHi,
Use the formula like this,
Max(CASE WHEN D_MILLS.MILL_NO =1 THEN (F_MILL_PRODUCTION.FN_YTD_CPO_PRODUCED/F_MILL_PRODUCTION.FN_YTD_CROP_PROCESSED ) ELSE (FILTER(F_MILL_PRODUCTION.FN_YTD_CPO_PRODUCED/F_MILL_PRODUCTION.FN_YTD_CROP_PROCESSED USING (D_MILLS.MILL_NO = 1.00)) ) END)
Also for all the values you need to show the value of Mill no 1, so no need for case statement.
MAX(FILTER(F_MILL_PRODUCTION.FN_YTD_CPO_PRODUCED/F_MILL_PRODUCTION.FN_YTD_CROP_PROCESSED USING (D_MILLS.MILL_NO = 1.00)))
Thanks,
Vino -
Query Designer - Hide Repeated Key Values - Doesn't work in the web
Hello Experts,
I'm facing a problem with a query. The user requested that he/she wants to see all the values of the key values.
I already unchecked the option "Hide repeated key values" in query designer, but it still hiding it. I tested in BEx and it's working fine, but when I run it in the web the key values are being hidden.
Anyone knows what is happening? I'm not using WAD and there is no possibility to use it.
Thanks,
HelderHi,
I have seen this problem - setting that option still does not show the repeated key values in web. You will indeed need to use WAD and uncheck that option in the properties of the analysis item. If you can't do that, the other option would be to do this change in the default web template (which is generally 0Analysis_pattern for BI WAD) but note that this will affect all queries.
Also, please note that if the query is exported to excel, it will show the repeated values. This is the reason sometimes the users ask for key values to be repeated - maybe you would want to confirm that. -
Performance issue: View query is calculating a column value before filterin
Hi,
I have a view like this.(My view is more complex than this..I just tried to imitate the situation )
Select emp_id, emp_name, calculate_salary(emp_id) salary
From employees
Where nvl(department, '@@##$$') = nvl(get_global.department, '@@##$$')When I execute the below query
select emp_name from my_view where salary=10000 by setting a value to get_globals.department I found that it first calls the calculate_salary instead of applying the filter for departments. By somehow the cost base analyzer thinks that calling the function is cheaper than applying the filter. I wonder whether there is way to direct the cba and say to first apply the filters before calculating column values.
Any suggestions ?
ThanksI don't think it's possible.
Before a WHERE clause can be applied the data has to be collected for the row so Oracle, I would imagine, isn't going to differentiate between what is a database column and a function, fetch just the columns, do the filtering and then go back to calculate the rest of the columns; it's just going to get all the columns, including the calculated ones, and then apply the filters.
The only option would be to do...
select emp_id, emp_name, calculate_salary(emp_id) salary
from (select emp_id, emp_name
from employees
where nvl(deparment, '@@##$$') = nvl(get_global.department, '@@##$$')
)as your view -
Bex Query not passing blank columns to crystal reports
good morning ladies and gentleman,
i have created a bex query that shows all employees from the master data table and links to the cats table to show absence hours...
in bex, all employees are showing and some of the employees have hours showing for sick time. very good...
i have created a report in crystal with this bex query and it does not show rows from the master data that do not have a link to the cats table. only the rows that have a link to the cats table are showing up.
the reason i need the master data from the employee table is that the users want to divide the total hours off(sick time) per department by the total employees in that department.
i have tried to create a formula that will add 1 to the hours sick field, then all the rows should have a amount in it. but, it still does not show the employees who do not have sick time.
here is the sql query from crystal.
SELECT {[Measures].[4J8L2TQJ3P517ISQ1R4Y8UZ36], [Measures].[4J9PY3UANRIW2HW15YSOED92A], [Measures].[4J9TLIO0NDQROSA2YONCW6HB6]}
ON COLUMNS,
NON EMPTY
CROSSJOIN([0EMPLOYEE].[LEVEL01].MEMBERS, [0EMPLOYEE__0COMP_CODE].[LEVEL01].MEMBERS)
DIMENSION PROPERTIES [0EMPLOYEE].[50COMP_CODE], [0EMPLOYEE].[50MAST_CCTR] ON ROWS
FROM [ZCATS_MC1/ZZCATS_MC1_Q001C]
SAP VARIABLES [0I_DAYS] INCLUDING [0CALDAY].[20100502] : [0CALDAY].[20100903]
this is kind of an emergency and i have been working on this for two days and cannot come to a resolution.
if anyone can help, i would appreciate it.
i am guessing that there is a option somewhere that will allow blank records to show.
please help.
thanks,
erikmiss stated the issue. created new note.
-
Report query not returning the field value from external table
hi
I have an issue regarding reports. I have a query having 4 fields from external table and remaining from db tables. the report query returns all the fields from the db tables and only 2 fields from external table. but the same query if I tried in plsql developer it returns all the fields values.
Can anyone please help me in this issue.
Thanks and Regards
kkDuplicate post?
value not displaying in report whereas it returns in plsql developer
value not displaying in report whereas it returns in plsql developer
Please log a SR if you do not get any reply to your thread instead of creating new one.
Thanks,
Hussein -
Query not executing all columns
Hi Experts
My client is running a query. they have been using it for a little while now with no issues. I have attached the query as a formatted search on the item master data form. when one of their users runs the queriy through the formatted search, it doesnt show the last column. but when running it through the query manager, it works fine.
its only giving this problem for the one user (doesnt matter if we log in as that user on his PC or any other PC) therefore it is user related.
why could this be happening?OK below is the query:
declare @CurUser as nvarchar(10)
set @CurUser = $[user]
if(@CurUser in (1,5,8,9,22,44
begin
with req as
select [item number] as 'item',[required qty] as 'required', [forecast current month] as 'forecast', [sq] as 'SQ', [on hand]
FROM VPP_2006SBO_GARSINLIVE.DBO.VLGX_GetPlannedItemDetails()
Invoices AS --Get invoices per item
*(SELECT T0.[ItemCode], T0.[FrgnName], SUM(I1.[Quantity]) AS Qty,*
*DATEDIFF(month, T0.CreateDate,getdate()) AS ItemMonths*
*FROM OITM T0 full outer join inv1 i1 on T0.ItemCode = I1.ItemCode*
*left join OINV I0 ON I0.DocEntry = I1.DocEntry*
*WHERE I0.[DocDate] >= '2006-06-01'*
*AND I0.DocType <> 'S'*
*GROUP BY T0.[ItemCode], T0.[FrgnName], T0.CreateDate*
*Credit AS -- Get credit notes per item*
( SELECT C1.[ItemCode],
* C1.[Dscription],*
* SUM(C1.[Quantity]) AS Qty*
* FROM ORIN C0 INNER JOIN RIN1 C1 ON C0.DocEntry = C1.DocEntry*
WHERE C0.[DocDate] >= '2006-06-01'
AND C0.DocType <> 'S'
GROUP BY C1.[ItemCode], C1.[Dscription]
ItemInfo As
(SELECT T0.ItemCode[SearchCode], t0.ItemName,T0.FRGNName[Description], cast (cast ((T0.OnHand- T0.IsCommited) as decimal (5,0)) as nvarchar (10))[Available], cast (cast (T0.OnOrder as decimal (5,0)) as nvarchar (10))[Expected],
(case when (T0.U_IMP is null or T0.U_IMP = '') then '0' else T0.U_IMP end )as 'InputTube',
*(T0.U_Wieghtm * T0.BLength1)[KgLength], T0.ValidComm[-], T2.Price[PriceL], T0.SWW[Spec],T0.U_ManStd, T0.U_MaterialSpec,T0.U_WIEGHTM[KgMetre],*
(T2.Price/(CASE WHEN T0.BLength1 = 0 THEN 0.0001 ELSE T0.BLength1 END))[PriceM]
FROM OITM T0 INNER JOIN ITM1 T2 ON T0.ItemCode = T2.ItemCode,
OCRD T3
WHERE T3.CardName = '[%1]'
and LEFT(T0.ITEMCODE,1)<>'L'
and t0.itmsgrpcod <> '105'
and t0.itmsgrpcod <> '101'
and t0.itmsgrpcod <> '112'
and t0.itmsgrpcod <> '113'
and t0.itmsgrpcod <> '111'
and t0.itmsgrpcod<>'114'
and T2.[PriceList] = T3.[ListNum]
and T3.CardType = 'C'
--order by T0.ITEMNAME
SELECT
ITEMINFO.SearchCode,
--iteminfo.itemname,
ITEMINFO.Description,
ITEMINFO.Available,
(case when ITEMINFO.Expected is null then '0' else ITEMINFO.Expected end ) as 'Expected',
(case when req.forecast is null then 0 when req.forecast = 0 then 0 when req.forecast > 0 then (iteminfo.available + (case when ITEMINFO.Expected is null then 0 else ITEMINFO.Expected end)) / (case when req.FORECAST is null then 0 else req.FORECAST end)end) as 'Months Left of Stock',
--(case when Inv.[Qty] is null then Inv.[Qty] else Inv.[Qty] end) as 'i qty',
--(case when Crn.[Qty] is null then Crn.[Qty] else Crn.[Qty] end) as 'c qty',
--(case when Inv.ItemMonths is null then Inv.ItemMonths else Inv.ItemMonths end) as 'Invoice ItemMonths',
(case when (Inv.[Qty] is null or Crn.[Qty] is null) and Inv.ItemMonths is null then '0' when Inv.[Qty] is null then '0' when Inv.ItemMonths ='0' then Inv.[Qty] when Crn.[Qty] is null and Inv.[Qty] >=0 then (Inv.[Qty] / Inv.ItemMonths) ELSE ((Inv.[Qty] - Crn.[Qty]) / Inv.ItemMonths) END) AS 'Garsin Avg Sales Per Month',
(case when req.FORECAST is null then '0' else req.FORECAST end) as 'Valogix Avg Sales Per Month',
(case when ITEMINFO.InputTube is null then '0' else ITEMINFO.InputTube end) as 'Input Tube',
(case when ITEMINFO.KgLength is null then '0' else ITEMINFO.KgLength end) as 'Kg Length',
(case when ITEMINFO.PriceL is null then '0' else ITEMINFO.PriceL end) as 'Price L' ,
(case when ITEMINFO.Spec is null then '0' else ITEMINFO.Spec end) as 'Standard/Non-Standard', Iteminfo.U_MaterialSpec as 'Material Grade',
(case when iteminfo.U_manstd is null then ' ' else iteminfo.U_manstd end) as 'Manufacturing Standard' ,
(case when ITEMINFO.KgMetre is null then '0' else ITEMINFO.KgMetre end) as 'Kg Metre',
(case when Iteminfo.PriceM is null then '0' else Iteminfo.PriceM end) as 'Price M'
FROM Invoices Inv left outer JOIN Credit Crn ON Inv.[ItemCode] = Crn.[ItemCode]
full outer join ItemInfo ON Inv.[ItemCode] =ItemInfo.[SearchCode]
* left outer join req on req.item = iteminfo.searchcode collate SQL_Latin1_general_CP850_CI_AS *
where Iteminfo.SearchCode is not null
GROUP BY iteminfo.itemname , ItemInfo.[SearchCode], ItemInfo.[Description],Iteminfo.Available, Inv.Qty, Crn.Qty, Inv.ItemMonths, Iteminfo.Expected, ItemInfo.InputTube, ItemInfo.KgLength, Iteminfo.PriceL, ItemInfo.Spec,iteminfo.U_manstd,Iteminfo.Kgmetre, Iteminfo.U_MaterialSpec,ItemInfo.PriceM,req.FORECAST
order by iteminfo.itemname
end
else
begin
WITH Invoices AS --Get invoices per item
*(SELECT T0.[ItemCode], T0.[FrgnName], SUM(I1.[Quantity]) AS Qty,*
*DATEDIFF(month, T0.CreateDate,getdate()) AS ItemMonths*
*FROM OITM T0 full outer join inv1 i1 on T0.ItemCode = I1.ItemCode*
*left join OINV I0 ON I0.DocEntry = I1.DocEntry*
*WHERE I0.[DocDate] >= '2006-06-01'*
*AND I0.DocType <> 'S'*
*GROUP BY T0.[ItemCode], T0.[FrgnName], T0.CreateDate*
*Credit AS -- Get credit notes per item*
( SELECT C1.[ItemCode],
* C1.[Dscription],*
* SUM(C1.[Quantity]) AS Qty*
* FROM ORIN C0 INNER JOIN RIN1 C1 ON C0.DocEntry = C1.DocEntry*
WHERE C0.[DocDate] >= '2006-06-01'
AND C0.DocType <> 'S'
GROUP BY C1.[ItemCode], C1.[Dscription]
ItemInfo As
(SELECT T0.ItemCode[SearchCode], t0.ItemName,T0.FRGNName[Description], cast (cast ((T0.OnHand- T0.IsCommited) as decimal (5,0)) as nvarchar (10))[Available], cast (cast (T0.OnOrder as decimal (5,0)) as nvarchar (10))[Expected],
(case when (T0.U_IMP is null or T0.U_IMP = '') then '0' else T0.U_IMP end )as 'InputTube',
*(T0.U_Wieghtm * T0.BLength1)[KgLength], T0.ValidComm[-], T2.Price[PriceL], T0.SWW[Spec], T0.U_MaterialSpec,T0.U_WIEGHTM[KgMetre],*
(T2.Price/(CASE WHEN T0.BLength1 = 0 THEN 0.0001 ELSE T0.BLength1 END))[PriceM]
FROM OITM T0 INNER JOIN ITM1 T2 ON T0.ItemCode = T2.ItemCode,
OCRD T3
WHERE T3.CardName = '[%1]'
and LEFT(T0.ITEMCODE,1)<>'L'
and t0.itmsgrpcod <> '105'
and t0.itmsgrpcod <> '101'
and t0.itmsgrpcod <> '112'
and t0.itmsgrpcod <> '113'
and t0.itmsgrpcod <> '111'
and t0.itmsgrpcod<>'114'
and T2.[PriceList] = T3.[ListNum]
and T3.CardType = 'C'
--order by T0.ITEMNAME
SELECT
ITEMINFO.SearchCode,
--iteminfo.itemname,
ITEMINFO.Description,
ITEMINFO.Available,
(case when ITEMINFO.Expected is null then '0' else ITEMINFO.Expected end ) as 'Expected',
(case when ITEMINFO.InputTube is null then '0' else ITEMINFO.InputTube end) as 'Input Tube',
(case when ITEMINFO.KgLength is null then '0' else ITEMINFO.KgLength end) as 'Kg Length',
(case when ITEMINFO.PriceL is null then '0' else ITEMINFO.PriceL end) as 'Price L' ,
(case when ITEMINFO.Spec is null then '0' else ITEMINFO.Spec end) as 'Standard/Non-Standard', Iteminfo.U_MaterialSpec as 'Material Spec',
(case when ITEMINFO.KgMetre is null then '0' else ITEMINFO.KgMetre end) as 'Kg Metre',
(case when Iteminfo.PriceM is null then '0' else Iteminfo.PriceM end) as 'Price M'
FROM Invoices Inv left outer JOIN Credit Crn ON Inv.[ItemCode] = Crn.[ItemCode]
full outer join ItemInfo ON Inv.[ItemCode] =ItemInfo.[SearchCode]
where Iteminfo.SearchCode is not null
GROUP BY iteminfo.itemname , ItemInfo.[SearchCode], ItemInfo.[Description],Iteminfo.Available, Inv.Qty, Crn.Qty, Inv.ItemMonths, Iteminfo.Expected, ItemInfo.InputTube, ItemInfo.KgLength, Iteminfo.PriceL, ItemInfo.Spec,Iteminfo.Kgmetre, Iteminfo.U_MaterialSpec,ItemInfo.PriceM
order by iteminfo.itemname
end
>>BASICALLY THERE ARE 2 QUERIES BUILT INTO ONE. IF THE USERCODE IS 1,5,8,9,22, OR 44 THEN IT WILL EXECUTE THE FIRST PART OTHERWISE IT EXECUTES THE OTHER PART. THIS ISNT THE ISSUE WTH MY QUERY AS I HAVE CHECKED THE USERCODE. -
SQL Query not working for column names with spaces
Hi People..
We have a strange situation wherein, the column name in the database table has a space inbetween like "Constant Name". While we write a JDBC statement code with the select query we get an exception for invalid syntax. It will help us in a great way if you have anything to inform us on this..
Thanks
PrabzUsing case sensitive names and names with spaces in it is not a good practice.
However, I believe the SQL standard accounts for this with quoted identifiers. I believe the syntax is
. select "My Field1", "My Field2"
. from "My Table'
Have also seen the following although it might be MS Access specific.
. select [My Field1], [My Field2]
. from [My Table] -
Eliminate repeating column values
Hi,
I have my source table below values:
CLIENT_ID BEGIN_DT END_DT R RES_TYPE_DESC
109800001 20-MAR-97 23-AUG-98 2 FOSTER/COMPANION CARE RESIDENTIAL COMPON
109800001 24-AUG-98 03-SEP-98 1 SHIFT STAFF RESIDENTIAL COMPONENT 3 BED
109800001 04-SEP-98 18-MAR-00 2 FOSTER/COMPANION CARE RESIDENTIAL COMPON
121874001 20-MAR-98 15-DEC-03 2 FOSTER/COMPANION CARE RESIDENTIAL COMPON
121874001 14-MAY-97 15-DEC-03 2 FOSTER/COMPANION CARE RESIDENTIAL COMPON
121874001 16-DEC-03 11-MAY-05 4 SUPERVISED LIVING
504407361 07-SEP-97 05-SEP-07 3 OWN/FAMILY HOME
504564902 06-NOV-97 03-NOV-06 3 OWN/FAMILY HOME
506169803 20-AUG-97 31-MAY-99 3 OWN/FAMILY HOME
506169803 01-JUN-99 29-FEB-00 1 SHIFT STAFF RESIDENTIAL COMPONENT 3 BED
506169803 01-MAR-00 18-AUG-02 4 SUPERVISED LIVING
CLIENT_ID BEGIN_DT END_DT R RES_TYPE_DESC
506169803 19-AUG-02 24-JUL-03 5 RESIDENTIAL SUPPORT SERVICE
506169803 25-JUL-03 23-JUN-04 2 FOSTER/COMPANION CARE RESIDENTIAL COMPON
506169803 24-JUN-04 17-AUG-05 5 RESIDENTIAL SUPPORT SERVICE
14 rows selected.
at row no 4 and 5 for client_id = '121874001'
It has repeating END_DT = '15-DEC-03'
I want to have only one record for client_id = '121874001' where BEGIN_DT IS MINIMUM begin_Dt value (i.e. begin_Dt = '14-MAY-97' and END_DT = '15-DEC-03')
so I can have 2 rows instead of 3 rows for client_id = '121874001'
This is part of my table records my table contains multiple clients.
can some one help me writing SQL ?
Thanks in advance
JayTo display non-repeating information while showing the minimun begin_dt, you need to apply the aggregate funtion MIN to the begin_dt column and the GROUP BY clause to the rest of the columns, as follows:
SELECT client_id, MIN(begin_dt) BEGIN_DT, end_dt, r, res_type_desc
FROM your_source_table
GROUP BY client_id, end_dt, r, res_type_desc;
(use your real column names; your pasted result set seems to append some column names)
Good luck,
Luis -
Spool ALV not displaying two column value
Hi,
In spool ALV is getting displayed. But the output is not printing the value of 2 columns , both are MATNR values. I checked the output table it is fetching the material number but ALV is not displaying it. please help its urgent. The GI material is not getting displayed.HI Aparjitha,
As per the above screenshot I assume there should be only 2 possible cases as said by Jyoti. Apart from that there is no other chance of missing data, especially for couple of columns in the output.
If you are passing the value at run-time to MATNR and you are able to see that in output, hence your final internal table which you are passing to the ALV is not filled appropriately with MATNR values. May be those values are cleared somewhere.
It would be better if you could share some piece of your subroutine FIELDCATFILL code. Also place a breakpoint before ALV display and check if the fieldcatalog and the final internal table are having the appropriate values.
Regards,
Naresh -
How to not repeat the column values if repeated on next line and so on..?
Hi all,
The XmlP template that is designed gives me the output as follows :
COL1 COL2 COL3 COL4 COL5 COL6 COL7
abc 1 1000.00 10.00 95.00 695.00 cad
abc 2 1000.00 100.00 95.00 695.00 cad
abc 3 1000.00 100.00 95.00 695.00 cad
But my requirement is as follows :
COL1 COL2 COL3 COL4 COL5 COL6 COL7
abc 1 1000.00 10.00 95.00 795.00 cad
- 2 - 100.00 - - -
- 3 - 100.00 - - -
Note : "-" indicates blank column values (gaps are being filled)
How do I not repeat the column values if repeated?
Please let me know if you have answer for it?
Thanks in Advance
MunnaIam trying to design the xml publisher template using xmlp template builder.
My requirement is :
For a receipt number, I have receipt amount, applied amount, unapplied amount and on account amount. And for each receipt, there can be multiple applied amount ( as the receipt can be applied multiple times), but the unapplied amount, on account amount and receipt amount is single.
By using the logic as said above from http://blogs.oracle.com/xmlpublisher/2007/04/13
Iam getting the output something like this:
Receipt Number| Receipt Amount | App Amount |UnappAmount|OnaccountAmount|
111-b|249.28|249.28|0.00|0.00|
1110|1,000.00|10.00|95.00|795.00|
1110| -|10.00|-|-|
1112|1500.00|1,271.02|-|-|
1112|-|228.98|-|-|
My requirement is to go get something like this:
Receipt Number| Receipt Amount | App Amount |UnappAmount|OnaccountAmount|
111-b|249.28|249.28|0.00|0.00|
1110|1,000.00|10.00|95.00|795.00|
1110| -|10.00|-|-|
1112|1500.00|1,271.02|0.00|0.00| ---> here lies the difference
1112|-|228.98|-|-|
How do i check the duplicate of the column values only for a receipt number??
Because as for receipt no. 111-b the unapplied amount and on account amount is 0.00, the the unapplied amount and on account amount for receipt number 1112 is getting hided( because its a duplicate) . In reality, it should be 0.00 and any other line for that receipt number (1112) should be hided. except for the applied amount.
Note We can see that last 2 columns in the last record( for receipt number 1112) is getting hided that is as expected but for 4th record the unapplied amount and on account amount should be 0.00 respecively.
'-' indicates hided value
Please help.
Thanks in Advance -
To get the count of records and able to access the column value in a single
Hi
Is there any way to get the number of records in the query and access the column values
e.g
select count(*)
from
(SELECT department, COUNT(*) as "Number of employees"
FROM employees
WHERE salary > 25000
GROUP BY department ) a
This wil only get the Count, if i want to access each row from the inline view how can i do that.Your question is not clear.
Are you looking for total record count as well as count by department ?
Something like this?
SQL>
SQL> with temp as
2 (
3 select 1 dept ,10000 sal from dual union
4 select 1 dept ,25100 sal from dual union
5 select 1 dept ,30000 sal from dual union
6 select 1 dept ,40000 sal from dual union
7 select 2 dept ,10000 sal from dual union
8 select 2 dept ,25100 sal from dual union
9 select 2 dept ,30000 sal from dual union
10 select 2 dept ,40000 sal from dual )
11 select count(*) over( partition by 1 ) total_count,dept,
12 count(*) over(partition by dept) dept_cnt from temp
13 where sal>25000;
TOTAL_COUNT DEPT DEPT_CNT
6 1 3
6 1 3
6 1 3
6 2 3
6 2 3
6 2 3
6 rows selected
SQL> -
Hi,
There are some data dictionary views to get the list of column names and their id.
eg: all_tab_columns
I am querying the fiels for EMP table..
Select column_name,column_id from all_tab_columns where table_name='EMP' order by column_id;
column Name column_id
EMPNO 1
ENAME 2
SAL 3
My reuuirement is nothing but the values of COLUMN_NAME should be displayed as an individual field that is..
EMPNO,ENAME,SAL
Likewise, it should react for all tables that is the values should transformed into fields..
Please help me out in this regard..
Thanks in advance...The reason why i need the generic query to frame the column values into individual fiels is , the explicit cursor can not be used for binding sql statments and moreover i want to create the record type based on the explicit cursor due to some requirement in creating generic procedure..
So, I need a help for creating column values individual fields meaning
select column_name from all_tab_columns where table_name='EMP'
COLUMN_NAME
EMPNO
ENAME
SAL
the answer should be
empno ename sal
Pleaese help me ... -
How To Concatenate Column Values from Multiple Rows into a Single Column?
How do I create a SQL query that will concatenate column values from multiple rows into a single column?
Last First Code
Lesand Danny 1
Lesand Danny 2
Lesand Danny 3
Benedi Eric 7
Benedi Eric 14
Result should look like:
Last First Codes
Lesand Danny 1,2,3
Benedi Eric 7,14
Thanks,
David JohnsonStarting with Oracle 9i
select last, first, substr(max(sys_connect_by_path(code,',')),2) codes
from
(select last, first, code, row_number() over(partition by last, first order by code) rn
from a)
connect by last = prior last and first = prior first and prior rn = rn -1
start with rn = 1
group by last, first
LAST FIRST CODES
Lesand Danny 1,2,3
Benedi Eric 7,14Regards
Dmytro
Maybe you are looking for
-
Obtaining the list of data interfaced out of SAP HCM
Hello, we got a good challenge from our partners in the business organization that we support. The Data Privacy officer on the business partner side would like to know: - what other systems are "takers" of the data from our SAP HCM instance - what da
-
What do I do about message:- iTunes could not back up iPhone because a session could not be started with the iPhone.
-
Distributing customizing(control) data from SAP ECC to a non SAP System
Dear Experts, I am currently working on an interface for distribution of different data to a non SAP System. One of these is customizing data (Company code, purchasing org. plant etc). The system expects a file and we shall implemet the following sce
-
LabVIEW : Why use anything else to write code?
I have been programming in LabVIEW for about 3 years now pretty heavily for both work and fun. It seems to me that if one is going to write most any type of program that LabVIEW is the logical choice. I was playing around with vb6 the other day and
-
I am unable to install the audio content for Soundtrack on FCS2 . During the process the installer will ask for Audio content disc 1 ,I insert the disk and then after a few seconds the installer asks for the Final Cut Studio install disk . I insert t