Reply to SQL query help...

Your name:

Reply:


Posted by hharry on 05/04/07 00:02

All,

I have the following table:

CREATE TABLE [PATIENT_VISITS_BY_YEAR] (
[ROW_ID] [int] IDENTITY (1, 1) NOT NULL ,
[PATIENT_ID] [int] NOT NULL ,
[YEAR_IN_QUESTION] [int] NOT NULL ,
[NUM_OF_VISITS] [int] NOT NULL
) ON [PRIMARY]
GO

With rows:

INSERT INTO PATIENT_VISITS_BY_YEAR
VALUES (1, 2000, 10)

INSERT INTO PATIENT_VISITS_BY_YEAR
VALUES (1, 2001, 20)

INSERT INTO PATIENT_VISITS_BY_YEAR
VALUES (2, 2000, 50)

INSERT INTO PATIENT_VISITS_BY_YEAR
VALUES (2, 2001, 25)

I need to return the a single row for each patient, displaying the max
number of visits and the year those visits occurred:

e.g.

PATIENT_ID: 1
YEAR_IN_QUESTION: 2001
NUM_OF_VISITS: 20

PATIENT_ID: 2
YEAR_IN_QUESTION: 2000
NUM_OF_VISITS: 50

Thanks in advance!

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация