SQL - where did "rv" come from


#1

I’m new to SQL (and programming). Can someone explain to me what “rv” stands for in this block of code? I’m guessing it’s a short hand for the table named recommended_values but no where did it rename the table to rv. It just seems to randomly appear in the code. This one of the learning module solutions I’m working on and I hate to move on b/c I have no idea how they came up with the short hand rv. Thank you!!!

SELECT
active_patients.Name as Name, round(LDL) as LDL,
active_patients.Address As Address,
active_patients.Phone as Phone
FROM
panels,
(SELECT Borderline_High, High
FROM recommended_values
WHERE LIPID = ‘LDL’) rv
JOIN active_patients on
panels.patient_ID = active_patients.ID
GROUP BY LDL
HAVING LDL>= rv.Borderline_High
ORDER BY LDL DESC;


#2

Hi @msphilomath,

See if this helps you out please: Tables Aliases

The short is, as the title to the other post suggests; a Table Alias. SQL doesn’t not like knowing where it’s getting it’s info from. So every object needs a name. This object is a derived table, and needs a name in order for SQL to reference it correctly.