Ask a Question related to Coldfusion Database Access, Design and Development.
-
glossen #1
most popular value in a column
if I have 10 records :
ID_______thisval__________name
1________5______________bob
2________3______________bill
3________3______________diane
4________2______________jacko
5________2______________jean
6________3______________gloria
and I want to run a report on the most popular "thisval"
is there anyway to do this in an sql query rather than using alot of CF loops
etc...
i basicly want the output
val_____________countnum
3______________3
2______________2
5______________1
i tried the following but it only returned one column
<cfquery datasource="#datsrc1#" name="getComp" maxrows="10">SELECT
COUNT(DISTINCT thisVal) AS "countNum" FROM table WHERE thisDate >
"#DateFormat(DateAdd("m", -6, now()), "yyyy-mm-dd")#" AND thisVal <> "" ORDER
BY thisVal</cfquery>
TIA =)
glossen Guest
-
Popular video and realtime stats
Hi, I need to get the most popular videos hosted on the FMS. How can I get that. Also I want to get at any time the stats for the viewer ship... -
!! DOWNLOAD THE MOST POPULAR 2006's CRACKED SOFTWARE(CAD/CAE/CAM/EDA/PCB/GIS/CNC/FEA)
Our team provide different types of services such as: - proffessional cracking of any kind of softwar... -
!! DOWNLOAD THE MOST POPULAR 2006's CRACKED SOFTWARE(CAD/CAE/CAM/EDA/PCB/GIS/FEA/CNC)
Our team provide different types of services such as: - proffessional cracking of any kind of softwar... -
!! DOWNLOAD THE MOST POPULAR 2005's CRACKED SOFTWARE(CAD/CAE/CAM/EDA/GIS/PCB/FEA/CNC/
Our Team provide CRACKED engineering and technical software at thi topics: => Civil and Structural => Survey , GIS , Rock , Soil and Water =>... -
Ruby could be wildly more popular if it had ...
Brackets. Huh? What do you mean "brackets"? Brackets. Ruby doesn't have enough brackets. Hmph! I think ruby has the exact right amount of... -
paross1 #2
Re: most popular value in a column
<cfquery datasource="#datsrc1#" name="getComp" maxrows="10">
SELECT thisVal,
COUNT(DISTINCT thisVal) AS "countNum"
FROM table
WHERE thisDate > "#DateFormat(DateAdd("m", -6, now()), "yyyy-mm-dd")#"
AND thisVal <> ""
GROUP BY thisVal
ORDER BY 2 DESC
</cfquery>
Phil
paross1 Guest



Reply With Quote

