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 391,618 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,687 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:
Views: 2939 | Replies: 5
Reply
Join Date: Sep 2006
Posts: 9
Reputation: caterpillar is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
caterpillar caterpillar is offline Offline
Newbie Poster

Help Formatted Output in Stored Procedure

  #1  
Oct 2nd, 2006
Hi All,

I have a stored procedure which displays list of ADMITTED,QUEUED and DISCHARGED patients. The patient status is stored in a table. A represents ADMITTED patient, Q represents QUEUED patient and D represents DISCHARGED patient. I am using a dropdown to display the ADMITTED,QUEUED and DISCHARGED patients respectively. I need to add a new option in the dropdownas ALL which displays all i.e., ADMITTED,QUEUED and DISCHARGED patients but in a classified manner on the same page like:

ADMITTED
--------
RegNo PatientName Age
---- ----------- ---
A1 PNA 70

QUEUED
--------
RegNo PatientName Age
---- ----------- ---
D1 PNQ 53

DISCHARGED
--------
RegNo PatientName Age
---- ----------- ---
Q1 PND 45


How should i code my stored procedure for this kind of formatted output?

Thanks!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2005
Location: Dallas, TX
Posts: 481
Reputation: campkev is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: Formatted Output in Stored Procedure

  #2  
Oct 10th, 2006
post the queries for the 3 lists and I should be able to help you do one query to get the combined list
Reply With Quote  
Join Date: Sep 2006
Posts: 9
Reputation: caterpillar is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
caterpillar caterpillar is offline Offline
Newbie Poster

Solution Re: Formatted Output in Stored Procedure

  #3  
Oct 19th, 2006
Originally Posted by campkev View Post
post the queries for the 3 lists and I should be able to help you do one query to get the combined list


Thanks for replying, i am sorry for responding back late. Here goes my Query:

--ADMITTED
SELECT RNO,PNAME,AGE
FROM TAB1
WHERE enroll_status='A'

--QUEUED
SELECT RNO,PNAME,AGE
FROM TAB1
WHERE enroll_status='Q'

--DISCHARGED
SELECT RNO,PNAME,AGE
FROM TAB1
WHERE enroll_status='D'

At present i am making 3 different datatables & calling them separately to be displayed in 3 different datagrids in asp.net. I need to call a single datatable & want to display in 1 datagrid only.

Thanks
Reply With Quote  
Join Date: Jul 2005
Location: Dallas, TX
Posts: 481
Reputation: campkev is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: Formatted Output in Stored Procedure

  #4  
Oct 19th, 2006
does this work for you?
SELECT RNO,PNAME,AGE
FROM TAB1
WHERE enroll_status in ('D','A','Q')
Reply With Quote  
Join Date: Sep 2006
Posts: 9
Reputation: caterpillar is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
caterpillar caterpillar is offline Offline
Newbie Poster

Help Re: Formatted Output in Stored Procedure

  #5  
Oct 19th, 2006
Thanks again for your reply. This does not works as i need the output as described in my 1st post!
Last edited by caterpillar : Oct 19th, 2006 at 3:46 pm.
Reply With Quote  
Join Date: Oct 2005
Location: Manchester, UK
Posts: 481
Reputation: pty is on a distinguished road 
Rep Power: 3
Solved Threads: 31
pty's Avatar
pty pty is offline Offline
Posting Pro in Training

Re: Formatted Output in Stored Procedure

  #6  
Oct 20th, 2006
SELECT RNO,PNAME,AGE,'discharged' as STATUS
FROM TAB1
WHERE enroll_status = 'D' 
union
SELECT RNO,PNAME,AGE,'queued' as STATUS
FROM TAB1
WHERE enroll_status = 'Q' 
union
SELECT RNO,PNAME,AGE,'admitted' as STATUS
FROM TAB1
WHERE enroll_status = 'A' 
Note to self... pocket cup
Reply With Quote  
Reply

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

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb MS SQL Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the MS SQL Forum

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