OR1
asked on
How to add a sequential row number column to an aggregate view.
I have a query that agrregates the values from a table in oracle. I want to add a column with sequential rownumbers and I get the following error:
"Ora-00979 Not a valid Group by expression."
It is trying to pull the row numbers from the source data. What I want is to have a squential id number colum.
SELECT ROWNUM,
COUNT (DISTINCT COVERPAGE_GIS.PARENT_COMPA NY) COMPANIES,
FORM477_PART_VI_GIS.TRACT_ FIPS
FROM COVERPAGE_GIS, FORM477_PART_VI_GIS
WHERE (COVERPAGE_GIS.CONTROL_ID = FORM477_PART_VI_GIS.CONTRO L_ID)
AND ( (FORM477_PART_VI_GIS.UPLOA D_RATE_COD E >= 2)
OR (FORM477_PART_VI_GIS.DOWNL OAD_RATE_C ODE >= 2))
GROUP BY FORM477_PART_VI_GIS.TRACT_ FIPS
"Ora-00979 Not a valid Group by expression."
It is trying to pull the row numbers from the source data. What I want is to have a squential id number colum.
SELECT ROWNUM,
COUNT (DISTINCT COVERPAGE_GIS.PARENT_COMPA
FORM477_PART_VI_GIS.TRACT_
FROM COVERPAGE_GIS, FORM477_PART_VI_GIS
WHERE (COVERPAGE_GIS.CONTROL_ID = FORM477_PART_VI_GIS.CONTRO
AND ( (FORM477_PART_VI_GIS.UPLOA
OR (FORM477_PART_VI_GIS.DOWNL
GROUP BY FORM477_PART_VI_GIS.TRACT_
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Your solution works with or without the iq. Can you tell me the reason for it?
Thanks
Thanks
In Oracle iq is optional. In DB2, iq or AS iq is compulsory for nested query (overall/select list/where/having) i.e. normal OR correlated.
Open in new window