SQLTeam.com | Weblogs | Forums

Help writing a small query

Given the two tables below, write a statement that would pull Account, Facility, and PatientLast for the Atlanta Facility only. The Primary Key for both tables is Account.

Welcome

Please provide your sample data not as an image but like following example

declare @sample table(
Class varchar(50), 
Animal1 varchar(50),
Animal2  varchar(50),
Animal3  varchar(50),
Animal4  varchar(50))

insert into @sample
values('reptile','crocodile','lizard','snake','alligator')

insert into @sample
values('bird','penguin','ostrich','emu','owl')

CREATE TABLE Location (
Account VARCHAR(6),
Facility TEXT(10),
PRIMARY KEY (Account)
INSERT INTO 'Location' (Account, Facility)
VALUES ('A12385', 'Atlanta', 'A45643', 'Atlanta', 'C45644', 'Cherokee', 'F98978', 'Forsyth');

CREATE TABLE Demographics (
Account VARCHAR(6),
PatientLast TEXT(10),
City TEXT(15),
PRIMARY KEY (Account)
INSERT INTO 'Demographics' ('Account', 'PatientLast', 'City')
Values ('A12345', 'Smith', 'Atlanta' , 'A45643', 'Jones', 'Dunwoody', 'C45644', 'Brown', 'Canton', 'F98978,''Webb', 'Cumming',);

Again, need help writing a statement that would pull Account, Facility,City, and PatientLast for the Atlanta Facility only. Primary key for both is Account

This is a simple join - what have you tried so far and where are you having issues?