[SQL] Balance Calculation

2005-05-21 Thread Muhyiddin A.M Hayat
Dear All,I have problem to calculation balance from debet and credit.my transaction table:    id |    trx_timestamptz | account  | trx_type_id |   amount++--+-+-  3 | 2005-04-14 17:16:49+08 | 01.2010100.2

Re: [SQL] Debet-Credit-Balance Calculation

2005-04-20 Thread Muhyiddin A.M Hayat
There is an easy way to do this; write a plpgsql set returning function which adds the balance to the last column of the table. That query will always have a cost in both time and memory proportional to the size of the table, and the memory cost may bite you as table size grows... -- Can you give

Re: [SQL] Debet-Credit-Balance Calculation

2005-04-20 Thread Muhyiddin A.M Hayat
There is an easy way to do this; write a plpgsql set returning function which adds the balance to the last column of the table. That query will always have a cost in both time and memory proportional to the size of the table, and the memory cost may bite you as table size grows... -- Can you give

[SQL] Debet-Credit-Balance Calculation

2005-04-19 Thread Muhyiddin A.M Hayat
Dear All,I have problem to calculation balance from debet and credit.my transaction table:    id |    trx_timestamptz | account  | trx_type_id |   amount++--+-+-  3 | 2005-04-14 17:16:49+08 | 01.2010100.2 |

Re: [SQL] Calendar Function

2005-02-01 Thread Muhyiddin A.M Hayat
-02-12 2004-02-13 2004-02-14 2004-02-15 2004-02-16 2004-02-17 2004-02-18 2004-02-19 2004-02-20 2004-02-21 2004-02-22 2004-02-23 2004-02-24 2004-02-25 2004-02-26 2004-02-27 2004-02-28 2004-02-29   - Original Message - From: Franco Bruno Borghesi To: Muhyiddin A.M Hayat Cc

[SQL] Calendar Function

2005-01-28 Thread Muhyiddin A.M Hayat
Dear All,   How to create Calendar Function or Query. I would like to display date form -mm-dd to -mm-dd or display date in one Month   e.g:       date 2005-01-01 2005-01-02 2005-01-03 2005-01-04 2005-01-05 2005-01-06 2005-01-07 2005-01-08 2005-01-09 2005-01-10 2005-01-11 

[SQL] Create Calendar

2004-12-10 Thread Muhyiddin A.M Hayat
Dear All,   How to create Calendar using Function/View. For example i would like to display date 2004-12-01 to 2004-12-20.   date -- 2004-12-01 2004-12-02 2004-12-03 2004-12-04 2004-12-05 .. ..  2004-12-20

Re: [SQL] Cross tabulations

2004-10-25 Thread Muhyiddin A.M Hayat
(select check_time-check_time::date from test where employee_id = x.employee_id and check_time::date = date and state = 'Out') as out from (select distinct employee_id, check_time::date as date from test) as x; out - in = work_time - Original Message - From: "Greg

[SQL] Cross tabulations

2004-10-19 Thread Muhyiddin A.M Hayat
Dear all,I need to do something similar to a cross tabulation, but without anyaggregation.I have below table id | employee_id |   state   | check_time+-+---+ 21 |   1 | In    | 2004-10-12 21:37:13 22 |   1 | Break Out |

[SQL] Rank

2004-05-04 Thread Muhyiddin A.M Hayat
Dear All,   I Have below table    id | site_name | point+---+---  1 | Site A    |    40  2 | Site B    |    90  3 | Site D    |    22  4 | Site X    |    98    Would like to calc that Rank for each site, and look like        id | site_name | point | rank+---+---

[SQL] Rank

2004-05-04 Thread Muhyiddin A.M Hayat
  Dear All,   I Have below table    id | site_name | point+---+---  1 | Site A    |    40  2 | Site B    |    90  3 | Site D    |    22  4 | Site X    |    98    Would like to calc that Rank for each site, and look like        id | site_name | point | rank+---+-

Re: [SQL] Calc

2003-10-16 Thread Muhyiddin A.M Hayat
> > trx_date | trx_time | descriptions| > > payment_method | debet | credit | creator > > +--+--+ > >- ---+---+--+- > > 2003-10-09 | 21:55:02 | Resto Biling : 13,800, Paid : 10,00

Re: [SQL] Calc

