3 Replies - 662 Views - Last Post: 06 April 2009 - 01:12 PM Rate Topic: -----

#1 shahzi400  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 30-March 09

how to get data with sum

Post icon  Posted 03 April 2009 - 11:04 PM

hi
i have table name trick and data base name newbase
and columns names are
1. ITID 2. ITName 3. ITPrice 4. IT Quantity 5. ITStock
and i have data in it

i write a query to get the sum of price column
query is : select SUM(itprice)as total from trick where itname='a'
this query give the result i am developing a vb.net 2005 application
problem part
i want to get the remining data while using this query
means the specific row on whic i get total of that column
can anone help me
thanks

Is This A Good Question/Topic? 0
  • +

Replies To: how to get data with sum

#2 egof  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 20
  • View blog
  • Posts: 132
  • Joined: 27-March 09

Re: how to get data with sum

Posted 04 April 2009 - 11:07 AM

You want the original rows and the sum right? You can either return the rows then do the sum in the application or return 2 select statements. Doing the sum in the application usually is easy. Are you calling a stored proc with this select statement?
Was This Post Helpful? 0
  • +
  • -

#3 shahzi400  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 30-March 09

Re: how to get data with sum

Posted 05 April 2009 - 03:26 AM

View Postegof, on 4 Apr, 2009 - 10:07 AM, said:

You want the original rows and the sum right? You can either return the rows then do the sum in the application or return 2 select statements. Doing the sum in the application usually is easy. Are you calling a stored proc with this select statement?



hi
I want the original rows and the sum right and i am not calling any stored proc

More elaboration what I want
Trick (Table name)
Itid itname itprice itquantity
1 a 5 6
2 a 4 3
4 p 8 3
Query
select SUM(itprice)as total from trick where itname='a'
result
10
I want to display the rows in data grid and for that I need query ok
Like
Itid itname itprice itquantity total
1 a 5 6 10
2 a 4 3

This post has been edited by shahzi400: 05 April 2009 - 11:31 AM

Was This Post Helpful? 0
  • +
  • -

#4 egof  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 20
  • View blog
  • Posts: 132
  • Joined: 27-March 09

Re: how to get data with sum

Posted 06 April 2009 - 01:12 PM

What about this?

select Itid, itname, itprice, itquantity, (itprice* itquantity) as total 
from Trick
where ?=?

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1