How to combine 2 sql queries to one query in SQL Server? -


i'm bit confused 2 sql queries in ms access have add in sql server.

i want write stored procedure, don't know how combine these 2 sql queries.

here's first maxmonthdate:

select max(day([datum])) daymax,         month([datum]) monthmax,         year([datum]) yearmax,         dateserial([yearmax],[monthmax],[daymax]) datummax ds (((ds.datum)>=[formulare]![hauptmenü]![startdatum] , (ds.datum)<=[formulare]![hauptmenü]![enddatum])) group month([datum]), year([datum]); 

the second query maxmonthval:

select ds.* maxmonthdate inner join ds on maxmonthdate.datummax = ds.datum order ds.datum; 

can tell me how combine these in 1 query?

you can use subquery combine queries. please refer below query same:

    select ds.*     ds ds.datum in     (select datummax      (select max(day([datum])) daymax,             month([datum]) monthmax,             year([datum]) yearmax,             dateserial([yearmax],[monthmax],[daymax]) datummax     ds     (((ds.datum)>=[formulare]![hauptmenü]![startdatum] , (ds.datum)<=[formulare]![hauptmenü]![enddatum]))     group month([datum]), year([datum]))a     )     order ds.datum; 

please mark answer if helps solve query.

thanks!!


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -