Double-Count in a SQL Query

Double-Count in a SQL Query

Question:
I want to create two count-variables in one SQL query based on GROUP BY signum_chef. Is that possible? I’ve tried something like this:

 SELECT DISTINCT signum_chef,   Antal=(SELECT COUNT (*)),   Antal1=(SELECT COUNT (*)   FROM anstallda   WHERE anstnr IN (" & sEmployeeID & ")) FROM anstallda GROUP BY signum_chef 

Answer:
Sorry, but I’m not 100 percent clear on your intent. I’d like to offer the following. I think it is redundant to use DISTINCT with GROUP BY, because GROUP BY collapses the result around the members of the projection, so what is DISTINCT going to do?

Also, I don’t think it will work to have Antal and Antal1 in the select list without them appearing in the GROUP BY expression.

Is IN what you intended? If you are making a comparison to some parameter, and it is a key, wouldn’t an equality match work better?

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of