[SQL]

2003-11-07 Thread ronald

Hello everyone, Good day! Could anyone help me translate this query in Microsoft
Access to Postgresql. I'm having a difficulty. Pls...

Query1:
SELECT items.description, Sum(supplieditems.qty) AS SumOfqty
FROM items INNER JOIN supplieditems ON items.itemno = supplieditems.itemno
GROUP BY items.description;

Query2:
SELECT [items].[description], Sum([customer].[qty]) AS SumOfqty
FROM (items INNER JOIN OtherItem ON [items].[itemno]=[OtherItem].[Itemno]) INNER
JOIN customer ON [OtherItem].[Itemno]=[customer].[itemcode]
GROUP BY [items].[description];

Query3:
SELECT [Query1].[SumOfqty], [Query2].[SumOfqty],
[Query1]![SumOfqty]-[Query2]![SumOfqty] AS remain
FROM Query1, Query2;

I have translated Query1 and Query2 in POSTGRESQL but I don't know how to
implement Query3.



Are you a student of MSU-IIT? Log on http://my.msuiit.edu.ph 
and sign up for your My.MSUIIT E-mail Plus account now!
Are you an MSU-IIT alumnus? Log on http://www.alumni.msuiit.edu.ph


---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


[SQL]

2003-11-08 Thread ronald


Hello everyone, Good day! Could anyone help me translate this query in Microsoft
Access to Postgresql. I'm having a difficulty. Pls...

Query1:
SELECT items.description, Sum(supplieditems.qty) AS SumOfqty
FROM items INNER JOIN supplieditems ON items.itemno = supplieditems.itemno
GROUP BY items.description;

Query2:
SELECT [items].[description], Sum([customer].[qty]) AS SumOfqty
FROM (items INNER JOIN OtherItem ON [items].[itemno]=[OtherItem].[Itemno]) INNER
JOIN customer ON [OtherItem].[Itemno]=[customer].[itemcode]
GROUP BY [items].[description];

Query3:
SELECT [Query1].[SumOfqty], [Query2].[SumOfqty],
[Query1]![SumOfqty]-[Query2]![SumOfqty] AS remain
FROM Query1, Query2;

I have translated Query1 and Query2 in POSTGRESQL but I don't know how to
implement Query3.


Are you a student of MSU-IIT? Log on http://my.msuiit.edu.ph 
and sign up for your My.MSUIIT E-mail Plus account now!
Are you an MSU-IIT alumnus? Log on http://www.alumni.msuiit.edu.ph


---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


[SQL] alter table table add column

2007-07-30 Thread Ronald Rojas
Hi,

Anybody knows how to add column with reference to BEFORE or AFTER any
given column? Let say here's my table structure:

  Column  |   Type| Modifiers 
--+---+---
 surname  | character varying | 
 lastname | character varying | 
 address   | character varying |

And, I want to add the field name age with type integer after lastname
OR before the address field. How to I do that?

I would really appreciate your response.

Thanks in advance.


==
Ronald Rojas
Systems Administrator
Linux Registered  User #427229
==

Arnold's Laws of Documentation:
(1) If it should exist, it doesn't.
(2) If it does exist, it's out of date.
(3) Only documentation for useless programs transcends the
first two laws.




[SQL] Crosstab limitation...

2007-11-30 Thread ronald tabada
Good day... I'm new in postgresql and I used PostgreSQL 8.2. I tried
generating a query that can convert rows into columns. I was
happy when I discovered the crosstab function. But when I tried
producing reports with more than 17 columns it displayed the following
error message:

ERROR: invalid return type
SQL state: 42601
Detail: Query-specified return tuple has 39 columns but crosstab returns 17.

Can anyone help me? How can I use crosstab w/ more than 17 columns?