I am trying to learn how aggregate functions work in SQL and I cant work out how to calculate the number of times a value appears within a query.
Im using MSSQL 2008 and everything I try seems to cause an error.
Below is my query:
SELECT category,
template,
galleryshortDescription,
galleryLongDescription,
GalleryName,
GalleryTitle,
GalleryID,
GalleryCreatedDate,
GalleryLastUpdated,
GalleryPublished,
GalleryViews,
ObjectID,
GalleryDescription,
HtmlMetaKeywords,
HtmlMetaDescription
FROM dbo.ImageGallery
I would like to return the category
field as well as the total number of times it appears in this query and I have tried using
count (category) AS category_counter
any suggestions greatly appreciated
thanks in advance
Aucun commentaire:
Enregistrer un commentaire