Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > SQL Language
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 19th, 2007, 09:26 AM
Authorized User
Join Date: Aug 2006
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default display count results and image in webpage

I am trying to count 5 categories, which will be based on the errorcode that has the most values. (eg errorcode1 was chosen 10 times, errocode2 was chosen 3 times all for category1, then the image in the cell next to category 1 should be red, because errorcode1 contained the most values for that category.

eg of how the webpage looks:
(5 categories, 5 errorcodes, 3 images for colorcode)

Category 1 --> errorcode1(10) red
Category 2 --> errorcode2 (6) yellow
Category 3 --> errorcode3 (5) yellow
Category 4 --> errorcode4 (3) green
Category 5 --> errorcode5 (1) green

green - 0-3 errors
yellow - 4-6 errors
red - 7+ errors

"SELECT category, COUNT(errorcode) AS id_number FROM ticket_view GROUP BY category"

Reply With Quote
  #2 (permalink)  
Old April 19th, 2007, 09:42 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons

Try this:

WHEN Count(e1.ErrorCode) <= 3 Then Green
WHEN Count(e1.ErrorCode) > 3 AND Count(e1.ErrorCode) <= 6 Then Yellow
WHEN Count(e1.ErrorCode) > 6 Then Red
END as [Category 1],
WHEN Count(e2.ErrorCode) <= 3 Then Green
WHEN Count(e2.ErrorCode) > 3 AND Count(e2.ErrorCode) <= 6 Then Yellow
WHEN Count(e2.ErrorCode) > 6 Then Red
END as [Category 2]

FROM ticket_view e1
Left Join ticket_view e2 on e2.category = 'Category 2'
WHERE e1.category = 'Category 1'

Obviously you would wnat to join 3 more times to get the last 3 categories but you get the idea. The column name will be your category and the value of that column will be a color.


================================================== =========
Read this if you want to know how to get a correct reply for your question:
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
================================================== =========
Why can't Programmers, program??
================================================== =========
Reply With Quote
  #3 (permalink)  
Old April 19th, 2007, 09:44 AM
Authorized User
Join Date: Aug 2006
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts

thank you for your very fast help, i will try that right now.

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to count the number of access the webpage ? khb3283 ASP.NET 2.0 Basics 2 October 2nd, 2008 09:08 PM
Count in combo box(display results in text box) mboyisis Access 4 April 4th, 2008 07:08 AM
Display icon on a webpage rroohhiitt C# 3 February 24th, 2006 08:12 PM
display a pdf in a webpage crmpicco Classic ASP Basics 3 February 8th, 2005 09:59 AM
how to count the database search results of record gilgalbiblewheel Classic ASP Databases 2 July 31st, 2004 10:37 AM

All times are GMT -4. The time now is 02:58 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.