Programming

Programming questions? Ask a programmer for answers ASAP

Ask a Computer Expert,
Get an Answer ASAP!

Need sql query to pull from the same column of a table under…

Customer Question
Need sql query to pull...
Need sql query to pull from the same column of a table under different conditions. Have two tables. Need to pull all data from first table and only one column from the second table multiple times under different conditions.
Submitted: 2 years ago.Category: Programming
Show More
Show Less
Ask Your Own Programming Question
Answered in 2 minutes by:
1/18/2016
Programmer: Ingo U, Software Engineer replied 2 years ago
Ingo U
Ingo U, Software Engineer
Category: Programming
Satisfied Customers: 796
Experience: Over 25 years experience in software development. Expert in Microsoft .Net, C#, C++, VB, SQL
Verified

Hi,

can you upload information on the schema of the tables involved? For example, if you had SQL server generate CREATE scripts for the tables and upload them for me, I could replicate your situation at my end. Or, just backup your whole database if it's not too large/complex/confidential and upload the whole thing.

Some simple example of source and destination table contents before and after the operation would be helpful, too.

Thanks,

Ingo U

Ask Your Own Programming Question
Customer reply replied 2 years ago
Here is my query so farselect
ENT.PATIENT.PAT_SEQ,
ENT.PATIENT.CREATED_DT,
ent.patient.created_tz,
ent.patient.created_by_seq,
ENT.PATIENT.MODIFIED_DT,
ent.patient.modified_tz,
ent.patient.modified_by_seq,
ent.patient.record_version,
ent.patient.enterprise_seq,
ent.patient.cpi_seq,
ent.patient.organization_seq,
ent.patient.previous_organization_seq,
ent.patient.episode_of_care_seq,
ent.patient.patient_type_seq,
ent.patient.patient_visit_type_seq,
ent.patient.bed_seq,
ent.patient.previous_bed_seq,
ent.patient.arrival_mode_seq,
ent.patient.departure_mode_seq,
ent.patient.name_prefix,
ent.patient.name_prefix_lseq,
ent.patient.last_name,
ent.patient.middle_name,
ent.patient.first_name,
ent.patient.name_suffix,
ent.patient.name_suffix_lseq,
ent.patient.birth_dt_approximate_fl,
ent.patient.birth_dt,
ent.patient.birth_tz,
ent.patient.gender,
ent.patient.gender_lseq,
ent.patient.facility_id,
ent.patient.dept_id,
ent.patient.email_address,
ENT.PATIENT.PATIENT_ID,
ent.patient.visit_number,
ent.patient.medrec_id,
ent.patient.soc_sec_no,
ent.patient.barcode,
ent.patient.patient_status,
ent.patient.patient_status_lseq,
ent.patient.patient_status_detail,
ent.patient.patient_status_detail_lseq,
ent.patient.pat_type_group,
ent.patient.pat_type_group_lseq,
ent.patient.acuity_class,
ent.patient.acuity_class_lseq,
ent.patient.payor_class,
ent.patient.payor_class_seq,
ENT.PATIENT.ADMIT_DT,
ent.patient.admit_tz,
ent.patient.expected_admission_dt,
ent.patient.expected_admission_tz,
ent.patient.transfer_dt,
ent.patient.transfer_tz,
ENT.PATIENT.DISCHARGE_DT,
ent.patient.discharge_tz,
ent.patient.text_1,
ent.patient.text_2,
ent.patient.room_id,
ent.patient.bed_id,
ent.patient.source_system,
ent.patient.source_system_seq,
ent.patient.accommodation_code,
ent.patient.accommodation_seq,
ent.patient.service,
ent.patient.complaint,
ent.patient.complaint_onset_dt,
ent.patient.complaint_onset_tz,
ent.patient.admit_source,
ent.patient.admit_source_lseq,
ent.patient.admit_type,
ent.patient.admit_type_lseq,
ent.patient.condition,
ent.patient.condition_lseq,
ent.patient.discharge_disposition,
ent.patient.discharge_disposition_seq,
ent.patient.discharge_condition,
ent.patient.discharge_condition_lseq,
ent.patient.disposition_decision_dt,
ent.patient.final_discharge_ind,
ent.patient.final_discharge_ind_lseq,
ent.patient.cancel_reason,
ent.patient.cancel_reason_lseq,
ent.patient.expired_fl,
ent.patient.expired_dt,
ent.patient.expired_tz,
ent.patient.purge_ind,
ent.patient.purge_ind_lseq,
ent.patient.purge_dt,
ent.patient.purge_tz,
ent.patient.last_result_dt,
ent.patient.last_result_tz,
ent.patient.financial_support,
ent.patient.financial_support_lseq,
ent.patient.publicity,
ent.patient.publicity_seq,
ent.patient.confidentiality_level,
ent.patient.confidentiality_level_seq,
ent.patient.visit_protection_fl,
ent.patient.visit_protection_dt,
ent.patient.visit_protection_tz,
ent.patient.cancel_admission_reason,
ent.patient.cancel_admission_dt,
ent.patient.cancel_admission_tz,
ent.patient.cancelled_by,
ent.patient.height,
ent.patient.height_unit,
ent.patient.height_unit_lseq,
ent.patient.weight,
ent.patient.weight_unit,
ent.patient.weight_unit_lseq,
ent.patient.recurring_treatment_end_dt,
ent.patient.recurring_treatment_end_tz,
ent.patient.lmp_date,
ent.patient.pregnant_fl,
ent.patient.information_given_by,
ent.patient.brought_in_by,
ent.patient.disposition_decision_tz,
ent.patient.corporate_billing_class_lseq,
ent.patient.patient_type_class_seq,
ent.patient.service_seq,
ent.patient.pr_dept_id,
b.staff_seq AS "Attend Staff Seq",
c.staff_seq AS "Admitting Staff Seq",
d.staff_seq AS "Primary Care Staff Seq",
e.staff_seq AS "Ordering Staff Seq",
f.staff_seq AS "Performing Staff Seq",
g.staff_seq AS "Referring Staff Seq"FROM
ENT.PATIENT inner join ent.staff_assign b
on ent.patient.pat_seq = b.pat_seq inner join
ent.staff_assign c
on ent.patient.pat_seq = c.pat_seq inner join
ent.staff_assign d
on ent.patient.pat_seq = d.pat_seq inner join
ent.staff_assign e
on ent.patient.pat_seq = e.pat_seq inner join
ent.staff_assign f
on ent.patient.pat_seq = f.pat_seq inner join
ent.staff_assign g
on ent.patient.pat_seq = g.pat_seq
where b.care_reln_code = 'ADMD' and
c.care_reln_code = 'ATMD' and
d.care_reln_code = 'PCMD' and
e.care_reln_code = 'ORD' and
f.care_reln_code = 'PER' and
g.care_reln_code = 'REF'
and ent.patient.pat_seq = '123456'
Customer reply replied 2 years ago
Here is the staff_assign tableent.staff_assign.staff_assign_seq,
ENT.STAFF_ASSIGN.CREATED_DT,
ent.staff_assign.created_tz,
ent.staff_assign.created_by_seq,
ent.staff_assign.modified_dt,
ent.staff_assign.modified_tz,
ent.staff_assign.modified_by_seq,
ent.staff_assign.record_version,
ent.staff_assign.enterprise_seq,
ENT.STAFF_ASSIGN.STAFF_SEQ,
ENT.STAFF_ASSIGN.PAT_SEQ,
ent.staff_assign.assign_by_staff_seq,
ent.staff_assign.cover_by_staff_seq,
ent.staff_assign.close_by_staff_seq,
ent.staff_assign.cover_by_group_seq,
ent.staff_assign.practice_group_seq,
ent.staff_assign.specialty_seq,
ent.staff_assign.care_reln_code,
ent.staff_assign.care_reln_seq,
ENT.STAFF_ASSIGN.START_DT,
ent.staff_assign.start_tz,
ent.staff_assign.start_utc,
ENT.STAFF_ASSIGN.END_DT,
ent.staff_assign.end_tz,
ent.staff_assign.end_utc,
ent.staff_assign.close_by_reason,
ent.staff_assign.source_system,
ent.staff_assign.source_system_seq,
ent.staff_assign.pat_finder_fl
Customer reply replied 2 years ago
My query pulls 0 results right now. I can eliminate all the care_reln_codes but ATMD and PCMD and get data, but there are two rows for that due to the pat_seq being in the staff_assign table twice for when the ATMD changed. I need it all on one row with only the most recent modified_dt for each care_reln_code and I need the data to pull even if there is no data for all the care_reln_codes.
Programmer: Ingo U, Software Engineer replied 2 years ago

