Re: [SQL] crosstab help

2013-06-04 Thread Jayadevan
Hello all , I have a similar situation - an EAV table. entity_attr_id integer entity_id bigint ent_attr_value character varying I am trying select * from crosstab('select entity_id::text as row_name, entity_attr_id::bigint as entity_attr_id , ent_attr_value::text as

Re: [SQL] SQL syntax rowcount value as an extra column in the result set

2010-03-25 Thread Jayadevan M
such a query (cartesian join) Regards, Jayadevan From: "Snyder, James" To: Date: 26/03/2010 03:21 Subject:[SQL] SQL syntax rowcount value as an extra column in the result set Sent by:pgsql-sql-ow...@postgresql.org Hello I’m using PostgreSQL (8.4.701) and

Re: [SQL] SQL syntax rowcount value as an extra column in the result set

2010-03-25 Thread Jayadevan M
6 John 6 John 6 Jacob 6 rows selected. PostgreSQL postgres=# select count(*) over () as ROWCOUNT , first_name from people; ERROR: syntax error at or near "over" LINE 1: select count(*) over () as ROWCOUNT , first_name from people... ^

Re: [SQL] SQL syntax rowcount value as an extra column in the result set

2010-03-25 Thread Jayadevan M
guess - over () will be better. My query does sequential scans/nested loop...(if there are no indexes) Regards, Regards, Jayadevan DISCLAIMER: "The information in this e-mail and any attachment is intended only for the person to whom it is addressed and may contain confidential and/or pr

Re: [SQL] LEFT OUTER JOIN issue

2010-04-21 Thread Jayadevan M
| 2008-03-15 | 00:00:00| 8.3 2008-03-15 | 03:00:00 | 2008-03-15 | 03:00:00| 12.0 2008-03-15 | 06:00:00 | 2008-03-15 | 06:00:00| 15.0 2008-03-15 | 09:00:00 | 2008-03-15 | 09:00:00| 18.0 2008-03-15 | 12:00:00 || | 2008-03-15 | 15:00:00 |

Re: [SQL] [GENERAL] How to Get Column Names from the Table

2010-07-07 Thread Jayadevan M
.mt2" Column | Type | Modifiers +-+--- id | integer | Table "public.mt3" Column | Type | Modifiers +-+--- id | integer | Regards, Jayadevan DISCLAIMER: "The information in this e-mail and any attachment is

Re: [SQL] SUM the result of a subquery.

2010-09-02 Thread Jayadevan M
i.price, SUM (o.quantity), ROUND (SUM (o.quantity) * i.price, 2) AS cost FROM orders o JOIN items i ON i.id_item = o.id_item WHERE o.date_order BETWEEN '2010-01-01' AND '2010-01-31' GROUP BY i.id_item, i.price) ) as x Regards, Jayadevan DISCLAIMER: "The inform

Re: [SQL] find and replace the string within a column

2010-09-24 Thread Jayadevan M
and after the pattern and concatenating them . Please see documentation for proper use of substr,strpos,cahr_length etc. Regards, Jayadevan DISCLAIMER: "The information in this e-mail and any attachment is intended only for the person to whom it is addressed and may contain confi

Re: [SQL] Calculate next event date based on instance of the day of week

2010-12-02 Thread Jayadevan M
dnesday | 5 2010-12-30 | Thursday | 5 2010-12-31 | Friday| 5 Regards, Jayadevan DISCLAIMER: "The information in this e-mail and any attachment is intended only for the person to whom it is addressed and may contain confidential and/or privileged material. If you have recei

Re: [SQL] Get the max viewd product_id for user_id

2010-12-03 Thread Jayadevan M
as y on x.user_id=y.user_id and x.count=y.count1 Regards, Jayadevan DISCLAIMER: "The information in this e-mail and any attachment is intended only for the person to whom it is addressed and may contain confidential and/or privileged material. If you have received this e-mail in error, ki

Re: [SQL] Get the max viewd product_id for user_id

2010-12-05 Thread Jayadevan M
> And then, to jump again into my own mouth - your approach, Jayadevan, > correctly gives me both product_id's if they're viewed the same number > of times. > Good. It should, since we are joining on count and user_id. I was surprised to see your mail which said it wouldn&#

Re: [SQL] Postgresql function which compares values from both tables

2012-03-19 Thread Jayadevan M
ant to compare and ensure that the values are same for all columns, please have a look at INTERSECT http://www.postgresql.org/docs/9.1/static/sql-select.html Regards, Jayadevan DISCLAIMER: "The information in this e-mail and any attachment is intended only for the person to whom

Re: [SQL] How to limit access only to certain records?

2012-06-22 Thread Jayadevan M
uses some other client like psql. Using a VIEW? Regards, Jayadevan DISCLAIMER: "The information in this e-mail and any attachment is intended only for the person to whom it is addressed and may contain confidential and/or privileged material. If you have received this e-mail in error

Re: [SQL] DB link from postgres to Oracle; how to query Dbname.tablename?

2013-10-02 Thread Jayadevan M
In PostgreSQL, you always connect to a 'database', then query tables. So if you are connecting to the 'wrong' database, you will get the error you mentioned. You can troubleshoot this in many ways - one way would be to enable logging on PostgreSQL side and check the log and see which database you a