sql - How do I "collapse" the following column data with TSQL in Access 2010? -


While conducting my research I have not found such a problem (in reference to Access 2010 and TSQL)

Challenge: Currently, my data looks like State # 1 below. There are duplicate rows in state # 1, only the difference is that they have different fields / column values ​​for three special areas (offermembership, hassetting, quittieria).

Wish: I would like to "collapse" the lines through "PlaceIDID" and "year", and for each line, one of the current number of Y within each field Will generate different numbers. I have prepared sample data to represent my desired result.

My data currently looks like the following:

  state # 1 line | Year | Place ID | Offer Ambership | Hassiatic | Quitaria 001 2011 Park Yi 002 2011 Park YNN 003 2011 Library YYY 004 2011 Library NYN 005 2011 Museum YN 006 2011 Museum YYY 006 2011 Movie Theater YN 007 2012 Park YYY 008 2012 Park N   

Do I want to see my data:

  state # 2 line | Year | Place ID | Ambership "Y" | Heating "Y" | Chuetaria "Y" 001 2011 Park 1 1 002 2011 Library 1 1 1 003 2011 Museum 1 1 1 004 2011 Mubiagator 1 004 2012 Park 1 1 1   

Note: < P> 1) I am using TSQL within Access 2010 because I am running pass-through queries that kills a SQL Server table.

2) Yes, the state # 1 has "empty" cells in the data

< P> You can use simple group to summarize the data. I excluded the row column because I think it was just a line number placeholder. Select
  [Place], PlaceID, COUNT (Case offers ambershibwe 'Y' then 1 ELSE 0 END) as Ambership, COUNT (case is setting when 'Y' then 1 ELSE 0 END) AS HasSeating, COUNT (Case Quetteria when 'Y' then 1 ELSE 0 ADD) by MyTable Tea Group from IS Quiet Area. [Year], PlaceID   

Note: The above sample query has not been executed.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -