|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hello,
I am trying to do a query on the data below and produce the following report: Win 95 5 Win 98 8 Win NT 4.0 3 Win NT 5.0 9 Win NT 5.2 20 I am not quite sure how to do a query that contains all the counts. I can do this: SELECT COUNT(*) FROM dbo.Log WHERE [logField] LIKE '%User Agent:%Windows 95%' And that works, but I am not sure how to do it for all the platforms. The other caveat is that the data type is ntext, so I think I need to do something like: SELECT SUBSTRING(text, 0, 128) AS Expr1, COUNT(*) etc. I am not an expert at SQL, but understand it well enough to do somewhat complex queries, but this one has me stumped. Any help would be greatly appreciated. The field format: User Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705; .NET CLR 1.1.4322) User Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705; .NET CLR 1.1.4322) User Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705; .NET CLR 1.1.4322) User Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98) User Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98) User Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98) User Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705; .NET CLR 1.1.4322) User Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; (R1 1.5)) User Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; (R1 1.5)) User Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; (R1 1.5)) User Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90) User Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90) User Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705; .NET CLR 1.1.4322) User Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705; .NET CLR 1.1.4322) User Agent: Mozilla/5.0 User Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98) User Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98) User Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 95; Supplied by blueyonder) User Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 95; Supplied by blueyonder) User Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 95; Supplied by blueyonder) User Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; GTE_IE4; Hotbar 3.0) User Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 98) User Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 98) User Agent: Mozilla/4.0 (compatible; MSIE 5.13; Mac_PowerPC) User Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; libero) User Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) User Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt) User Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98) User Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) User Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows 98) User Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98) User Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; (atfile.com)) Thank you, Tony |
|
#2
|
||||
|
||||
|
You should split the value first to retrieve the OS, then insert that into a different field, then your select statement would be something like this
Code:
SELECT OS, COUNT(*) As 'Count' FROM TableName GROUP BY OS ORDER BY 'Count' DESC |
|
#3
|
|||
|
|||
|
Yes, that is one option I thought of. However, I already have this data in a table and it contains
thousands of records. Rather than writing code to 'fix-up' the already existing records, I was hoping I could perform an SQL query to do the job. Any other ideas/options? Thanks for your assistance, Tony |
|
#4
|
||||
|
||||
|
What you could do is create another field called OS.
Extract the OS from the text string and update the OS field with the extracted value, then do a distinct count on that field. Last edited by Memnoch : June 16th, 2004 at 10:26 AM. |
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > SQL Query question... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|