hi,
am using query as - Select machine_id as MachineID,item_name as Name,SUM(item_quantity) as Quantity,SUM(billed_amount) as BilledAmount,SUM(received_amount) as ReceivedAmount from transaction where DATE(paid_date)='" + rdate + "'Group by machine_id,item_name
here rdate , am collecting from UI, - string rdate = dateTimePicker1.Value.ToString("yyyy-MM-dd");
- MachineID Name Quantity BilledAmount ReceivedAmount
-
V0001 petrol 61 244 244
-
V0002 Diesel 186 726 726
-
V0002 petrol 155 605 605
-
Total 402 1575 1575
But i want for every machine id ,total row - V0001 - - - -
-
total - - -
-
V0001 - - - -
-
total - - -
4 1053 Luuk 1,047
Expert 1GB
"But i want for every machine id ,total row"
than you should GROUP, and SUM() things in your query, not on 'machine_id' and 'item_name' but only on 'machine_id'
Based on item_name also actually
i am having records with name"petrol" more than 1 per day , so i need to sum() based on item_name,machine_id
above out put is after the querying database.
i want output as
V0001 Petrol - - -
Diesel - - -
Total - - -
V0002 Petrol - - -
Diesel - - -
total - - -
Luuk 1,047
Expert 1GB -
select
-
MachineID,
-
Name,
-
Quantity,
-
BilledAmount,
-
ReceivedAmount
-
from (
-
Select 1,
-
machine_id as MachineID,
-
item_name as Name,
-
SUM(item_quantity) as Quantity,
-
SUM(billed_amount) as BilledAmount,
-
SUM(received_amount) as ReceivedAmount
-
from transaction
-
where DATE(paid_date)='" + rdate + "'
-
Group by machine_id,item_name
-
union
-
Select 2,
-
machine_id as MachineID,
-
'' as Name,SUM(item_quantity) as Quantity,
-
SUM(billed_amount) as BilledAmount,
-
SUM(received_amount) as ReceivedAmount
-
from transaction
-
where DATE(paid_date)='" + rdate + "'
-
Group by machine_id
-
order by MachineID, 1)
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: SomeDude |
last post by:
Lo group,
I would like to know if it is possible to a (string) replace on
existing records based on a given pattern.
Let's say I have a table containing the following records (strings):...
|
by: Matt |
last post by:
Hi everyone, still pretty new to MySQL. I was
wondering if there is a way to automatically filter
records based on a mysql userlogin name??
I have serveral databases that I want to combine
in...
|
by: arthur-e |
last post by:
How can you select records based on more than one combo box -
I have a combobox that selects records based on name
(I'm sure this has been asked a thousand times - web site answer/link
could be...
|
by: lj |
last post by:
How do I get an asp.net datagrid to set certain records as
tedittemplate based on a certain condition.
It is for a simple workflow. The user will have permission to see a
list of records. He...
|
by: AA Arens |
last post by:
I have a form with navigation button and they brows through the
records. How to change the order or the way these records are
navigated?
Like before based on ID, now I want based on another field,...
|
by: Eugene Anthony |
last post by:
I have a table that has a DateTime column which uses a DataTime
datatype. How do I retrieve a range of records based on the month and
year using ms sql?
Eugene Anthony
*** Sent via...
|
by: BEETHOVEN |
last post by:
I have an option group called Issue_Type on my main form
F1_Member_Demographics_Main. When I select one of the 3 options on the
main form from the option group Issue_Type I want to limit the sub...
|
by: cehlinger |
last post by:
I am trying to add multiple records based on a date range. I found some examples and have tried them but am getting errors and I can't seem to figure out what the problem is. I am not a VBA...
|
by: lev9shun |
last post by:
Hi all,
I have a reporting table that I use for my reports but would like to filter(flag) records based certain Medical conditions.
Example of reporting table:
ID Name MedCond Reported...
|
by: Yoni Hasid |
last post by:
Hello,
I am struggling with finding a solution on how to assign numerical values to text records based on various criteria. I have a table with survey responses where each column has text records...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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: 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...
| |