•
•
•
•
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
![]() |
•
•
Join Date: Sep 2006
Posts: 9
Reputation:
Rep Power: 0
Solved Threads: 0
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!
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!
•
•
Join Date: Sep 2006
Posts: 9
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
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
•
•
Join Date: Jul 2005
Location: Dallas, TX
Posts: 481
Reputation:
Rep Power: 4
Solved Threads: 19
does this work for you?
SELECT RNO,PNAME,AGE
FROM TAB1
WHERE enroll_status in ('D','A','Q')•
•
Join Date: Oct 2005
Location: Manchester, UK
Posts: 481
Reputation:
Rep Power: 3
Solved Threads: 31
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
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb MS SQL Marketplace
- Help with a stored procedure (MS SQL)
- Help with Stored Procedure (MS SQL)
- how do I run a "disconnected" stored procedure (MS SQL)
- Stored procedure call with ADO (C)
Other Threads in the MS SQL Forum
- Previous Thread: Identity Column Problem in MS SQL Server when moving data from using Bulk Copy
- Next Thread: Problem with query.


Linear Mode