TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
evan liewer
NA
25
35.9k
Query n# of Records
Sep 26 2012 6:17 PM
Creating a c# program founded on MS-SQL:
It is a medical program and patients are sometimes prescribed drugs, sometimes 1 prescription, sometimes 4, who knows. I want the program user to be able to click a button and see the last prescription (possibly to scroll through all previous prescriptions) and see what drugs were prescribed last. Then another button and they can re-prescribe the same meds.
I have a table with Patient Info and a prescription table that has Patient #, Visit #, and then drug info
How would i do a Query that pulls all the records of a particular patient, and then groups them by the Visit #.
My initial thought is query all the pharmacy records of a patient and then do a foreach loop through that data. but how would I group the data. How do i have it find and group the unique VisitID numbers?
Pictures:
ID PatID VisitID MedID
1 58 334 200
2 58 567 301
3 58 567 687
4 58 567 420
5 58 891 301
6 58 891 82
7 58 891 612
and I want to get 3 Groups of data (334, 567, 891) with (1,3,3) results respectively.
Thank you
Reply
Answers (
1
)
Rename a db in SQL
SQL View