[SQL] Retrieve month from date in SQl query

2007-04-22 Thread RPK

I am using PGSQL 8.2.3 on Windows XP.

I have a table called "StudentFeesPayment" with columns "ReceiptNo" and
"ReceiptMonthYear".
The column, "ReceiptMonthYear" stores date in the format "-mm-dd". I
have to find the max(ReceiptNo) where Month of (ReceiptMonthYear)=4. Or
whatever month I give.

I tried:

Select max(ReceiptNo) from StudentFeesPayment where
Extract(Month('ReceiptMonthYear'))=4;

But it is not working. How to do it?
-- 
View this message in context: 
http://www.nabble.com/Retrieve-month-from-date-in-SQl-query-tf3602302.html#a10063035
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.


---(end of broadcast)---
TIP 6: explain analyze is your friend


Re: [SQL] Floating point type to store numbers

2007-04-22 Thread Lew

Andrew Sullivan wrote:

On Tue, Apr 17, 2007 at 04:33:33PM -0400, Radhika Sambamurti wrote:

Andrew,
This has been quite helpful. My main concern is CPU cost.  Thanks for the
input.


You're welcome.  Are you sure your main concern should be CPU cost?
It's true that numeric is more costly that float in a lot of cases,
but I know at least one auditor who will refuse to certify results
from programs that anywhere use floating-point storage or calculation
on accounting data.  The problem is really that you can get compound
errors -- very small rounding errors several times can turn out to be
a big problem.  (One quick primer that can help you understand this
is at .)


Would you rather have wrong answers really, really fast, or right answers fast 
enough?


--
Lew

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

  http://www.postgresql.org/docs/faq


[SQL] Windows postgres

2007-04-22 Thread Senthil
Respected sir/madam,

Please can you send me link of windows postgres sql download page.

thanks
senthil


---(end of broadcast)---
TIP 6: explain analyze is your friend


[SQL] i have prolem can you help me

2007-04-22 Thread saytinh

-- Table: ticket

-- DROP TABLE ticket;

CREATE TABLE ticket
(
  gid serial NOT NULL,
  id integer,
  name character varying,
  address character varying(254),
  province character varying(100),
  fax character varying(50),
  code integer,
  "type" integer,
  phone character varying(15),
  web character varying(40),
  levels integer,
  the_geom geometry,
  email character varying,
  CONSTRAINT ticket_pkey PRIMARY KEY (gid),
  CONSTRAINT enforce_dims_the_geom CHECK (ndims(the_geom) = 2),
  CONSTRAINT enforce_geotype_the_geom CHECK (geometrytype(the_geom) =
'POINT'::text OR the_geom IS NULL),
  CONSTRAINT enforce_srid_the_geom CHECK (srid(the_geom) = 42102)
) 
WITHOUT OIDS;
ALTER TABLE ticket OWNER TO postgres;


Why i run void -> Exception parameter


   public DataTable SearchTicket(string strProvin, string strDistric,
string strName, string strAddress, string strPhone, string strFax, string
strEmail, string strType)
{
try
{
String Query = "Select name,gid from ticket Where 1=1 ";
string str, str1;
string strCode = "-1";
if (strDistric != "" && strDistric != "0")
{
Query += " and code = :code";
strCode = strDistric;
}
else
{
if (int.Parse(strProvin) != 0)
{
Query += " and code like ':code%'";
strCode = strProvin;
}

}
if (int.Parse(strType) == 0)
{
str = " like '%";
str1 = "%'";
}
else
{
str = " = '";
str1 = "'";
}
if (strName != "")
Query += " and lower(name) " + str + ":name" + str1;
if (strAddress != "")
Query += " and lower(address) " + str + ":address" +
str1;
if (strPhone != "")
Query += " and lower(phone) " + str + ":phone" + str1;
if (strFax != "")
Query += " and lower(fax) " + str + ":fax" + str1;
if (strEmail != "")
Query += " and lower(email) " + str + ":email" + str1;
Query += ";";

NpgsqlParameter[] values = new NpgsqlParameter[6];
values[0] = new NpgsqlParameter(@":code",
Convert.ToInt32(strCode));
values[1] = new NpgsqlParameter(@":name",
strName.ToLower());
values[2] = new NpgsqlParameter(@":address",
strAddress.ToLower());
values[3] = new NpgsqlParameter(@":phone",
strPhone.ToLower());
values[4] = new NpgsqlParameter(@":fax", strFax.ToLower());
values[5] = new NpgsqlParameter(@":email",
strEmail.ToLower());

values[0].Direction = ParameterDirection.Input;
values[1].Direction = ParameterDirection.Input;
values[2].Direction = ParameterDirection.Input;
values[3].Direction = ParameterDirection.Input;
values[4].Direction = ParameterDirection.Input;
values[5].Direction = ParameterDirection.Input;

values[0].SourceColumn = "code";
values[1].SourceColumn = "name";

DataSet ds = PostGresServerDataAccess.getDataFromSQL(Query,
"ticket", values);
return ds.Tables["ticket"];
}
catch (Exception ex)
{
throw ex;
}
 }
-- 
View this message in context: 
http://www.nabble.com/i-have-prolem-can-you-help-me-tf3582184.html#a10009763
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.


---(end of broadcast)---
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate


[SQL] Regular Expression Data Type

2007-04-22 Thread Richard Doust

Hi.
I appreciate that I can query the database and find records that  
match a regular expression.
What I'd like to be able to do is to define a field in the database  
as a regular expression so that when I select, i.e.,


select price from shipping_prices where shipFromZip = '23773' and  
shipToZip ~ '87927'


because shipToZip is defined as a regular expression, I'd match a row  
where shipToZip held the value '879[0-9]{2,2}' or '87[0-9]*'.


Wouldn't that be cool? Does anyone know whether this is already  
possible?


Thanks.


---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


Re: [SQL] Windows postgres

2007-04-22 Thread Paul Lambert

Senthil wrote:

Respected sir/madam,

Please can you send me link of windows postgres sql download page.

thanks
senthil


---(end of broadcast)---
TIP 6: explain analyze is your friend




http://www.postgresql.org/ftp/binary/v8.2.4/win32/

--
Paul Lambert
Technical Support Team Leader and Database Administrator
AutoLedgers
Level 3, 823 Wellington Street, West Perth, W.A. 6005
Postal: P.O. Box 106, West Perth, W.A. 6872
Ph: 08 9217 5086 Fax: 08 9217 5055
AutoLedgers Technical Support Desk: 1800 649 987 (Free call) 08 9217 
5050 (Perth local and mobile)

Email: [EMAIL PROTECTED] 

For AutoLedgers technical support, please send an email to 
[EMAIL PROTECTED]



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


Re: [SQL] We all are looped on Internet: request +transport = invariant

2007-04-22 Thread Bart Degryse
A hierarchical is specialized in managing data which is hierarchically
structured, while a relational database is not.
Maybe this analogy is clearer: If you want to fly you could attach
wings to your sportscar, but it's more logical to use a plane.

>>> Dmitry Turin <[EMAIL PROTECTED]> 2007-04-20 16:21 >>>
>you could use a hierarchical database instead of a relational
database

why ?
why is impossible to make addition for relational database?