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 2005 Forums
 Transact-SQL (2005)
 SQL 2005: How to count multi-columns in one row

Author  Topic 

jwx_uk
Starting Member

2 Posts

Posted - 2011-05-25 : 11:00:03
Dear All,

I have the following data pattern in my SQL 2005 table:

MPAN, Date, Reading1, Reading2,Reading3,......, Reading48
134, 21/05/11, , ,0.345 ,......, 0.789
134, 22/05/11, , , ,......, 0.467
456, 21/05/11, , , , , 1.234
456, 21/05/11, 0.009 , , 0.534 ,......,

What I am trying to do is to find out how many columns for each MPAN having blank readings on each specific day (group by MPAN, Date). Can I use "Select count(*) query" to return these records or do I need to use Stored Procedures? Any examples would be appreciated.

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-05-25 : 11:36:28
Can you change the design to normalise the structure?

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

jwx_uk
Starting Member

2 Posts

Posted - 2011-05-26 : 05:00:24
Thanks for your reply.

This is a database I took over from my previous colleague and it's being used by several other people.

Stored Procedures seems to be the way to do it according to my Google search, but unfortunately I am new to SP.


Please help!
Go to Top of Page
   

- Advertisement -