Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Max over partition by excluding certain values

$
0
0

I have two tables

table1:Messagethread,opendate,closedate,threadsection

table2:Messageid,Messagethread, messagetitle,messagedate,messageparent.

I would like to dispaly the following columns

threadid, threadsection,messagetitle (for all), max message date but (only thoses with messageparent=0), count (messageid but only thoses with messageparent=0), open and close date

 how to select only those records with messageparent=0 for the max and count functions but display the other columns for all records


sz


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>