Count in SQL

Posted on 2005-04-28
Last Modified: 2010-04-23
How can I make this with SQL?

   Dim oBotas As New Botas
        Dim dtBotas As dsBotas.BotaDataTable = oBotas.DsBotas.Bota

        Dim dvMontar As New DataView(dtBotas)
        dvMontar.RowFilter = "Estado='Montar'"

        Dim dvMontada As New DataView(dtBotas)
        dvMontada.RowFilter = "Estado='Montada'"

        Dim dvLlenada As New DataView(dtBotas)
        dvLlenada.RowFilter = "Estado='Llenada'"

        Dim dvReparar As New DataView(dtBotas)
        dvReparar.RowFilter = "Estado='Reparar'"

        Dim dvVender As New DataView(dtBotas)
        dvVender.RowFilter = "Estado='Vender'"

        Dim dvVendida As New DataView(dtBotas)
        dvVendida.RowFilter = "Estado='Vendida'"

        Dim cntBotasParaMontar As Integer = dvMontar.Count
        Dim cntBotasMontada As Integer = dvMontada.Count
        Dim cntBotasReparar As Integer = dvReparar.Count
        Dim cntBotasVender As Integer = dvVender.Count
        Dim cntBotasLlenas As Integer = dvLlenada.Count
        Dim cntBotasVendidas As Integer = dvVendida.Count

        MsgBox("Montar: " & cntBotasParaMontar & Chr(13) & "Montadas: " & cntBotasMontada & Chr(13) & _
               "Reparar: " & cntBotasReparar & Chr(13) & "Vender: " & cntBotasVender & Chr(13) & _
               "Vendidas: " & cntBotasVendidas & Chr(13) & "Llenas: " & cntBotasLlenas)
Question by:miguelmam
    LVL 34

    Accepted Solution

    SELECT count(*) as myCount, [Estado]
    FROM myTable
    GROUP BY [Estado];

    Should retrun

    132   : Montar
    4234 : Montada etc....



    Author Comment

    Can you send me the whole complete code so that it works, included connection and Command?

    Thank you

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now