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.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 SQL add same table twice in select??

Author  Topic 

cava1010
Starting Member

1 Post

Posted - 2008-09-24 : 18:26:04
Im trying to have the same field from the same database twice inone call. because i have to select by one kriteria and use data from another kriteria.

The DB is not well structored and im not able to change it.

i have used the name SerieDATA.indhold and SerieDATA_1.indhold. They are suppose to be the same but i dosen't work that way. and i can't use this name to do it.

Is it possible to do this in one call?

SELECT SerieDATA.Indhold, Sum((CInt([SerieDATA_1].[indhold]))) AS DataSUMofKol6SortedByKol/

FROM SerieDATA INNER JOIN SerieDATA AS SerieDATA_1 ON (SerieDATA.SerieNR = SerieDATA_1.SerieNR) AND (SerieDATA.ProgramNR = SerieDATA_1.ProgramNR)

WHERE (((SerieDATA.Kolonne)=6) AND ((SerieDATA_1.Kolonne)=7))

GROUP BY SerieDATA.Indhold;

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-09-24 : 22:06:18
Yes you can do that. Just try to execute it.


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -