Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

MS Access SQL Fehler

Empfohlene Antworten

Veröffentlicht

Hallo zusammen,

ich habe folgenden rießen SQL und folgende Fehlermeldung:

Fehlermeldung:

Unzulässiges einklammern des Namens 'select '1' as Sortierung, Firma ...'


SELECT Firma, Zielrufnummer, Datum, Uhrzeit, Nebenstelle, Standardpreis, Bonuspreis

FROM [select '1' as Sortierung, Firma,Nebenstelle, Datum, Uhrzeit, Standardpreis, Bonuspreis, Zielrufnummer from (


select 

    ( select round(sum(evn.[Dauer/Sek])/60) from evn) AS Gesamtzeit,

    'Geopost'  as Firma,

    evn.Nebenstelle, evn.Datum, evn.Uhrzeit, 

     evn.[Dauer/Sek] as Dauer, 

     iif(Gesamtzeit < 1755000,round(((evn.[Dauer/Sek] / 60)* tarif.Malus), 4),0) as Maluspreis,

     iif(Gesamtzeit <= 2145000 AND Gesamtzeit > 1755000,round(((evn.[Dauer/Sek] / 60)* tarif.Standard), 4),0) as Standardpreis,

     iif (Gesamtzeit > 2145000, round(((evn.[Dauer/Sek] / 60)* tarif.Bonus), 4), 0) as Bonuspreis, 

    evn.Zielrufnummer

    FROM evn,tarif,vpn where evn.artikelnr = tarif.artikelnr and vpn.tel2 = '4925' and evn.fkto = vpn.fkto and  instr(';7258;7274;7253;7266;7249;7251;7252;'+

'7001;7009;7011;7091;7071;7081;7031;7041;7043;7051;7068;7021;7066;7022;7016;7065;7061;7005;7013;7011;',';' +evn.Nebenstelle+ ';') ) as Unterselect1

union

select '1.1' as Sortierung, '' As Firma, '' As Nebenstelle, '' As Datum, '' As Uhrzeit, '' As Maluspreis, '' As Standardpreis, '' As Bonuspreis, '' As Zielrufnummer from (

select min(1) from evn where 1 = 2) as tempselect

union

select '1.2' as Sortierung, FirmaGesamt, '' As Nebenstelle, '' As Datum, '' As Uhrzeit, Malusgesamtpreis, Standardgesamtpreis, Bonusgesamtpreis, '' As Zielrufnummer from (


SELECT '', 'Geopost-Gesamt' as FirmaGesamt , '', '',

( select round(sum(evn.[Dauer/Sek])/60) from evn) AS Gesamtzeit,

     iif( Firma = 'Delicom', 497, 0) as Grundgebuehr,

iif(Gesamtzeit < 1755000,round(((sum(Dauer*maluspreis)/60) +Grundgebuehr),2),0) AS Malusgesamtpreis,     

iif(Gesamtzeit <= 2145000 AND Gesamtzeit > 1755000,round(((sum(Dauer*standardpreis)/60) +Grundgebuehr),2),0) AS Standardgesamtpreis, 

iif (Gesamtzeit > 2145000, round(((sum(Dauer*bonuspreis)/60) + Grundgebuehr),2),0) AS Bonusgesamtpreis, ''

FROM (



select 

    'Geopost'  as Firma,

     evn.[Dauer/Sek] as Dauer, tarif.Malus as maluspreis, tarif.Standard as standardpreis, tarif.Bonus as bonuspreis

    FROM evn,tarif,vpn where evn.artikelnr = tarif.artikelnr and vpn.tel2 = '4925' and evn.fkto = vpn.fkto and  instr(';7258;7274;7253;7266;7249;7251;7252;'+

'7001;7009;7011;7091;7071;7081;7031;7041;7043;7051;7068;7021;7066;7022;7016;7065;7061;7005;7013;7011;',';' +evn.Nebenstelle+ ';'))  AS Unterselect GROUP BY firma) as Unterselect2



union

select '1.3' as Sortierung, '' As Firma, '' As Nebenstelle, '' As Datum, '' As Uhrzeit, '' As Maluspreis, '' As Standardpreis, '' As Bonuspreis, '' As Zielrufnummer from (

select min(1) from evn where 1 = 2) as tempselect

union

select '1.3.1' as Sortierung, '' As Firma, '' As Nebenstelle, '' As Datum, '' As Uhrzeit, '' As Maluspreis, '' As Standardpreis, '' As Bonuspreis, '' As Zielrufnummer from (

select min(1) from evn where 1 = 2) as tempselect



union

select '2' as Sortierung, Firma,Nebenstelle, Datum, Uhrzeit, Maluspreis, Standardpreis, Bonuspreis, Zielrufnummer from (


select 

    ( select round(sum(evn.[Dauer/Sek])/60) from evn) AS Gesamtzeit,

    'GmbH' as Firma, evn.Nebenstelle, evn.Datum, evn.Uhrzeit, 

     evn.[Dauer/Sek] as Dauer, 

     iif(Gesamtzeit < 1755000,round(((evn.[Dauer/Sek] / 60)* tarif.Malus), 4),0) as Maluspreis,

     iif(Gesamtzeit <= 2145000 AND Gesamtzeit > 1755000,round(((evn.[Dauer/Sek] / 60)* tarif.Standard), 4),0) as Standardpreis,

     iif (Gesamtzeit > 2145000, round(((evn.[Dauer/Sek] / 60)* tarif.Bonus), 4), 0) as Bonuspreis, 

    evn.Zielrufnummer

    FROM evn,tarif,vpn where evn.artikelnr = tarif.artikelnr and vpn.tel2 = '4925' and evn.fkto = vpn.fkto and  instr(';6015;6017;6018;6021;6012;6014;6007;6011;6054;6019;6020;',';' +evn.Nebenstelle+ ';') ) as Unterselect1


union

select '2.1' as Sortierung, '' As Firma, '' As Nebenstelle, '' As Datum, '' As Uhrzeit, '' As Maluspreis,, '' As Standardpreis, '' As Bonuspreis, '' As Zielrufnummer from (

select min(1) from evn where 1 = 2) as tempselect

union

select '2.2' as Sortierung,  FirmaGesamt, '' As Nebenstelle, '' As Datum, '' As Uhrzeit, Malusgesamtpreis, Standardgesamtpreis, Bonusgesamtpreis, '' As Zielrufnummer from (


SELECT '', 'GmbH-Gesamt' as FirmaGesamt, '', '',

( select round(sum(evn.[Dauer/Sek])/60) from evn) AS Gesamtzeit,

     iif( Firma = 'Delicom', 497, 0) as Grundgebuehr,

iif(Gesamtzeit < 1755000,round(((sum(Dauer*maluspreis)/60) +Grundgebuehr),2),0) AS Malusgesamtpreis, 

iif(Gesamtzeit <= 2145000 AND Gesamtzeit > 1755000,round(((sum(Dauer*standardpreis)/60) +Grundgebuehr),2),0) AS Standardgesamtpreis, 

iif (Gesamtzeit > 2145000, round(((sum(Dauer*bonuspreis)/60) + Grundgebuehr),2),0) AS Bonusgesamtpreis, ''

FROM (


select 

     'GmbH' as Firma,

     evn.[Dauer/Sek] as Dauer, tarif.Malus as maluspreis, tarif.Standard as standardpreis, tarif.Bonus as bonuspreis

    FROM evn,tarif,vpn where evn.artikelnr = tarif.artikelnr and vpn.tel2 = '4925' and evn.fkto = vpn.fkto and  instr(';6015;6017;6018;6021;6012;6014;6007;6011;6054;6019;6020;',';' +evn.Nebenstelle+ ';'))  AS Unterselect  GROUP BY firma) as Unterselect2


union


select '2.3' as Sortierung, '' As Firma, '' As Nebenstelle, '' As Datum, '' As Uhrzeit, '' As Maluspreis, '' As Standardpreis, '' As Bonuspreis, '' As Zielrufnummer from (

select min(1) from evn where 1 = 2) as tempselect

union

select '2.3.1' as Sortierung, '' As Firma, '' As Nebenstelle, '' As Datum, '' As Uhrzeit, '' As Maluspreis, , '' As Standardpreis, '' As Bonuspreis, '' As Zielrufnummer from (

select min(1) from evn where 1 = 2) as tempselect


union


select '3' as Sortierung, Firma,Nebenstelle, Datum, Uhrzeit, Maluspreis, Standardpreis, Bonuspreis, Zielrufnummer from (

select 

    ( select round(sum(evn.[Dauer/Sek])/60) from evn) AS Gesamtzeit,

      'Delicom' as Firma, evn.Nebenstelle, evn.Datum, evn.Uhrzeit, 

     evn.[Dauer/Sek] as Dauer, 

     iif(Gesamtzeit < 1755000,round(((evn.[Dauer/Sek] / 60)* tarif.Malus), 4),0) as Maluspreis,

     iif(Gesamtzeit <= 2145000 AND Gesamtzeit > 1755000,round(((evn.[Dauer/Sek] / 60)* tarif.Standard), 4),0) as Standardpreis,

     iif (Gesamtzeit > 2145000, round(((evn.[Dauer/Sek] / 60)* tarif.Bonus), 4), 0) as Bonuspreis, 

    evn.Zielrufnummer

    FROM evn,tarif,vpn where evn.artikelnr = tarif.artikelnr and vpn.tel2 = '4925' and evn.fkto = vpn.fkto

 and not  instr(';7258;7274;7253;7266;7249;7251;7252;'+

'7001;7009;7011;7091;7071;7081;7031;7041;7043;7051;7068;7021;7066;7022;7016;7065;7061;7005;7013;7011;6015;6017;6018;6021;6012;6014;6007;6011;6054;6019;6020;',';' +evn.Nebenstelle+ ';') 

) as Unterselect1


where firma = 'Delicom'

union

select '3.1' as Sortierung, '' As Firma, '' As Nebenstelle, '' As Datum, '' As Uhrzeit, '' As Maluspreis, '' As Standardpreis, '' As Bonuspreis, '' As Zielrufnummer from (

select min(1) from evn where 1 = 2) as tempselect

union

select '3.2' as Sortierung, FirmaGesamt, '' As Nebenstelle, '' As Datum, '' As Uhrzeit, Malusgesamtpreis, Standardgesamtpreis, Bonusgesamtpreis, '' As Zielrufnummer from (


SELECT '', 'Delicom-Gesamt' as FirmaGesamt, '', '',

( select round(sum(evn.[Dauer/Sek])/60) from evn) AS Gesamtzeit,

     iif( Firma = 'Delicom', 497, 0) as Grundgebuehr,

iif(Gesamtzeit < 1755000,round(((sum(Dauer*maluspreis)/60) +Grundgebuehr),2),0) AS Malusgesamtpreis, 

iif(Gesamtzeit <= 2145000 AND Gesamtzeit > 1755000,round(((sum(Dauer*standardpreis)/60) +Grundgebuehr),2),0) AS Standardgesamtpreis, 

iif (Gesamtzeit > 2145000, round(((sum(Dauer*bonuspreis)/60) + Grundgebuehr),2),0) AS Bonusgesamtpreis, ''

FROM (



select 

     'Delicom' as Firma,

     evn.[Dauer/Sek] as Dauer, tarif.Malus as maluspreis, tarif.Standard as standardpreis, tarif.Bonus as bonuspreis

    FROM evn,tarif,vpn where evn.artikelnr = tarif.artikelnr and vpn.tel2 = '4925' and evn.fkto = vpn.fkto

and not  instr(';7258;7274;7253;7266;7249;7251;7252;'+

'7001;7009;7011;7091;7071;7081;7031;7041;7043;7051;7068;7021;7066;7022;7016;7065;7061;7005;7013;7011;6015;6017;6018;6021;6012;6014;6007;6011;6054;6019;6020;',';' +evn.Nebenstelle+ ';'))  AS Unterselect GROUP BY firma) as Unterselect2


union

select '3.3' as Sortierung, '' As Firma, '' As Nebenstelle, '' As Datum, '' As Uhrzeit, '' As Maluspreis, '' As Standardpreis, '' As Bonuspreis, '' As Zielrufnummer from (

select min(1) from evn where 1 = 2) as tempselect

union

select '3.3.1' as Sortierung, '' As Firma, '' As Nebenstelle, '' As Datum, '' As Uhrzeit, '' As Maluspreis, '' As Standardpreis, '' As Bonuspreis, '' As Zielrufnummer from (

select min(1) from evn where 1 = 2) as tempselect

]. AS Hauptselect;

Kann mir jmd helfen?

Du musst dir schon erstmal selbst Muehe geben und zumindest die Unions aufloesen. Dann ist das Ganze nicht mehr so gross und du findest den Fehler auch selbst ganz leich (vermute ich).

Goos

Du musst dir schon erstmal selbst Muehe geben und zumindest die Unions aufloesen. Dann ist das Ganze nicht mehr so gross und du findest den Fehler auch selbst ganz leich (vermute ich).

Goos

wie kann ich ein union auflösen?

kannst du mir das an nem kleinen beispiel erläutern?

Na du hast zwischen den ganzen Unions lauter einzelne Selects, die ansich auch alle einzeln funktionieren sollten. Also kannst der Reihe nach immer ein Select Statement rauskopieren und testen. So hast die Moeglichkeit, einen Fehler in einem davon zu entdecken.

Goos

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.