On Sat, May 2, 2009 at 6:13 AM, Ernany <ernan...@gmail.com> wrote:
> Hello John,
>
> I have 2 tables ("pcprod" and "pcdesc"). I´d like to *add *in my application
> "MARCA" and "DESCR".
>
> This code is VB2005 .NET. How do I write SQL???

http://www.google.com/search?q=sql+tutorial


>
> Thanks a lot
>
> Ernany
>
>
> '***************************************************************
>
>  Dim dr As Data.SQLite.SQLiteDataReader
>  Dim BdMain As New ClsBD
>  Dim ContLinhas As Integer = 0
>  Dim indice As Integer = 1
>  Dim indiceLinha As Integer = 119
>
>
>  BdMain.AbreBD()
>
>  dr = BdMain.SQLRetornaDR("SELECT SUM(qtde) AS cont, codigo FROM pcdesc
> GROUP BY codigo")
>  While dr.Read
>            ContLinhas = ContLinhas + 1
>            SerialPortLeitura.WriteLine("T 2 0 7 " & indiceLinha & " " &
> indice & "- ") 'Indice
>            SerialPortLeitura.WriteLine("T 2 0 96 " & indiceLinha & " " &
> dr("codigo")) 'Codigo
>            SerialPortLeitura.WriteLine("T 2 0 403 " & indiceLinha & " " &
> dr("cont")) 'Quantidade
>
> *add   **"MARCA" and "DESCR"*  *??????*
>
>  dr.Close()
>
>
>
> '***************************************************************'***************************************************************
> '***************************************************************'***************************************************************
> '***************************************************************'***************************************************************
>
>
> 2009/5/2 John Machin <sjmac...@lexicon.net>
>
>> On 2/05/2009 4:21 PM, Ernany wrote:
>> > Hello,
>> >
>> > CREATE TABLE [pcprod] (
>> >   [codigo] NVARCHAR(20) NOT NULL ON CONFLICT ABORT PRIMARY KEY,
>> >   [descr] NVARCHAR(40),
>> >   [marca] NVARCHAR(20),
>> >   [codigoint] NVARCHAR(20),
>> >   [preco] NUMERIC(5, 7),
>> >   [preco2] NUMERIC(5, 7));
>> >
>> >
>> >
>> > CREATE TABLE [pcdesc] (
>> >   [codigo] NVARCHAR(20),
>> >   [qtde] NUMERIC(5, 6),
>> >   [loja] INTEGER,
>> >   [secao] INTEGER,
>> >   [coletor] INTEGER,
>> >   [hora] NVARCHAR(8),
>> >   [dia] NVARCHAR(8),
>> >   [chave] GUID PRIMARY KEY);
>> >
>> >
>> > This "Select "  is ok.
>> > SELECT SUM(qtde) AS cont, codigo FROM pcdesc GROUP BY codigo"
>> >
>> >
>> > But  I need  the fields "*marca*" and "*descr*".
>> >
>> > select SUM(qtde) AS cont, descr , codigo FROM pcdesc GROUP BY codigo,
>> > descr    ????? Wrong.....
>>
>> There is no column named "descr" in the "pcdesc" table. What error code
>> or message did you get from your (unspecified) interface? What did you
>> not understand about the error code or message?
>>
>> The command-line executable "sqlite3" tells you rather explicitly:
>>
>> sqlite> CREATE TABLE [pcdesc] (
>>     ...>   [codigo] NVARCHAR(20),
>>    ...>   [qtde] NUMERIC(5, 6),
>>    ...>   [loja] INTEGER,
>>    ...>   [secao] INTEGER,
>>    ...>   [coletor] INTEGER,
>>    ...>   [hora] NVARCHAR(8),
>>    ...>   [dia] NVARCHAR(8),
>>    ...>   [chave] GUID PRIMARY KEY);
>> sqlite> SELECT SUM(qtde) AS cont, codigo FROM pcdesc GROUP BY codigo;
>> sqlite> select SUM(qtde) AS cont, descr , codigo FROM pcdesc GROUP BY
>> codigo,
>>    ...> descr;
>> SQL error: no such column: descr
>> sqlite>
>>
>> By the way, those brackets around the column names are quite unnecessary
>> (your first SQL statement works OK withouit them, doesn't it?) and are
>> NOT standard SQL.
>>
>> HTH,
>> John
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to