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 |
|
ramu143
Yak Posting Veteran
64 Posts |
Posted - 2008-09-25 : 01:03:09
|
| drop table #mohanselect filedate, switchcode, legaport,sum(legatime)/60 as minutes,count(*) as noofcalls into #mohan from month09..xcda (nolock) where legaport like 'dac%' and filedate like '2008-09-04' group by filedate, switchcode,legaport order by filedate, switchcode,legaportALTER TABLE #MOHAN ADD ACD floatupdate #MOHAN set ACD= minutes/noofcallsselect * from #MOHAN where ACD<0.5 and noofcalls>1 order by ACD ,noofcallswith this select statements i need to write a view are procedure |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-25 : 01:12:31
|
| [code]CREATE VIEW YourViewASselect filedate, switchcode, legaport,minutes,noofcalls,minutes*1.0/noofcalls as ACDFROM(select filedate, switchcode, legaport,sum(legatime)*1.0/60 as minutes,count(*) as noofcalls into #mohan from month09..xcda (nolock) where legaport like 'dac%' and filedate like '2008-09-04' group by filedate, switchcode,legaport )torder by filedate, switchcode,legaport[/code]Also keep in mind that you wont have any use in keeping order by inside view. unless you order the records explicitly using order by while selecting from view, you cant guarantee your results to be ordered. |
 |
|
|
TBSPS
Starting Member
1 Post |
Posted - 2011-10-28 : 15:51:20
|
| In regards to creating a SQL view, the data I need is in interger fields and I need it to be varchar to be able to integrate with another database. How can convert interger to varchar in my sql view? |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-29 : 00:50:00
|
quote: Originally posted by TBSPS In regards to creating a SQL view, the data I need is in interger fields and I need it to be varchar to be able to integrate with another database. How can convert interger to varchar in my sql view?
integer is compatible with varchar so it will undergo implicit conversion if you're comparing it to varchar, but its always worth explicitly doing conversion.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|
|
|