Click here to Skip to main content
15,905,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
SELECT
   T1.id,T1.RANK,T1.fullname,T2._time,T2._date,T1.casing,T1.munit
FROM
   (SELECT DISTINCT id,rank,fullname,casing,munit,ending,frsrank FROM tblmain) T1
   FULL OUTER JOIN
   (SELECT DISTINCT num,_time,_date  FROM tbl_secure_mornning) T2
              ON T1.id = T2.num where T1.ending ='false' and T1.frsrank between 15 and 16;





how to group by this query with T1.munit ?
Posted
Comments
thanh_bkhn 2-Aug-13 21:14pm    
If you want to group by something, don't select others.
If you must use other field in functions, you can wrap entire your SQL in a new Select statement.
Kuthuparakkal 2-Aug-13 23:41pm    
unclear

Can't you just do it like this..

SQL
SELECT SELECT DISTINCT
	 T1.id
	,T1.RANK
	,T1.fullname
	,T2._time
	,T2._date
	,T1.casing
	,T1.munit
FROM tblmain T1
	LEFT OUTER JOIN tbl_secure_mornning T2 ON T1.id = T2.num 
WHERE T1.ending ='false' 
	and T1.frsrank between 15 and 16
GROUP BY T1.munit
 
Share this answer
 
Comments
Maciej Los 11-Dec-13 17:22pm    
Sounds reasonable ;)
+5!
You can use CTE(Common Table Expression) for that...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900