freelanceprogrammers.org Forum Index » PHP
Problem with SQL Statement
Joined: 14 Jan 2006
Posts: 1
Problem with SQL Statement
How to execute a sql query which sums up a field on a criteria and then doubles
the value.
i.e.
Field code = materialMaster
Values = 1, 2, 3, 4...and so on
SELECT materialMaster.Rate, sum(materialMaster.`QTY`) as TOT FROM
materialMaster WHERE QTY>=10
the above sql statement is working fine but i m not getting the solution to
double the value i mean i need twice of TOT. I cannot store tot and then double
the value i need it within the sql statement as a field code.
Zaid
---------------------------------
Yahoo! Photos – Showcase holiday pictures in hardcover
Photo Books. You design it and we’ll bind it!
[Non-text portions of this message have been removed]
Joined: 12 Feb 2005
Posts: 10
Problem with SQL Statement
Shaikh,
Try:
SELECT materialMaster.Rate, 2 * sum(materialMaster.`QTY`) as TOT FROM
materialMaster WHERE QTY>=10
Bob
-----Original Message-----
From: php-objects@yahoogroups.com [mailto:php-objects@yahoogroups.com]On
Behalf Of Zaid, Shaikh
Sent: Friday, January 13, 2006 11:56 PM
To: php-objects@yahoogroups.com
Subject: [php-objects] Problem with SQL Statement
How to execute a sql query which sums up a field on a criteria and then
doubles the value.
i.e.
Field code = materialMaster
Values = 1, 2, 3, 4...and so on
SELECT materialMaster.Rate, sum(materialMaster.`QTY`) as TOT FROM
materialMaster WHERE QTY>=10
the above sql statement is working fine but i m not getting the solution
to double the value i mean i need twice of TOT. I cannot store tot and then
double the value i need it within the sql statement as a field code.
Zaid
---------------------------------
Yahoo! Photos – Showcase holiday pictures in hardcover
Photo Books. You design it and we’ll bind it!
[Non-text portions of this message have been removed]
PHP Data object relational mapping generator
http://www.metastorage.net/
----------------------------------------------------------------------------
----
YAHOO! GROUPS LINKS
a.. Visit your group "php-objects" on the web.
b.. To unsubscribe from this group, send an email to:
php-objects-unsubscribe@yahoogroups.com
c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
----------------------------------------------------------------------------
----
[Non-text portions of this message have been removed]
Joined: 16 Jan 2006
Posts: 3
Problem with SQL Statement
why not try..
SELECT materialMaster.Rate, sum(materialMaster.`QTY`) * 2 as TOT FROM
materialMaster WHERE QTY>=10
"Zaid, Shaikh" <shaikh_zaid@...> wrote: How to execute a sql query
which sums up a field on a criteria and then doubles the value.
i.e.
Field code = materialMaster
Values = 1, 2, 3, 4...and so on
SELECT materialMaster.Rate, sum(materialMaster.`QTY`) as TOT FROM
materialMaster WHERE QTY>=10
the above sql statement is working fine but i m not getting the solution to
double the value i mean i need twice of TOT. I cannot store tot and then double
the value i need it within the sql statement as a field code.
Zaid
---------------------------------
Yahoo! Photos � Showcase holiday pictures in hardcover
Photo Books. You design it and we�ll bind it!
[Non-text portions of this message have been removed]
PHP Data object relational mapping generator
http://www.metastorage.net/
---------------------------------
YAHOO! GROUPS LINKS
Visit your group "php-objects" on the web.
To unsubscribe from this group, send an email to:
php-objects-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---------------------------------
---------------------------------
Yahoo! Photos
Got holiday prints? See all the ways to get quality prints in your hands ASAP.
[Non-text portions of this message have been removed]
Joined: 06 Sep 2005
Posts: 16
Problem with SQL Statement
Looks from here like you missed the "times two" part of the SQL string.
-m
On Jan 15, 2006, at 7:45 PM, Jary Nubla wrote:
>> why not try..
>>
>> SELECT materialMaster.Rate, sum(materialMaster.`QTY`) * 2 as TOT
>> FROM materialMaster WHERE QTY>=10
>
> "Zaid, Shaikh" <shaikh_zaid@...> wrote: How to execute a
> sql query which sums up a field on a criteria and then doubles the
> value.
>
> SELECT materialMaster.Rate, sum(materialMaster.`QTY`) as TOT
> FROM materialMaster WHERE QTY>=10
>
> the above sql statement is working fine but i m not getting the
> solution to double the value i mean i need twice of TOT. I cannot
> store tot and then double the value i need it within the sql
> statement as a field code.
>
>
> Zaid
>
Joined: 16 Jan 2006
Posts: 3
Problem with SQL Statement
Michael Slavin <mini@...> wrote: Looks from here like you missed the
"times two" part of the SQL string.
-m
On Jan 15, 2006, at 7:45 PM, Jary Nubla wrote:
>> why not try..
>>
>> SELECT materialMaster.Rate, sum(materialMaster.`QTY`) * 2 as TOT
>> FROM materialMaster WHERE QTY>=10
>
> "Zaid, Shaikh" <shaikh_zaid@...> wrote: How to execute a
> sql query which sums up a field on a criteria and then doubles the
> value.
>
> SELECT materialMaster.Rate, sum(materialMaster.`QTY`) as TOT
> FROM materialMaster WHERE QTY>=10
>
> the above sql statement is working fine but i m not getting the
> solution to double the value i mean i need twice of TOT. I cannot
> store tot and then double the value i need it within the sql
> statement as a field code.
>
>
> Zaid
>
PHP Data object relational mapping generator
http://www.metastorage.net/
SPONSORED LINKS
Programming languages Object oriented programming Php developer
Computer security C programming language Computer programming languages
---------------------------------
YAHOO! GROUPS LINKS
Visit your group "php-objects" on the web.
To unsubscribe from this group, send an email to:
php-objects-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---------------------------------
---------------------------------
Yahoo! Photos – Showcase holiday pictures in hardcover
Photo Books. You design it and we’ll bind it!
[Non-text portions of this message have been removed]
Joined: 27 Apr 2005
Posts: 7
Problem with SQL Statement
Have you tried using a variable?
http://dev.mysql.com/doc/refman/5.0/en/variables.html
-----Original Message-----
From: php-objects@yahoogroups.com [mailto:php-objects@yahoogroups.com] On
Behalf Of Zaid, Shaikh
Sent: Saturday, January 14, 2006 12:56 AM
To: php-objects@yahoogroups.com
Subject: [php-objects] Problem with SQL Statement
How to execute a sql query which sums up a field on a criteria and then
doubles the value.
i.e.
Field code = materialMaster
Values = 1, 2, 3, 4...and so on
SELECT materialMaster.Rate, sum(materialMaster.`QTY`) as TOT FROM
materialMaster WHERE QTY>=10
the above sql statement is working fine but i m not getting the solution
to double the value i mean i need twice of TOT. I cannot store tot and then
double the value i need it within the sql statement as a field code.
Zaid
---------------------------------
Yahoo! Photos - Showcase holiday pictures in hardcover Photo Books. You
design it and we`ll bind it!
[Non-text portions of this message have been removed]
PHP Data object relational mapping generator http://www.metastorage.net/
Yahoo! Groups Links
Joined: 18 Nov 2005
Posts: 4
Problem with SQL Statement
You can also write it this way.
SELECT materialMaster.Rate,
sum(materialMaster.`QTY`) as TOT,
(sum(materialMaster.`QTY`)*2) as TOT2 FROM
materialMaster WHERE QTY>=10
Hope that helps.
Jon
--- TechLDS <tech@...> wrote:
> Have you tried using a variable?
>
http://dev.mysql.com/doc/refman/5.0/en/variables.html
>
>
> -----Original Message-----
> From: php-objects@yahoogroups.com
> [mailto:php-objects@yahoogroups.com] On
> Behalf Of Zaid, Shaikh
> Sent: Saturday, January 14, 2006 12:56 AM
> To: php-objects@yahoogroups.com
> Subject: [php-objects] Problem with SQL Statement
>
> How to execute a sql query which sums up a field on
> a criteria and then
> doubles the value.
>
> i.e.
>
> Field code = materialMaster
> Values = 1, 2, 3, 4...and so on
>
>
> SELECT materialMaster.Rate,
> sum(materialMaster.`QTY`) as TOT FROM
> materialMaster WHERE QTY>=10
>
> the above sql statement is working fine but i m
> not getting the solution
> to double the value i mean i need twice of TOT. I
> cannot store tot and then
> double the value i need it within the sql statement
> as a field code.
>
>
> Zaid
>
>
>
> ---------------------------------
> Yahoo! Photos - Showcase holiday pictures in
> hardcover Photo Books. You
> design it and we`ll bind it!
>
> [Non-text portions of this message have been
> removed]
>
>
>
> PHP Data object relational mapping generator
> http://www.metastorage.net/
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
>
>
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Joined: 19 Jan 2006
Posts: 1
Problem with SQL Statement
i try in MS access
select col1 from table1 where colk1 >=
( select max(col1) from table1 where col1 not in
(select max(col1) from table1)
)
--- TechLDS <tech@...> wrote:
> Have you tried using a variable?
>
http://dev.mysql.com/doc/refman/5.0/en/variables.html
>
>
> -----Original Message-----
> From: php-objects@yahoogroups.com
> [mailto:php-objects@yahoogroups.com] On
> Behalf Of Zaid, Shaikh
> Sent: Saturday, January 14, 2006 12:56 AM
> To: php-objects@yahoogroups.com
> Subject: [php-objects] Problem with SQL Statement
>
> How to execute a sql query which sums up a field on
> a criteria and then
> doubles the value.
>
> i.e.
>
> Field code = materialMaster
> Values = 1, 2, 3, 4...and so on
>
>
> SELECT materialMaster.Rate,
> sum(materialMaster.`QTY`) as TOT FROM
> materialMaster WHERE QTY>=10
>
> the above sql statement is working fine but i m
> not getting the solution
> to double the value i mean i need twice of TOT. I
> cannot store tot and then
> double the value i need it within the sql statement
> as a field code.
>
>
> Zaid
>
>
>
> ---------------------------------
> Yahoo! Photos - Showcase holiday pictures in
> hardcover Photo Books. You
> design it and we`ll bind it!
>
> [Non-text portions of this message have been
> removed]
>
>
>
> PHP Data object relational mapping generator
> http://www.metastorage.net/
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
>
>
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
Booking Calendar - reservation calendar script
Land Surveying - total station instruments and equipments
China Wholesale - Electronics Products
Character Studio - Tutorials and Help
Booking Calendar - reservation calendar script
Land Surveying - total station instruments and equipments
China Wholesale - Electronics Products
Character Studio - Tutorials and Help







