Hi sanmugam.
On Tue, Oct 26, 2010 at 9:00 PM, sanmugam k <[email protected]> wrote:
> Hi to Everyone.
>
> To select a last n no. of records from table in the database i used the
> following query in PostgreSQL
>
> select * from stocks offset(select count(*) -3 from stocks);
>
> output:
>
> no | stkdate | stktime | itemcode | itemname | quantity
> | rate | totamount
>
> -----+------------+----------+----------+-------------------------+----------+--------+------------------------------
> 3 | 2010-10-19 | 11:44:41 | 606 | lemon |
> 2 | 100.00 | 200.00
> 1 | 2010-10-19 | 11:49:04 | 903 | Karaboondhi |
> 8 | 100.00 | 800.00
> 3 | 2010-10-19 | 11:49:04 | 907 | Ola pakoda |
> 6 | 100.00 | 600.00
>
>
>
> While am doing the same process from python code it displays output as
> None.
>
>
> Note: Assume that value of self.cou is 3
>
> Bit of python code:
>
> print self.cou
> disp=cur.execute("""select * from sales offset(select count(*)%d
> from sales);""" %self.cou)
>
cur.execute("""select * from sales offset(select count(*)%d from sales);"""
%self.cou)
disp=cur.fetchall()
print disp
problem solved!!!
> print disp
> print type(disp)
>
>
> output:
>
> 3
> None
> <type 'NoneType'>
>
> Need help. for this problem
>
> If some other query is there for this kind of process?
> kindly mention the query.
>
> Thanks in advance.
>
>
>
> --
> நன்றி ....
>
> சண்முகசுந்தரம்.க
>
> Kanchi Linux User Group Rocks !
>
> http://kanchilug.wordpress.com
>
> My Experiments In Linux are here
>
> http://gowithfoss.wordpress.com/
> _______________________________________________
> ILUGC Mailing List:
> http://www.ae.iitm.ac.in/mailman/listinfo/ilugc
>
--
With Regards,
V. Balakrishnan.
Kanchi Linux User Group Rocks !!!
http://kanchilug.wordpress.com
You can see my activities at
http://gnubala.wordpress.com/
_______________________________________________
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc