473,589 Members | 2,493 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

get day records based on id

8 New Member
hi,

am using query as
Expand|Select|Wrap|Line Numbers
  1. 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,

Expand|Select|Wrap|Line Numbers
  1. string rdate = dateTimePicker1.Value.ToString("yyyy-MM-dd");
Expand|Select|Wrap|Line Numbers
  1. MachineID Name Quantity BilledAmount ReceivedAmount
  2. V0001 petrol 61 244 244
  3. V0002 Diesel 186 726 726
  4. V0002 petrol 155 605 605
  5. Total 402 1575 1575
But i want for every machine id ,total row

Expand|Select|Wrap|Line Numbers
  1. V0001 - - - -
  2. total - - -
  3. V0001 - - - -
  4. total - - -
Mar 14 '14 #1
4 1062
Luuk
1,047 Recognized Expert Top Contributor
"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'
Mar 14 '14 #2
rajeswari02
8 New Member
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,machi ne_id
Mar 14 '14 #3
rajeswari02
8 New Member
above out put is after the querying database.
i want output as

V0001 Petrol - - -
Diesel - - -
Total - - -
V0002 Petrol - - -
Diesel - - -
total - - -
Mar 14 '14 #4
Luuk
1,047 Recognized Expert Top Contributor
Expand|Select|Wrap|Line Numbers
  1. select 
  2.     MachineID, 
  3.     Name, 
  4.     Quantity, 
  5.     BilledAmount, 
  6.     ReceivedAmount 
  7. from (
  8.     Select 1, 
  9.         machine_id as MachineID,
  10.         item_name as Name,
  11.         SUM(item_quantity) as Quantity,
  12.         SUM(billed_amount) as BilledAmount,
  13.         SUM(received_amount) as ReceivedAmount 
  14.     from transaction 
  15.     where DATE(paid_date)='" + rdate + "' 
  16.     Group by machine_id,item_name
  17. union 
  18.     Select 2, 
  19.         machine_id as MachineID,
  20.         '' as Name,SUM(item_quantity) as Quantity,
  21.         SUM(billed_amount) as BilledAmount,
  22.         SUM(received_amount) as ReceivedAmount 
  23.     from transaction 
  24.     where DATE(paid_date)='" + rdate + "' 
  25.     Group by machine_id
  26. order by MachineID, 1)
  27.  
Mar 14 '14 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1740
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): Windows/98 Windows/98/Registry Windows/2000 Windows/2000/Registry
11
11979
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 order to manage the databases more efficiently. - I'm currently using MySQL 4.1.12 and I'm currently testing 5.0.14 - I have a databases for each user account. - Each database has the same schema and entity relation model.
1
2648
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 helpful too; but I'm so bad with syntax that specifics will be MOST helpful) SELECT DISTINCT ., . FROM Union Select "<ALL>" , NULL From ;
0
1301
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 will be able to select all records he has permission to approve and that have not already been approved and click on a button to approve them. These records I want to display in edittemplate mode with a checkbox. The others I just want to display...
1
1726
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, like Name field. Bart Acc 2003
4
3613
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 Developersdex http://www.developersdex.com ***
6
4770
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 form F2_Member_Issues records based on the combo box Issue_Code_T1. Option Group Issue_Type on main form: 1=Complaint 2=Grievance 3=Appeal
8
6055
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 programmer so am a little lost. Any help would be appreciated. As an example, the user would enter in the following: 4 522 6/5/2010 6/10/2010 Once the user selected OK it would enter 6 records into the schedule table as the following:
12
4614
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 1 Pat A 100 N 1 Pat A 101 Y 1 Pat A 102 N 2 Pat B 100 Y
3
3427
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 for responses with various criteria. Thus I want to create a query that will change or assign numerical values to this text records as follows: If response is "Agree", then it is 5 If response is "Somewhat Agree", then it is 3 If response is...
0
7862
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8228
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8357
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8223
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5729
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5398
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2372
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1459
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1196
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.