User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 427,101 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,176 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser: Programming Forums
Views: 622 | Replies: 1
Reply
Join Date: May 2008
Posts: 33
Reputation: 2eXtreme is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
2eXtreme 2eXtreme is offline Offline
Light Poster

Get occurrences of a record

  #1  
May 28th, 2008
hey guys, i dont suppose you know how i can go from:

id.............result
----------------------
1..............Pass
1..............Pass
1..............Fail
1..............Pass
1..............Fail
2..............Pass
2..............Pass
2..............Fail

to this table:

id...........pass......fail
1............3.........2
2............2.........1

my current query is simply

select id, result from results

I just want to display the total number of occurrences of a result and display them under appropriate headings...I tried performing a union on 2 separate select statements, but it just stacks results on top of one another...

thanks for any help
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,467
Reputation: peter_budo is a jewel in the rough peter_budo is a jewel in the rough peter_budo is a jewel in the rough peter_budo is a jewel in the rough 
Rep Power: 11
Solved Threads: 296
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: Get occurrences of a record

  #2  
May 29th, 2008
  1. SELECT id, COUNT(NULLIF( result, 'Fail' )) Passes, COUNT(NULLIF( result, 'Pass' )) Fails
  2. FROM results
  3. GROUP BY id
  4. ORDER BY id
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MS SQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the MS SQL Forum

All times are GMT -4. The time now is 5:41 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC