?
Solved

Server: Msg 170, Level 15, State 1, Procedure UB_GAT, Line 68

Posted on 2005-05-13
3
Medium Priority
?
499 Views
Last Modified: 2008-02-01
Can somebody help me correct script. I get this error

Server: Msg 170, Level 15, State 1, Procedure UB_GAT, Line 68
Line 68: Incorrect syntax near ','.
The line indicates at               PRODUKT_PARTNER), ..in group_ by
.................................................................

create view USH as
select MONAT,
           BLZ,
           ZWEIGSTELLE,
           PRODUKT_PARTNER,
           left(USERID,8) MITARB_USERID_ID,
           MONAT + BLZ + ZWEIGSTELLE + PRODUKT_PARTNER + left(USERID,8) + '                   ' UB_STAT_ID,
           MONAT + 'G' + left(USERID,8) UB_FILTER_U,
           BRUTTO,
           BRUTTO_YTM,
           NETTO,
           NETTO_YTM,
           RUECKFLUSS,
           RUECKFLUSS_YTM,
           BESTAND ,
           ANZ_DEP_NEU,
           ANZ_DEP_NEU_YTM,
           ANZ_DEP
from
(select MONAT,
           BLZ,
           ZWEIGSTELLE,
           PRODUKT_PARTNER,
           sum(BRUTTO) BRUTTO,
           sum(BRUTTO_YTM) BRUTTO_YTM,
           sum(NETTO) NETTO,
           sum(NETTO_YTM) NETTO_YTM,
           sum(RUECKFLUSS) RUECKFLUSS,
           sum(RUECKFLUSS_YTM) RUECKFLUSS_YTM,
           sum(BESTAND) BESTAND ,
           sum(ANZ_DEP_NEU) ANZ_DEP_NEU,
           sum(ANZ_DEP_NEU_YTM) ANZ_DEP_NEU_YTM,
           sum(ANZ_DEP) ANZ_DEP
from UB_stat
where partner = 'BH'
group by MONAT,
             BLZ,
                 ZWEIGSTELLE,
             PRODUKT_PARTNER),
userlogin



0
Comment
Question by:veshan
  • 2
3 Comments
 
LVL 53

Accepted Solution

by:
Vitor Montalvão earned 400 total points
ID: 13994763
You need to give an alias to the second select. Something like:
create view USH as
select MONAT,
           BLZ,
           ZWEIGSTELLE,
           PRODUKT_PARTNER,
           left(USERID,8) MITARB_USERID_ID,
           MONAT + BLZ + ZWEIGSTELLE + PRODUKT_PARTNER + left(USERID,8) + '                   ' UB_STAT_ID,
           MONAT + 'G' + left(USERID,8) UB_FILTER_U,
           BRUTTO,
           BRUTTO_YTM,
           NETTO,
           NETTO_YTM,
           RUECKFLUSS,
           RUECKFLUSS_YTM,
           BESTAND ,
           ANZ_DEP_NEU,
           ANZ_DEP_NEU_YTM,
           ANZ_DEP
from
(select MONAT,
           BLZ,
           ZWEIGSTELLE,
           PRODUKT_PARTNER,
           sum(BRUTTO) BRUTTO,
           sum(BRUTTO_YTM) BRUTTO_YTM,
           sum(NETTO) NETTO,
           sum(NETTO_YTM) NETTO_YTM,
           sum(RUECKFLUSS) RUECKFLUSS,
           sum(RUECKFLUSS_YTM) RUECKFLUSS_YTM,
           sum(BESTAND) BESTAND ,
           sum(ANZ_DEP_NEU) ANZ_DEP_NEU,
           sum(ANZ_DEP_NEU_YTM) ANZ_DEP_NEU_YTM,
           sum(ANZ_DEP) ANZ_DEP
from UB_stat
where partner = 'BH'
group by MONAT,
             BLZ,
                 ZWEIGSTELLE,
             PRODUKT_PARTNER) MyAlias,
userlogin
0
 
LVL 53

Expert Comment

by:Vitor Montalvão
ID: 13994770
By the way, you posted an incomplete query , right?
0
 
LVL 11

Assisted Solution

by:lluthien
lluthien earned 100 total points
ID: 13994771
you need to give the subquery an alias...
like so:
(select MONAT,
           BLZ,
           ZWEIGSTELLE,
           PRODUKT_PARTNER,
           sum(BRUTTO) BRUTTO,
           sum(BRUTTO_YTM) BRUTTO_YTM,
           sum(NETTO) NETTO,
           sum(NETTO_YTM) NETTO_YTM,
           sum(RUECKFLUSS) RUECKFLUSS,
           sum(RUECKFLUSS_YTM) RUECKFLUSS_YTM,
           sum(BESTAND) BESTAND ,
           sum(ANZ_DEP_NEU) ANZ_DEP_NEU,
           sum(ANZ_DEP_NEU_YTM) ANZ_DEP_NEU_YTM,
           sum(ANZ_DEP) ANZ_DEP
from UB_stat
where partner = 'BH'
group by MONAT,
             BLZ,
                 ZWEIGSTELLE,
             PRODUKT_PARTNER) mySubQuery
,

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Suggested Courses

862 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