Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat logic can I use in SQL where I am getting two results which are both correct, but I need to pick just one?
    primarykey
    data
    text
    <p>I am a novice programmer and I am also learning to ask right questions and become a better writer so do comment some tips if you notice anything wrong with the way I asked my question or explained. Here we go:</p> <p>I have a request from a user, who wants me to write a code, which gets the term for which the applicants who applied for a specific program of study (example:"Information Systems") was accepted. </p> <p>I am not sure if this is bad data or what exactly happened, but while QC'ing the user came across a student who applied for a specific program of study twice (in Summer 2011 and Summer 2012) and was accepted both times. When the user QC'd, for some reason, Summer 2011 was showing in front-end. The user has requested that I show the latest term only for that program of study. I can't find any flags or alternatives to narrow my search.</p> <p>Does anyone know what I can do (what logic can I use) to choose the latest term. The table does has lastchangedate column, but I'm not sure if I can use it since students can apply to 20 different program of studies. </p> <p>More information:</p> <p>I will be putting my code into a existing stored procedure. Also, I will be inserting this term information in a table. </p> <p>here's what my code looks like logic wise:</p> <pre><code>DECLARE @MiscID int...... SELECT @MiscID = sys_miscinfotablesdetailsid from sys_miscinfotablesdetails where attributename = 'Start Term for Billing'.... INSERT INTO sss_studentstudyprogramsmisc ( AttributeValue....... ) SELECT T.Name [AttributeValue],.... FROM SMS_StudentsInstance i inner join.....(blah blah) where WHERE sspm.AttributeValue IS NULL </code></pre> <p>Please do let me know if I need to provide more information. I would appreciate this. I asked the Sr. Engineer on my team and he told me: "do some datetime comparison to term date times. I have no idea how you'd pull it off for a current summer term. good luck :)".</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload