Thomas Alexander Sekkelsten Tryde

> 
> Select count(*) / (Select count(*) From TBL_SOME) As 'Percent'
> Where SomeValue = <something>
> 
> How can someone get around this problem easily if sub selects aren't'
> allowed?
> 
> Here there is a sub query in a column spec. It's a 
> functionality that works
> in MS SQL Server and MS Access 2000. It doesn't work in 
> MySQL. There isn't
> necessary to create a lot of views when you put sub selects 
> in the column
> list.
> 
> Thomas Tryde


Select count_all / count_some
from
  (select count(*) count_all      from table_all) tab1,
  (select count(*) count_some from TBL_SOME 
       where SomeValue = <something>) tab2

With SAP DB 7.3 this will help assuming that table_all
is the table you want to select your first count (*) from
(not given above)

Select in select_list is available in 7.4.x (x > beta), will not be in 7.3.

Elke
SAP Labs Berlin



> 
> "Florian K�rner" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi,
> 
> I have never seen a subquery in a result column spec, so it 
> is probably not
> allowed here.
> What do you want to get here? Would you like to have the same 
> result of the
> subquery in every row of your result set? Or do you need 
> something like a
> correlated subquery that selects something depending on some 
> column value of
> the actual row of the main query?
> 
> Florian Kaerner
> -----Urspr�ngliche Nachricht-----
> Von: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]Im Auftrag von 
> Gustavo Comba
> Gesendet: Montag, 25. November 2002 16:10
> An: [EMAIL PROTECTED]
> Betreff: Subquery not allowed
> 
> 
> Hi,
> 
>     I'm performing a simple query on my database and I'm 
> getting a "-7056
> Subquery not allowed" for response. The query is:
> 
> SELECT
>  "MONITOR"."PIEZAS"."IDPIEZA",
>  "MONITOR"."PIEZAS"."IDDISPOSITIVO",
>  "MONITOR"."PLATOS"."IDMODELO",
>  "MONITOR"."PIEZAS"."CODIGOPIEZA",
>  "MONITOR"."PIEZAS"."CODIGOLOTE",
>  "MONITOR"."PIEZAS"."FECHACREACION",
>  "MONITOR"."PIEZAS"."FECHACREACION" AS "FECHAMODIFICACION",
>             'Sistema' AS "USUARIO",
>             "MONITOR"."DISPOSITIVOS"."NOMBRE",
>             "MONITOR"."PLATOS"."PESO",
>             NUM("MONITOR"."PLATOS"."PESOOK") AS "PESOCORRECTO",
>  "MONITOR"."PLATOS"."DIAMETRO",
>  NUM("MONITOR"."PLATOS"."DIAMETROOK") AS "DIAMETROCORRECTO",
>  NUM("MONITOR"."PIEZAS"."FALLIDA") AS "PIEZAFALLIDA",
>  "MONITOR"."PIEZAS"."FECHACREACION" AS "ORDEN",
>             (SELECT COUNT(*) FROM PLATOS_ERRORES
>                 WHERE PLATOS_ERRORES.IDDISPOSITIVO = 
> PLATOS.IDDISPOSITIVO
>                 AND PLATOS_ERRORES.IDPIEZA = PLATOS.IDPIEZA
>             ) AS FALLOS
> FROM "MONITOR"."PIEZAS","MONITOR"."PLATOS", "MONITOR"."DISPOSITIVOS"
> WHERE "MONITOR"."PIEZAS"."IDDISPOSITIVO"= 
> "MONITOR"."PLATOS"."IDDISPOSITIVO"
> AND  "MONITOR"."PIEZAS"."IDPIEZA"= "MONITOR"."PLATOS"."IDPIEZA"
> AND "MONITOR"."PIEZAS"."IDDISPOSITIVO"=
> "MONITOR"."DISPOSITIVOS"."IDDISPOSITIVO"
> AND "MONITOR"."PLATOS"."IDMODELO" = 2
> 
>     I've found the error's explanation on the documentation:
> -7056: Subquery not allowed
> Explanation:
> A <SUBQUERY> specification in a <CONSTRAINT DEFINITION> is 
> not allowed.
> 
>     But I think I'm not using the subquery on a "<CONSTRAINT 
> DEFINITION>",
> only on the "select" list... I think my query is normal.
> 
>     What's happening? Has somebody any clue?
> 
>         Thanks in advance,
> 
>                 Gustavo Comba
> 
> 
> 
> 
> _______________________________________________
> sapdb.general mailing list
> [EMAIL PROTECTED]
> http://listserv.sap.com/mailman/listinfo/sapdb.general
> 
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general

Reply via email to