Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8814085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:01:07+00:00 2026-06-14T04:01:07+00:00

I have a little problem with an SQL-Statement right now. I need to somehow

  • 0

I have a little problem with an SQL-Statement right now. I need to somehow get a group by condition inside of a Join. Well now I do know that this doesn’t work, but there most be a way to do this and I hope you guys can give me a clue on how to do this.

Statement:

SELECT 
   btst.Ordnungsbegriff AS BBNR,
   COUNT(vp.KVNR) 
   FROM T_Betriebsstaette btst
      JOIN T_VERSICHERUNGSZEIT vz
         ON vz.BETRIEBSNUMMER = btst.Ordnungsbegriff
         AND vz.VALIDTO = date('2999-12-31')
         AND vz.PERSONENKREIS = 'Beschäftigte'
         AND vz.BEITRAGSGRUPPEKV_IID > 0
         AND vz.PERSONENGRUPPENSCHLUESSEL IN (101, 102, 103, 118, 119)
         JOIN T_VERSICHERTEPERSON vp
            ON vp.OID = vz.VERSPERS_VERSPERSON_ID
            AND ('1' = '0' or '1' = '1' and (vp.VIPKENNZEICHEN is null or  NOT vp.VIPKENNZEICHEN is null and vp.VIPKENNZEICHEN  NOT  in (5, 6)))

The Group By Clause I have to get in there:

GROUP BY vz."VALIDTO", vz."BETRIEBSNUMMER"

I’m not really an expert in SQL. Hope you guys can help me out a little. 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T04:01:08+00:00Added an answer on June 14, 2026 at 4:01 am

    When using a group by clause, any element in the select clause must either be in the group by clause, or an aggregate function (sum, max, etc)

    So

    SELECT 
       btst.Ordnungsbegriff AS BBNR,
       COUNT(vp.KVNR) 
       FROM 
    
       ...
    GROUP BY vz."VALIDTO", vz."BETRIEBSNUMMER", btst.Ordnungsbegriff 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have little unusual problem to solve. I need some hint or links to
I got a little problem. I'm using Full outer Join in Sql server -
I'm a little new to SQL and have come across the following problem. I
I'm new to sql, and came across a little problem. I have a query
I have a confusing little problem in SQL-Server 2005 and Classic ASP. I have
I have a little Problem with sql again :) In this example I have
I have a little problem with a left join where I want a list
I have little problem with a replacement of a little part in an url.
I have little problem in regular expressin creation. Expected input: blahblahblah, blahblahblah, 'blahblahblah', blahblahblah,
I have a little problem about the sort direction of a specific column in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.