I'm sorry,
After reviewing the question, I regret that I won't be able to assist you at this time.

I am opting out and opening the question up to other professionals here who may be able to help.

Regards,
Ingo U

Ask Your Own Programming Question
Was this answer helpful?

How JustAnswer works

step-image
Describe your issueThe assistant will guide you
step-image
Chat 1:1 with a programmerLicensed Experts are available 24/7
step-image
100% satisfaction guaranteeGet all the answers you need
Ask ATLPROG Your Own Question
ATLPROG
ATLPROG
ATLPROG, Computer Software Engineer
Category: Programming
Satisfied Customers: 7,677
7,677 Satisfied Customers
Experience: MS in IT.Several years of programming experience in Java C++ C C# Python VB Javascript HTML

ATLPROG is online now

A new question is answered every 9 seconds

How JustAnswer works:

  • Ask an ExpertExperts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional AnswerVia email, text message, or notification as you wait on our site. Ask follow up questions if you need to.
  • 100% Satisfaction GuaranteeRate the answer you receive.

JustAnswer in the News:

Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.

What Customers are Saying:

My Expert answered my question promptly and he resolved the issue totally. This is a great service. I am so glad I found it I will definitely use the service again if needed.

One Happy CustomerNew York

Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help.

Mary C.Freshfield, Liverpool, UK

