My SQL query is -->
SELECT sum(bookings),sum(invoices) FROM alaqary WHERE alasas="WQ"
I am finding the sum of two fields .
Is there any better way ?
12 10246
My SQL query is -->
SELECT sum(bookings),sum(invoices) FROM alaqary WHERE alasas="WQ"
I am finding the sum of two fields .
Is there any better way ?
try this
SELECT s1.Sum, s2.Sum
FROM (SELECT sum(bookings) Sum , alasas
FROM alagary) s1,
(SELECT sum(invoices) Sum , alasas
FROM alagary) s2,
WHERE s1.alasas='WQ'
AND s2.alasas='WQ'
try this
SELECT s1.Sum, s2.Sum
FROM (SELECT sum(bookings) Sum , alasas
FROM alagary) s1,
(SELECT sum(invoices) Sum , alasas
FROM alagary) s2,
WHERE s1.alasas='WQ'
AND s2.alasas='WQ'
but i guess ur code will also work
wats exactly u r lookin for
try this
SELECT s1.Sum, s2.Sum
FROM (SELECT sum(bookings) Sum , alasas
FROM alagary) s1,
(SELECT sum(invoices) Sum , alasas
FROM alagary) s2,
WHERE s1.alasas='WQ'
AND s2.alasas='WQ'
Why to make it so complex ?
BUT I GUESS UR CODE WILL ALSO WORK
WATS EXACTLY U R LOOKIN FOR
I want to avoid using SUM in all the fields.
I want to avoid using SUM in all the fields.
u want to get the sum of all entries in ur table but u dun wanna use aggregate functions?????
is that what u want
U WANT TO GET THE SUM OF ALL ENTRIES IN UR TABLE BUT U DUN WANNA USE AGGREGATE FUNCTIONS?????
IS THAT WHAT U WANT
NO
I wanna use Aggregate functions with a different way if possible ?
NO
I wanna use Aggregate functions with a different way if possible ?
i know what u don't want but
i am not able to get what u want
plz explain briefly
well i explained a method above in my previous post
i know what u don't want but
i am not able to get what u want
plz explain briefly
well i explained a method above in my previous post
are u talking bout something related to complete table scan that u don't want
are u talking bout something related to complete table scan that u don't want
NO
I just don't want to use SUM with every field of the table.
Now you got ?
NO
I just don't want to use SUM with every field of the table.
Now you got ?
hi dear,
if you dont want realy user SUM() for your field to return back the some value,
i think you have to use PROCEDURE s or FUNCTION in your Database.
then just use CALL function to use the functions.
search and read more about user defiened functions and store procedure in your DBMS.
it will looks like this.
mysql> delimiter //
mysql> CREATE PROCEDURE mysum (IN field INT,OUT res INT)
-> BEGIN
-> SELECT SUM( field ) INTO res FROM t;
-> END;
-> //
Query OK, 0 rows affected (0.00 sec)
mysql> delimiter ;
NO
I just don't want to use SUM with every field of the table.
Now you got ?
U want to Do the SUM but Dont Wanna Use Sum()????
TEll me what u wanna Do , Not wat U dont wanna Do.
i understood wat u dont Wanna Do, But didnt Get Wat u wanna Do
U want to Do the SUM but Dont Wanna Use Sum()????
TEll me what u wanna Do , Not wat U dont wanna Do.
i understood wat u dont Wanna Do, But didnt Get Wat u wanna Do
YA the Guy Before Me is right
Try This Stored Procedures Sign in to post your reply or Sign up for a free account.
Similar topics
by: Westcoast Sheri |
last post by:
To keep track of how many fruits my visitors buy, I use a mySQL database
(2 columns: "fruit" and "quantity")....so can we make these following
mySQL queries work somehow?
(visitor buys 5...
|
by: Phil Powell |
last post by:
Relevancy scores are normally defined by a MySQL query on a table that
has a fulltext index. The rules for relevancy scoring will exclude
certain words due to their being too short (minimum...
|
by: Phil Powell |
last post by:
The table already has a fulltext index and from there I can use the
MySQL fulltext search query to get results as well as the relevancy
score.
The problem I have is that MySQL has a default...
|
by: fra |
last post by:
hi everybody,
i got a strange problem with a simple mysql query in php.
simply, it doesn't work on my page (while it does through phpmyadmin):
there's the query:
$sql="
SELECT operatore, azione,...
|
by: Auddog |
last post by:
I have the following query that works in mysql:
select id, order_no, price, count(item_no), sum(price) from production
WHERE item_no = '27714'
group by item_no;
When I setup my query in php,...
|
by: printline |
last post by:
Hello All
I need a little help with a phph script to display some specific data from a mysql table.
I have a mysql table with 4 columns and 10 rows. I want to display fx. data from row 4, 6, 8...
|
by: ScottCase |
last post by:
Hello,
I have this sql statement and it works fine with mysql v4
$query = "SELECT id, name, jv_signups, mem_signups, (
SELECT SUM( jv_signups )
) + (
SELECT SUM( mem_signups ) ) AS total...
|
by: inexion |
last post by:
Hello,
I'll try to explain what I'm trying to accomplish here, hopefully not
too bad a task. Basically I have an existing table with data that will
be operated on to form new records etc...
...
|
by: silversubey |
last post by:
I am trying to convert mssql triggers to mysql. I am very new to Mysql and would like some help with my code. My queries work but there has to be a more efficient way to write them. I would greatly...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |