Forum Stats

  • 3,759,224 Users
  • 2,251,514 Discussions
  • 7,870,541 Comments

Discussions

How make column with .dot work in select statement?

jdev1
jdev1 Member Posts: 222 Green Ribbon

Hello,

But my table column name is eil.skaicius, I am getting error "." I have tried to make like this: "eil.skaicius",

'eil.skaicius', eil.skaicius`eil.skaicius`. With these all I am getting same error. How to fix it?


SELECT rws.zu0_kod AS zu0_kod,     
   rws.did_nr  AS did_nr,
   rws.adm_var AS adm_var,
   rws.did_dat AS did_dat
   ,COUNT (1)  AS eil.skaicius


Tagged:
«13

Answers

  • User_H3J7U
    User_H3J7U Member Posts: 485 Bronze Trophy

    SQL Language Reference/Object names

    But my table column name is eil.skaicius

    The name of the query column does not have to match some field of some table.

  • jdev1
    jdev1 Member Posts: 222 Green Ribbon

    But I have column named eil.skaicius, whenever run slq code getting "." error.

  • KayK
    KayK Member Posts: 1,679 Bronze Crown
    edited Sep 6, 2021 10:52AM

    Ho jdev,

    what do you want to achieve ? I don't see a column_name in your code only an alias.

    And the alias works for me with double quote marks

    < tvratio:op57 > SELECT COUNT (1) AS eil.skaicius from dual;
    SELECT COUNT (1) AS eil.skaicius from dual
                           *
    ERROR at line 1:
    ORA-00923: FROM keyword not found where expected
    
    < tvratio:op57 > SELECT COUNT (1) AS "eil.skaicius" from dual;
    
    eil.skaicius
    ------------
              1
    
    1 row selected.
    

    regards

    Kay

  • jdev1
    jdev1 Member Posts: 222 Green Ribbon

    DataSource.Error: ODBC: ERROR [42601] ERROR: syntax error at or near "AS";

    Error while executing the query

    Details:

      DataSourceKind=Odbc

      DataSourcePath=dsn=dbname

      OdbcErrors=[Table]


    SQL:

    SELECT rws.zu0_kod AS zu0_kod,     
       rws.did_nr  AS did_nr,
       rws.adm_var AS adm_var,
       rws.did_dat AS did_dat
       ,COUNT (1)  AS eil_skaicius
     FROM (SELECT tab1.zu0_kod,
         tab1.did_nr,
         tab1.adm_var,
         tab1.did_dat
       FROM (SELECT id_vidp AS id_vidp2,
          zu0_kod  AS zu0_kod,
            AS did_nr,
          adm_var AS adm_var,
          did_dat AS did_dat
         FROM a.vidp
         WHERE a.vidp.did_dat >= filterdate) tab1
         LEFT OUTER JOIN a.vidp tab2
         ON tab1.id_vidp2 = tab2.id_vidp) rws
    GROUP BY rws.zu0_kod,
       rws.did_nr,
       rws.adm_var,
       rws.did_dat
    


  • jdev1
    jdev1 Member Posts: 222 Green Ribbon

    @KayK

    With double quotes also not works. I am getting the same error.

  • KayK
    KayK Member Posts: 1,679 Bronze Crown
     ,COUNT (1)  AS eil_skaicius
    

    and where is dot from your original posting ?

  • jdev1
    jdev1 Member Posts: 222 Green Ribbon

    I have tried to change for testing purposes. But ,count(1) as "eil.skaicius" not works.

  • KayK
    KayK Member Posts: 1,679 Bronze Crown
    edited Sep 6, 2021 10:57AM

    There is a missing column name here:


  • jdev1
    jdev1 Member Posts: 222 Green Ribbon
    edited Sep 6, 2021 11:27AM

    I don't have errors but with this sql getting empty table. How to solve it?

    SELECT rws.zu0_kod AS zu0_kod,     
       rws.did_nr  AS did_nr,
       rws.adm_var AS adm_var,
       rws.did_dat AS did_dat
       ,COUNT (1)  AS ""eil.skaicius""
     FROM (SELECT tab1.zu0_kod,
         tab1.did_nr,
         tab1.adm_var,
         tab1.did_dat
       FROM (SELECT id_vidp AS id_vidp2,
          zu0_kod  AS zu0_kod,
           did_nr AS did_nr,
          adm_var AS adm_var,
          did_dat AS did_dat
         FROM public.vidp
         WHERE public.vidp.did_dat >= '" & sFilterDate & "') tab1
         LEFT OUTER JOIN public.vidp tab2
         ON tab1.id_vidp2 = tab2.id_vidp) rws
    GROUP BY rws.zu0_kod,
       rws.did_nr,
       rws.adm_var,
       rws.did_dat
    

    Here is output.

  • KayK
    KayK Member Posts: 1,679 Bronze Crown

    No one can say why your select gets no results, we don't know your data.

    My first thought is check your where-clause.

    What do you want to achieve this

    WHERE public.vidp.did_dat >= '" & sFilterDate & "') tab1
    

    Which tool do you use ? Can you reproduce the empty result in sql*plus ?

    What happens if you elimate the where clause with something like this

    /* WHERE public.vidp.did_dat >= '" & sFilterDate & "' */ ) tab1