Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 14-06-2009, 02:01 PM   #1 (permalink)
In The Zone
 
Sridhar_Rao's Avatar
 
Join Date: Feb 2007
Posts: 353
Default Need help with mySQL statement


I need help with SQL statement. Here is the structure of the table

+-------+---------------+
| slno | labno |
+-------+---------------+
| 1 | 5 |
+-------|---------------|
| 1 | 6 |
+-------|---------------|
| 2 | 7 |
+-------|---------------|
| 3 | 8 |
+-------|---------------|
| 3 | 9 |
+-------|---------------|
| 3 | 10 |
+-------|---------------|
| 4 | 11 |
+-------|---------------|

I need the output something like this:

+---------+---------+
| times | Nos |
+---------+---------+
| 3 | 1 | a*
+---------+---------+
| 2 | 1 | b*
+---------+---------+
| 1 | 2 | c*
+---------+---------+

a* i.e number of cases where slno is present 3 times (e.g slno 3 is present thrice and it is the only slno to be present thrice)
b* i.e number of cases where slno is present 2 times (e.g slno 1 is present twice and it is the only slno to be present twice)
c* i.e number of cases where slno is present once (e.g slno 2 & 4 are present only once and only two slno are present once)
__________________
Want to study M.Sc in any medical subjects? Read this www.microrao.com/msc.htm
Microx, a diagnostic microbiology laboratory software application www.labmicrox.com
Sridhar_Rao is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 15-06-2009, 12:09 PM   #2 (permalink)
Always confused
 
vamsi360's Avatar
 
Join Date: May 2008
Location: Mandriva Control Center
Posts: 349
Default Re: Need help with mySQL statement

use COUNT(x) statement in WHERE clause
__________________
Vamsi Subhash
visit my blog at www.vamsisubhash.co.cc and taste a bit of IT!
vamsi360 is offline  
Closed Thread

Bookmarks

Thread Tools
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by Sujeet
- by gforz
- by soumya

Advertisement




All times are GMT +5.5. The time now is 03:13 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2