amandajdarlow
asked on
SQL Query to mimic MS Access First
Looking at the attaced screenshot can anyone suggest how I can create a SQL Server stored procedure or view which picks out the record with the lowest TagCategorySortId(last column) for each SNT SessionNotesId?
I am no SQL Server guru and I would like to know the 'correct' and 'best' way to do this.
Doc1.docx
I am no SQL Server guru and I would like to know the 'correct' and 'best' way to do this.
Doc1.docx
ASKER
I need to be able to select all the first records at the same time rather than by SessionNotesId.
In this case " However I noticed that you have 2 rows with SessionNotesId=45803 and TagCategorySortId=1. Which one you choose? "I am happy to simply select the first or both, it doesn't matter for now.
In this case " However I noticed that you have 2 rows with SessionNotesId=45803 and TagCategorySortId=1. Which one you choose? "I am happy to simply select the first or both, it doesn't matter for now.
Can you copy the select statement from the picture in text and post it here? I need to work on it.
ASKER
SELECT dbo.tblSessionNoteTags.SNT SessionNot esId, dbo.tblTag.TagId, dbo.tblTagCategory.TagCate gorySort
FROM dbo.tblSessionNoteTags INNER JOIN
dbo.tblTag ON dbo.tblSessionNoteTags.SNT TagId = dbo.tblTag.TagId INNER JOIN
dbo.tblTagCategory ON dbo.tblTag.TagCategoryID = dbo.tblTagCategory.TagCate goryId
WHERE (dbo.tblTagCategory.TagCat egorySort IS NOT NULL)
ORDER BY dbo.tblSessionNoteTags.SNT SessionNot esId, dbo.tblTagCategory.TagCate gorySort
FROM dbo.tblSessionNoteTags INNER JOIN
dbo.tblTag ON dbo.tblSessionNoteTags.SNT
dbo.tblTagCategory ON dbo.tblTag.TagCategoryID = dbo.tblTagCategory.TagCate
WHERE (dbo.tblTagCategory.TagCat
ORDER BY dbo.tblSessionNoteTags.SNT
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Brilliant works perfectly. Thank you very much. I shall study the technique later.
However I noticed that you have 2 rows with SessionNotesId=45803 and TagCategorySortId=1. Which one you choose?