2003-10-16 Thread Muhyiddin A.M Hayat
> Something like this: > > select id,db,cr,(select sum(cr-db) from calc sub where sub.id <= > calc.id) from calc; > > This of course assumes that ID indicates the correct order of the > entries and it will blow up if you allow nulls for cr or db (which > you shouldn't since that would literally be

[SQL] Calc

2003-10-15 Thread Muhyiddin A.M Hayat
Dear all,   I have below table   +-++-+  | id   |    db    |cr                          | +-++-+  |1 |        | 200  |  |2 | 100   

[SQL] Create View

2003-10-14 Thread Muhyiddin A.M Hayat
Dear all,   I Have This table     Table Billing:       id   trx_date   trx_time depart   payment_method    billing_amount    amount_paid balance   creator 1  10/09/2003  21:55:02   Resto    Visa   13.800,00   

[SQL] PL/PGSQL TUTORIAL

2003-10-11 Thread Muhyiddin A.M Hayat
Where can i find a complete full terminated database schema in SQL?I want to see a real complete database schema with views, triggers.. etc,...  

Re: [SQL] SUM() & GROUP BY

2003-09-28 Thread Muhyiddin A.M Hayat
52 | Resto  | Cash   |  10 |3600| 36000. | 32400 |    2.00 | middink  2 |    1 | 2003-09-29 | 07:50:17 | Resto  | Visa   |  10 |1200| 12000. | 10800 |    1.00 | middinkbut i have another problem : - how to simple below statment : (SUM(("public".it

Re: [SQL] SUM() & GROUP BY

2003-09-28 Thread Muhyiddin A.M Hayat
1 | 2003-09-28 | 16:08:52 | Resto | Cash | 10 |3600 | 36000. | 32400 |2.00 | middink 2 |1 | 2003-09-29 | 07:50:17 | Resto | Visa | 10 |1200 | 12000. | 10800 |1.00 | middink but i have another problem : - how to simple below statme

[SQL] SUM() & GROUP BY

2003-09-28 Thread Muhyiddin A.M Hayat
  hotel=# SELECThotel-#   "public".billing.id,hotel-#   "public".billing.guest_id,hotel-#   "public".billing.trx_date,hotel-#   "public".billing.trx_time,hotel-#   "public".billing.payment_method,hotel-#   "public".billing.tax,hotel-#   "public".billing.dep_id,hotel-#   "public".departme

Re: [SQL] auto_increment

2003-09-20 Thread Muhyiddin A.M Hayat
;public"."guest" FOR EACH ROW EXECUTE PROCEDURE "public"."generate_guest_id"(); but error - Original Message - From: "Richard Huxton" <[EMAIL PROTECTED]> To: "Muhyiddin A.M Hayat" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED

Re: [SQL] auto_increment

2003-09-20 Thread Muhyiddin A.M Hayat
Ok, but if i do rollback, the auto_increment don't roolback. How to use nextval(), currval() and setval() functions.   - Original Message - From: Cavit Keskin To: 'Muhyiddin A.M Hayat' Sent: Saturday, September 20, 2003 2:15 PM Subject: RE: [SQL]

[SQL] auto_increment

2003-09-19 Thread Muhyiddin A.M Hayat
How to Create auto_increment field in PostreSQL. Can I create them using Trigger.

[SQL]

2003-09-14 Thread Muhyiddin A.M Hayat
 

[SQL] Column Types

2003-09-14 Thread Muhyiddin A.M Hayat
If in MySQL i'm using type EMUN what type in Postgres?

[SQL] Column limits in table/ views

2003-06-07 Thread A.M.
I have 560 columns of NUMERIC(10,14). To not run up against max column restraints, I split the information into two tables. Does the column limit on tables imply the same limit for views or selects or could I potentially select a row across both tables and make a view that hides the split? -

[SQL] UNION and ORDER BY ... IS NULL ASC

2003-04-04 Thread A.M.
PostgreSQL 7.3.2 on i686-pc-linux-gnu, compiled by GCC 2.95.3 I have come across some unexpected behavior while dealing with a UNION and ORDER BY. I'd like some advice. Here's a scenario where I want to order by null values: CREATE TABLE test(a int); SELECT a FROM test UNION SELECT a FROM test

Re: [SQL] Getting the latest unique items

2002-12-11 Thread A.M.
AULT '.zip' ); On Wednesday, December 11, 2002, at 01:36 PM, Tomasz Myrta wrote: I'm not sure if I understood your problem, but did you try with "distinct on"? select distinct on (id) from ... order by submittime desc Regards, Tomasz Myrta A.M. wrote: > I have

[SQL] Getting the latest unique items

2002-12-11 Thread A.M.
I have a table as follows: CREATE TABLE student_gradedmaterial( id SERIAL, studentid INT8 REFERENCES student, gradedmaterialid INT8 REFERENCES gradedmaterial, caid INT8 REFERENCES ca, ... submittime TIMESTAMP, gradedtime TIMESTAMP, score INT4 ); Every time a student submits a homewo

Re: [SQL]

2002-11-29 Thread A.M.
Wow. That's a real head-slapper. Thanks for the quick answer! On Friday, November 29, 2002, at 11:28 PM, Tom Lane wrote: "A.M." <[EMAIL PROTECTED]> writes: In summary, what I want is field INT8 REFERENCES sometable NULL OK Er ... NULL *is* OK, unless you say

[SQL]

2002-11-29 Thread A.M.
I have a reference which is guaranteed not to have a valid reference (preferably NULL) until it is processed later. How can I defer a reference entry so that both NULL and an actual reference are valid in the reference field? The processing which I speak of takes place later and not in the same