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 9235447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:02:04+00:00 2026-06-18T07:02:04+00:00

I have a problem with my stored procedure, when I run I have this

  • 0

I have a problem with my stored procedure, when I run I have this error:

ADO EROR: Incorrect syntax near the keyword ” where “

I want to display 2 fileds counted by on filed where i have companies that area selected by year 2012

This is my query:

    ALTER PROCEDURE ProceduraCalculareAuto
      AS
       SELECT ФИРМА.НаимПредпр
         FROM  dbo.ФИРМА  LEFT OUTER JOIN
                  dbo.АВТОМОБ ON dbo.АВТОМОБ.КодПредпр = dbo.ФИРМА.КодПредпр INNER JOIN
                      dbo.КАРНЕТ ON dbo.КАРНЕТ.КодПредпр = dbo.ФИРМА.КодПредпр 
                  INNER JOIN
    (SELECT Tegaci = COUNT
            (CASE [КодПриц/Тягач]
                  WHEN 4 THEN  [КодПриц/Тягач] 
                END),
            Auto = COUNT
         (CASE [КодПриц/Тягач]
          WHEN 3 THEN  [КодПриц/Тягач] 
                         END)
          FROM     dbo.АВТОМОБ
                 GROUP BY dbo.АВТОМОБ.[КодПриц/Тягач] )
      WHERE(dbo.КАРНЕТ.ДтВыдачи BETWEEN CONVERT(DATETIME, '2012-01-01 00:00:00',  
       102) AND CONVERT(DATETIME, '2012-12-31 00:00:00', 102))
      GROUP BY ФИРМА.НаимПредпр

 RETURN
  • 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-18T07:02:06+00:00Added an answer on June 18, 2026 at 7:02 am

    You are missing an alias for the subquery. In SQL Server every derived table and subquery needs an alias. You are also missing the ON clause to join the subquery to the rest of your query:

    SELECT ФИРМА.НаимПредпр
    FROM  dbo.ФИРМА  
    LEFT OUTER JOIN dbo.АВТОМОБ 
      ON dbo.АВТОМОБ.КодПредпр = dbo.ФИРМА.КодПредпр 
    INNER JOIN dbo.КАРНЕТ 
      ON dbo.КАРНЕТ.КодПредпр = dbo.ФИРМА.КодПредпр 
    INNER JOIN
    (
      SELECT Tegaci = COUNT
                (CASE [КодПриц/Тягач]
                      WHEN 4 THEN  [КодПриц/Тягач] 
                    END),
                Auto = COUNT
             (CASE [КодПриц/Тягач]
              WHEN 3 THEN  [КодПриц/Тягач] 
                             END)
      FROM     dbo.АВТОМОБ
      GROUP BY dbo.АВТОМОБ.[КодПриц/Тягач] 
    )  src 
       -- this needs an alias and it also needs a join condition. 
      on etc = src.
    WHERE(dbo.КАРНЕТ.ДтВыдачи BETWEEN CONVERT(DATETIME, '2012-01-01 00:00:00',  
           102) AND CONVERT(DATETIME, '2012-12-31 00:00:00', 102))
    GROUP BY ФИРМА.НаимПредпр
    

    I am guessing on the join columns, but I think you might want this:

    SELECT ФИРМА.НаимПредпр
    FROM  dbo.ФИРМА  
    LEFT OUTER JOIN dbo.АВТОМОБ 
      ON dbo.АВТОМОБ.КодПредпр = dbo.ФИРМА.КодПредпр 
    INNER JOIN dbo.КАРНЕТ 
      ON dbo.КАРНЕТ.КодПредпр = dbo.ФИРМА.КодПредпр 
    INNER JOIN
    (
      SELECT Tegaci = COUNT
                (CASE [КодПриц/Тягач]
                      WHEN 4 THEN  [КодПриц/Тягач] 
                    END),
                Auto = COUNT
             (CASE [КодПриц/Тягач]
              WHEN 3 THEN  [КодПриц/Тягач] 
                             END),
          dbo.АВТОМОБ.[КодПриц/Тягач]
      FROM     dbo.АВТОМОБ
      GROUP BY dbo.АВТОМОБ.[КодПриц/Тягач] 
    )  src 
       -- this needs an alias and it also needs a join condition. 
      on dbo.АВТОМОБ.[КодПриц/Тягач] = src.[КодПриц/Тягач] 
    WHERE(dbo.КАРНЕТ.ДтВыдачи BETWEEN CONVERT(DATETIME, '2012-01-01 00:00:00',  
           102) AND CONVERT(DATETIME, '2012-12-31 00:00:00', 102))
    GROUP BY ФИРМА.НаимПредпр
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this stored procedure for Oracle: create or replace procedure bns_saa_message_get() <--- PROBLEM
I am basically getting this error when trying to run a stored procedure from
I have a problem when debugging stored procedure using SQL server Management Studio 2008.
So here is my problem, I have written a stored procedure to do the
The Problem I have a CakePHP application in which I call a stored procedure:
I have this Stored procedure on my sql server : [InsertRecord] @param1 varchar(10), @Param2
I am having a strange problem with MySQL Stored Procedure. I have written a
I'm using devexpress and i have two problems. My insert stored procedure work fine.
Im create this code to store page view in database, but i have problem
I have a problem with the system function. I want to store the system

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.