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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Null row has to be returned when sort by group

Author  Topic 

satish15385
Starting Member

17 Posts

Posted - 2011-06-16 : 14:16:37
Hello,

i want to return a null row when passing the query after adding group By clause...

ex: when i pass select isnull(sum(fulls),0) Fulls,isnull(sum(halfs),0) Halfs
from ss a inner join xx b on a.sample=b.sample
where Id = '21' and PID ='3377' and b.TYPE='S' ; it will return a
0.0000 0.0000 row if it has no values to return ....

i want the same result to return after adding group by clause for the same query..is there anyway i can do that...... Thanks in Advance

satish15385
Starting Member

17 Posts

Posted - 2011-06-16 : 16:20:38
Can anyone atleast give me a clue on how i can do this???
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-06-16 : 16:42:15
Can you give us a better clue what your data looks like, and the type of results you want? Can you also put some blank lines between questions, query statements, and results? It's very hard to read and understand what you've posted.
Go to Top of Page

satish15385
Starting Member

17 Posts

Posted - 2011-06-16 : 16:49:59
Sure, when we pass a query like the below :

select isnull(sum(fulls),0) Fulls,isnull(sum(halfs),0) Halfs

from ss a inner join xx b on a.sample=b.sample

where Id = '21' and PID ='3377' and b.TYPE='S'

Result : 0.0 0.0 if there are no values for the where condition

what i want is that i need the same output after i apply group by clause for a column (by default it won't return any row)....is there a possibility???
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-06-16 : 17:10:40
What are you adding for a GROUP BY clause, and why? Please be specific, and post the full table structure (CREATE TABLE statement). Some actual sample data would help too.
Go to Top of Page

satish15385
Starting Member

17 Posts

Posted - 2011-06-17 : 16:29:06
let me make my question simple...is there a way i can return a null row with a "group by" command....
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-06-17 : 16:46:59
Making your question simple(r) does not help us answer it. How about answering my questions instead?
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2011-06-17 : 17:12:26
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page
   

- Advertisement -