dbaspot
Tags Register FAQ Calendar Search Today's Posts Mark Forums Read

Please give me a solution - sqlserver-faq

This is a discussion on Please give me a solution - sqlserver-faq ; I have a table called patient.i am using count of test_code.every patient can have more than one test_code.and each test_code can be performed more than one time.I want to get the patients who have only count as 1 and doesnot ...


Home > Database Forum > Microsoft SQL Server > sqlserver-faq > Please give me a solution

Reply

 

LinkBack Thread Tools Display Modes
  #1  
Old 10-18-2009, 01:05 AM
Database Newbie
 
Join Date: Oct 2009
Posts: 1
neemapremano is on a distinguished road
Post Please give me a solution

I have a table called patient.i am using count of test_code.every patient can have more than one test_code.and each test_code can be performed more than one time.I want to get the patients who have only count as 1 and doesnot have count more than 1

patient COunt(for each test_code)
PAT001 1
1
2
3
PAT002 1
1
PAT003 5
3
PAT004 1
1
1

when i am using the following query i nam getting patients who have both count=1 and count greater than.

SELECT A.PATIENT_ID,A.SPECIMEN_NO,COUNT(A.GROUP_TEST_CODE ) AS "COUNT" FROM RL_RESULT_TEXT A
GROUP BY A.PATIENT_ID,A.SPECIMEN_NO
HAVING PATIENT_ID LIKE 'QH%' AND COUNT(A.GROUP_TEST_CODE)=1



Please help me out....
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
Integrated Security by any LDAP solution other than Active Directory? Database Administrator ms-sqlserver 1 08-14-2008 12:29 PM
Re: which query solution is better? Database Administrator mysql 1 07-09-2008 09:40 AM
which query solution is better? Database Administrator mysql 1 07-08-2008 12:20 PM
WANdisco Announces Clustering Solution for Subversion and CVS Database Administrator shell 0 01-10-2008 03:05 AM
Solution Explorer Database Administrator sqlserver-faq 0 01-08-2008 03:15 PM


All times are GMT -4. The time now is 01:40 PM.