sql count of distinct records?

vendredi 3 avril 2015

I'm pretty new to sql and wonder if the following is possible.



Say I have a very large data set, we'll call it #data, and two of the fields are year1 and month1.



Is it possible to simultaneously do a select distinct year1, month1 from #data as well count of each of those things?



It would be useful to determine what my unique combinations are, and how many of each combination I have in my data.



I was thinking something like

select distinct year1, month1, count(distinct year1, month1) as count from #data order by year1, month1



Is there a way to do that in sql?



if it matters I'm using microsoft sql server management studio. Also anyone have any sql forums recommendations?



TGIF!



Gareth Keenan





sql count of distinct records?

0 commentaires:

Enregistrer un commentaire

 

Lorem

Ipsum

Dolor