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.
| Author |
Topic |
|
mavershang
Posting Yak Master
111 Posts |
Posted - 2009-08-25 : 16:14:29
|
| Hi there. I am a rookie to SQL and have a problem with the queryThe table is likeSystemName BP_Type IDAA\BB\CC KDKD 10000AA\BB\CC IEIE 201AA\BB\DD IAEJ 1020...Now I want to check under each SystemName, for each different BP_Types, how many entries are there.so the result will be likeSystemName BP_Type SumAA\BB\CC KDKD 2AA\BB\CC IEIE 1AA\BB\DD IAEJ 101Anyone could help. Thanks. |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-08-25 : 16:42:02
|
Does you sample data and expected output match??maybe u need this?select systemname,bp_type,count(*) from @t group by systemname,bp_type |
 |
|
|
mavershang
Posting Yak Master
111 Posts |
Posted - 2009-08-25 : 18:29:28
|
Thanks for your post. But your query only gives the number of entries grouped by SystemName. That is partly what I need. But I need divide further by different bp_type within each SystemName.quote: Originally posted by vijayisonly Does you sample data and expected output match??maybe u need this?select systemname,bp_type,count(*) from @t group by systemname,bp_type
|
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-08-25 : 18:48:33
|
Huh?vijayisonly's query is grouping by systemname,bp_typeThat should do exactly what you want or what I am missing? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
VLADIM
Starting Member
1 Post |
Posted - 2009-08-26 : 07:22:29
|
| I am work with Visual Studio 2005 + C# + XQUery.Below is part FILE.xml<xs:element nam_="ScheduleSteps"...... </xs:element><xs:element nam_="aliasName"...... </xs:element><xs:element nam_="localName" ...... </xs:element><xs:element nam_="mRID" ...... </xs:element>Part from the programs on C# ....... string s_qu = "<NSet> { " + " for $aa in document(\"FILE.xml\")//@*[1] " + " return <Tb> { ($aa) } </Tb> " + // (: ?? " return <Tb> { data($aa) } </Tb> " + " </NSet> "; .......1. With operator { ($aa) } i get nam_="ScheduleSteps" nam_="aliasName" nam_="localName" nam_="mRID" And it is true. 2. But with operator { data($aa) } i get error < ')'expected > Function data() is no right ? Help my please if possibal. Vladim. |
 |
|
|
|
|
|