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 |
|
wormz666
Posting Yak Master
110 Posts |
Posted - 2008-09-18 : 02:22:19
|
| i have a problem with the query i want to view how much i earned for each producttable1 prodid numeric desc varchar uprice int table2 tranid numeric prodid numeric qty intSelect table1.prodid,(sum(table2.qty) * uprice) from table1inner join table2 on table1.prodid=table2.prodidwhere table1.prodid=table2.prodid |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-09-18 : 02:25:42
|
you missed the GROUP BY prodid KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-18 : 02:27:28
|
quote: Originally posted by khtan you missed the GROUP BY prodid KH[spoiler]Time is always against us[/spoiler]
Also group by uprice |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-09-18 : 02:31:52
|
why group by uprice ?I guess the wrong placement of parenthesis confuses you KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-09-18 : 02:33:51
|
oh the parenthesis is wrong alsoSelect table1.prodid, sum(table2.qty * uprice) from table1 inner join table2 on table1.prodid = table2.prodidwhere table1.prodid=table2.prodid -- this is redundantgroup by table1.prodid KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
wormz666
Posting Yak Master
110 Posts |
Posted - 2008-09-18 : 02:44:10
|
| thank you very much i am new member of this forum... and i guess i will learned much more on this site.... |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-18 : 03:38:39
|
quote: Originally posted by khtan oh the parenthesis is wrong alsoSelect table1.prodid, sum(table2.qty * uprice) from table1 inner join table2 on table1.prodid = table2.prodidwhere table1.prodid=table2.prodid -- this is redundantgroup by table1.prodid yup got confused thanks for clarification KH[spoiler]Time is always against us[/spoiler]
|
 |
|
|
|
|
|