This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!!

AlexLos Angeles, CA

Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult.

GPHesperia, CA

I couldn't be more satisfied! This is the site I will always come to when I need a second opinion.

JustinKernersville, NC

Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around.

EstherWoodstock, NY

Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know.

RobinElkton, Maryland

< Previous | Next >

Meet the Experts:

ATLPROG

ATLPROG

Computer Software Engineer

7,677 satisfied customers

MS in IT.Several years of programming experience in Java C++ C C# Python VB Javascript HTML

LogicPro

LogicPro

Computer Software Engineer

7,175 satisfied customers

Expert in C, C++, Java, DOT NET, Python, HTML, Javascript, Design.

unvadim

unvadim

Computer Software Engineer

1,168 satisfied customers

Good knowledge of OOP principles. 3+ years of programming experience with Java and C++. Sun Certified Java Programmer 5.0.

lifesaver

lifesaver

Computer Software Engineer

950 satisfied customers

Several years of intensive programming and application development experience in various platforms.

ehabtutor

ehabtutor

Computer Software Engineer

936 satisfied customers

Bachelor of computer science, 5+ years experience in software development, software company owner

TheDoctor

TheDoctor

Software Engineer

893 satisfied customers

M.S. in Internet Information Systems

The-PC-Guy

The-PC-Guy

Software Engineer

848 satisfied customers

Extensive Knowledge in PHP, MYSQL, CSS & Javascript

< Previous | Next >

