﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 7,2000 / SQL Server Newbies  / Group by select problem / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Wed, 19 Jun 2013 00:45:11 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Group by select problem</title><link>http://www.sqlservercentral.com/Forums/Topic410817-169-1.aspx</link><description>thanks  a lot its work</description><pubDate>Tue, 16 Oct 2007 00:06:26 GMT</pubDate><dc:creator>bsasiju</dc:creator></item><item><title>RE: Group by select problem</title><link>http://www.sqlservercentral.com/Forums/Topic410817-169-1.aspx</link><description>Sounds like you might be looking for a "pivot query" solution.  Something like:Select M.BookId, M.booktitle,        sum(case when d.status=1 then 1 else 0 end) as TotalIn,        sum(case when d.status=2 then 1 else 0 end) as TotalOut,        sum(case when d.status=3 then 1 else 0 end) as TotalLost,        sum(case when d.status=4 then 1 else 0 end) as TotalDamaged,        sum(case when d.status=5 then 1 else 0 end) as TotalRemoved      from [master Book table] Minner join [details Book table] Don M.bookID = D.BookIdGroup by M.BookId, M.booktitle</description><pubDate>Mon, 15 Oct 2007 09:03:56 GMT</pubDate><dc:creator>Matt Miller (#4)</dc:creator></item><item><title>RE: Group by select problem</title><link>http://www.sqlservercentral.com/Forums/Topic410817-169-1.aspx</link><description>thank for you answer but  I hope you did not get me well  I want to get sum of status Book i.e In book,out Book Lost book,Damage and Removed as table fields  for each title bookthanks  in advance</description><pubDate>Mon, 15 Oct 2007 08:07:44 GMT</pubDate><dc:creator>bsasiju</dc:creator></item><item><title>RE: Group by select problem</title><link>http://www.sqlservercentral.com/Forums/Topic410817-169-1.aspx</link><description>Maybe this gets you started...[i]Select M.BookId, D.[status], count(*) as NumberOfOccurrencesfrom [master Book table] Minner join [details Book table] Don M.bookID = D.BookIdGroup by M.BookId, D.Status[/i]</description><pubDate>Mon, 15 Oct 2007 07:49:02 GMT</pubDate><dc:creator>ALZDBA</dc:creator></item><item><title>Group by select problem</title><link>http://www.sqlservercentral.com/Forums/Topic410817-169-1.aspx</link><description>Hi all have developed my library project counter problem when I  want to get  sum   book status (in , out ,lost,damage and removed) of the  same title  from master Book table vs details Book table in one row.Master book table link with detail table field bookID  and  their status  field  on the book details have 1=in,2=out,3=lost,4=damage,5=removed .I tried to use group by method  but got  sum their status of same title different rowsPlease need you helpthank in advanced</description><pubDate>Mon, 15 Oct 2007 07:39:28 GMT</pubDate><dc:creator>bsasiju</dc:creator></item></channel></rss>