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 |
|
eurob
Posting Yak Master
100 Posts |
Posted - 2005-08-12 : 14:19:48
|
| How do I get a column name for the subquery result ?select distinct(myclient),(select sum(myvalue) from mytable m where cycleid = 31 and reportid = 1 and m.clientid = m1.clientid) <--- How do I name subquery ? from mysecondtable m1inner join reportnames n on n.reportid = m1.reportidwhere a=bgroup by clientidthanks,robertrobert |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-08-12 : 14:43:08
|
| Use AS after the end of the query.Tara |
 |
|
|
ajthepoolman
Constraint Violating Yak Guru
384 Posts |
Posted - 2005-08-12 : 14:44:55
|
| select distinct(myclient) AS [Client],(select sum(myvalue) from mytable m where cycleid = 31 and reportid = 1 and m.clientid = m1.clientid) AS [SUM] <--- How do I name subquery ? from mysecondtable m1inner join reportnames n on n.reportid = m1.reportidwhere a=bgroup by clientidIs that what you need, or is this more what you were thinking:select [Client] = distinct(myclient),[SumAmount] = (select sum(myvalue) from mytable m where cycleid = 31 and reportid = 1 and m.clientid = m1.clientid) <--- How do I name subquery ? from mysecondtable m1inner join reportnames n on n.reportid = m1.reportidwhere a=bgroup by clientidAjHey, it compiles. |
 |
|
|
eurob
Posting Yak Master
100 Posts |
Posted - 2005-08-12 : 14:53:11
|
| Thanks, it worked.robertrobert |
 |
|
|
|
|
|