Related Programming Questions
I Have a query regarding My Sql database manipulation can
Hi I Have a query regarding My Sql database manipulation can you help … read more
Steve
Steve
Consultant
Bachelor
69 satisfied customers
Can you help me with this MS-SQL query: select sostrs.csono,
Can you help me with this MS-SQL query: select sostrs.csono, sum(sostrs.nsalesamt-sostrs.ndiscamt) as salestrs, avg(sosord.ntaxable1-sosord.nfrtamt) as salestot from sostrs left outer join sosord on s… read more
Ingo U
Ingo U
Software Engineer
796 satisfied customers
I'm getting an error I don't understand: Msg 4104, Level
I'm getting an error I don't understand: Msg 4104, Level 16, State 1, Line 5 The multi-part identifier "a.accNumber" could not be bound. What I'm trying to do: I have a single table. table key is the … read more
TheDoctor
TheDoctor
Software Engineer
Master's Degree
893 satisfied customers
I need help writing a script that can be either java or php. I
I need help writing a script that can be either java or php. I want to create a drop down menu with a list of Table names: Demographics_Current, Demographics, Current_Yr_Schedules, Attendance_Daily, A… read more
The-PC-Guy
The-PC-Guy
Software Engineer
Bachelor's Degree
848 satisfied customers
For "THE DOCTOR" ONLY!SQL Query Needed - This should be
For "THE DOCTOR" ONLY! SQL Query Needed - This should be final Doctor, I now know what is needed for the SQL query... I cant type in all the text here as I am limited. Please let me know when you are … read more
TheDoctor
TheDoctor
Software Engineer
Master's Degree
893 satisfied customers
I have a SQL database I need code to add selects and joins
I have a SQL database I need code to add selects and joins to the database. The following are what I need and I can accept it as late as 24hrs from now. Write one SQL query that Selects all the column… read more
C.Martin
C.Martin
IT Consultant
Bachelor's Degree
453 satisfied customers
for "ATLPROG" only write one SQL squery that selects all the
for "ATLPROG" only write one SQL squery that selects all the columns in both tables and JOINs the two in the database you created last week and uses an expression (,=) to restrict record selection. Us… read more
ATLPROG
ATLPROG
Computer Software Engineer
Master's Degree
7,677 satisfied customers
Hi! Could you please to help me this question: How does querying
Hi! Could you please to help me this question: How does querying multiple tables differ from querying a single table using SQL? Give specific examples of the differences in the main parts of a SELECT … read more
The-PC-Guy
The-PC-Guy
Software Engineer
Bachelor's Degree
848 satisfied customers
Using the file at this location: http://wikisend.com/download/994772/KudlerFoods.doc
Using the file at this location: http://wikisend.com/download/994772/KudlerFoods.doc I need the following: write SQL queries using Between, Like, and Union. Write an SQL query that does the following:… read more
jatechexpert
jatechexpert
Master\u0027s Degree
1 satisfied customers
I need the additional parts an the sql query below as
Hello I need the additional parts an the sql query below as follows: 1. Put results of below query into a #temp Table (temp name 'mytemp') Select (c.First_Name + ' ' + c.Last_Name) AS Auditor_Name,d.O… read more
The-PC-Guy
The-PC-Guy
Software Engineer
Bachelor's Degree
848 satisfied customers
I need to identify the avg and max numbers for the following: Sql
I need to identify the avg and max numbers for the following: Sql query (s) for a table with columns (auditor_id, company_id) table1 with auditor_id client_company_id 1 2 1 5 1 9 1 15 2 22 3 21 4 33 3… read more
LogicPro
LogicPro
Computer Software Engineer
Bachelor of Technology
7,175 satisfied customers
Need to know if MS Access 2007 can help me do the following....I
Need to know if MS Access 2007 can help me do the following....I have have three different excel spreadsheets that I need to upload into a single data base. Once they have been uploaded only some of t… read more
Eljon
Eljon
Software Developer Consultant
Associate Degree
562 satisfied customers
when you get a chance here is the information...also need
for ehabtor when you get a chance here is the information...also need help with a discrepancie from the first project Use the database and tables from last week's assignment to write SQL statements an… read more
ehabtutor
ehabtutor
Computer Software Engineer
Bachelor's Degree
936 satisfied customers
ehab tutuor, here is the information you requested......also
ehab tutuor, here is the information you requested......also had a problem with the first one ....they said they oculd download it but not able to read it...ask me to download it in msword2003....can … read more
ehabtutor
ehabtutor
Computer Software Engineer
Bachelor's Degree
936 satisfied customers
I need a MySQL query to build a table of standings for NFL
I need a MySQL query to build a table of standings for NFL like this one. I have two tables that are populated with enough data to make this happen. A certain amount of flexibility is allowed. If I ha… read more
toughguy
toughguy
Master\u0027s Degree
210 satisfied customers
simple question lost my code example. Need to return only
simple question lost my code example. Need to return only one row based on a column where there may be many rows with same value (a unique kind of request). no counts, no aggregate functions, just a r… read more
Sabertooth
Sabertooth
Freelancer
Bachelor\u0027s Degree
67 satisfied customers
I have a db with multiple tables, quieries and reports. I
I have a db with multiple tables, quieries and reports. I routinely import data from excel, same excel file format. The db file size was 575 MB when I started getting an error "Subscript out of range"… read more
Dave Lewis
Dave Lewis
IT Consultant
Bachelor's Degree
6 satisfied customers
There is a table with individual last names, first names, addresses,
There is a table with individual last names, first names, addresses, etc. Some records are for spouses of people in other records, but it is desired to keep separate records. However, when doing a que… read more
Sam Perridge
Sam Perridge
Bachelor's Degree
12 satisfied customers
Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.

Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.

Show MoreShow Less

Ask Your Question

x