SQL Basics

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsDatabasesSQL Basics

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old April 5th, 2018, 02:43 PM
Ayupchap Ayupchap is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Apr 2018
Posts: 0 Ayupchap User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 24 sec
Reputation Power: 0
HELP with my SQL code

Hi there all this is my first post

Super new dealing with SQL but can perform simple queries. I have this query below and need to add code so that it searches the field Classes.section_name with the contents of this field Grade.short_name

The difficulty is that the Grade.short_name contains a single number (the grade a students in) whereas the Classes.section_name will contain the number from Grade.short_name but also have other details.

Is this possible to do. I need to add it to this code here:

SELECT DISTINCT

Students.state_student_id,

Students.student_id,

Students.local_student_id,

Students.first_name,

Students.last_name,

Grade.short_name,

Schools.site_name,

Classes.section_name,

Teachers.teachers,

Assmnts.title,

Assmnts.description,

Assmnts.academic_year,

Assmnts.administered_at,

Assmnts.code_subject_area_id,

MathScores.percent_correct



FROM

dna_assessments.agg_student_responses MathScores

left JOIN dna_assessments.assessments Assmnts ON MathScores.assessment_id = Assmnts.assessment_id

left JOIN public.students Students ON MathScores.student_id = Students.student_id





left JOIN (SELECT distinct

c.student_id,

STRING_AGG(u.last_name, ', ') AS teachers,

c.site_id,

c.grade_level_id,

c.section_id





FROM matviews.ss_cube c

left JOIN public.users AS u

ON c.user_id = u.user_id



GROUP BY c.student_id, c.site_id, c.grade_level_id, c.section_id

) AS Teachers

ON Students.student_id = Teachers.student_id

left JOIN public.sections Classes ON Classes.section_id = Teachers.section_id

left JOIN public.student_session_aff Enrollment -- Student school enrollments as on page=Student_Enrollment_Controller

ON Students.student_id = Enrollment.student_id

AND MathScores.date_taken BETWEEN Enrollment.entry_date and Enrollment.leave_date -- Enrollment range in which student's score date falls. Assumes no missing leave dates or overlapping enrollment records.

-- AND Assmnts.administered_at BETWEEN Enrollment.entry_date and Enrollment.leave_date -- Enrollment range in which assessment date falls. Assumes no missing leave dates or overlapping enrollment records.

left JOIN public.grade_levels Grade ON Enrollment.grade_level_id = Grade.grade_level_id

left JOIN public.sessions Years ON Enrollment.session_id = Years.session_id -- Sites' regular/summer sessions (connects student_session_aff to sites)

left JOIN public.sites Schools ON Years.site_id = Schools.site_id



Where (Assmnts.title like '%Math Interim Assessment%' or Assmnts.title like '%HRM%') and (Classes.section_name like '%HRM%' or Classes.section_name like '%Homeroom%');


Any help much much much appreciated, I'm at a total loss

Reply With Quote
Reply

Viewing: Tutorialized ForumsDatabasesSQL Basics > HELP with my SQL code


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap