Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
soorajtnpki
Posting Yak Master
231 Posts |
Posted - 2008-04-26 : 02:32:54
|
| hi i have a table with below structureid no.of visit no of sales no of delivery. I want all records to be selected with the following data also average( no.of visit),average( no of sales ), average( no of delivery) in a single query ? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-04-26 : 02:34:28
|
| SELECT id,avg( [no.of visit]),avg( [no of sales] ), avg( [no of delivery])FROM YourTableGROUP BY id |
 |
|
|
soorajtnpki
Posting Yak Master
231 Posts |
Posted - 2008-04-26 : 02:39:24
|
| hi visakh, i want not only averages,but also all records also.just like below... select * from table with average of the three fields I mentioned above.All in a single query.ok thanks.. |
 |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2008-04-26 : 02:56:15
|
might be better to post sample data and expected results elsasoft.org |
 |
|
|
soorajtnpki
Posting Yak Master
231 Posts |
Posted - 2008-04-26 : 03:00:27
|
| hi sample data id novisit noenquiry nodelivery 1 20 30 10 2 40 40 10i want 1 20 30 102 40 40 10 30 35 10 okthanks |
 |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2008-04-26 : 03:06:47
|
select id, novisit, noenquiry, nodelivery from yourtableunion all select null, avg(novisit), avg(noenquiry), avg(nodelivery) from yourtable elsasoft.org |
 |
|
|
soorajtnpki
Posting Yak Master
231 Posts |
Posted - 2008-04-26 : 03:35:27
|
| hi all thanks for ur replies.. ok |
 |
|
|
|
|
|
|
|