Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 31st, 2006, 03:20 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default Problems with SELECT DISTINCT

Hey guys,
    Let me get right down to it, I work for an agency that is regulated by HIPAA and to come into compliance with those standards I had to rewrite the security system that we use on our intranet. Well this is where the problem arises, HIPPA states that an employee may only view Medical Records of clients when it is required to perform their daily job functions.

Here is the problem: only certain people have the rights to view ALL of the client information all other employees are permitted to view clients that only belong to their service area (e.g. Substance Abuse) but clients may also belong to more then one service area (substance abuse and young adult)

When X user preforms a search I pass in as a parameter that users domain name and have a view setup of all the service areas they belong to; my actual search is preformed against a view that has every client and their corrosponding service area and my where statement is WHERE serv_fk IN (Sub Query users service areas).

The problem is with the client Views, it is a SELECT DISTINCT but when I Left Join my look up table of service areas I have duplicate records in my view because while Jon Doe is a unique client his record is different in his service area column. So when a user searches for jon doe and they belong to both service areas they will see both records, is there any way that I can search the aforementioned view but only return one client if they exsist more than once?

"The one language all programmers understand is profanity."
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
 
Old April 2nd, 2006, 01:55 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

I am confused. Does the service area relate to the user or to the patient? Maybe you need an inner join rather than a left join?

 
Old April 2nd, 2006, 03:55 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I just resolved this. I place my search results in a temp table and was selecting all from that temp table changing this to SELECT DISTINCT fixed the problem. (The view contains duplicate yet unique values only because of the program service column, when I place a search result in my temp table, i dont place the service area into that table so DISTINCT returns exactly what i need)

"The one language all programmers understand is profanity."





Similar Threads
Thread Thread Starter Forum Replies Last Post
Select Distinct kirkmc Access 13 July 13th, 2006 01:26 PM
Select Distinct kirkmc Excel VBA 3 May 5th, 2006 07:55 PM
Select Distinct? [email protected] SQL Language 5 November 5th, 2005 09:58 AM
Distinct SELECT DISTINCT question... EndEffect Classic ASP Databases 4 August 18th, 2005 08:53 AM
select distinct bmains ADO.NET 0 April 8th, 2004 02:50 PM





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