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 |
|
SQLNoob81
Starting Member
38 Posts |
Posted - 2011-06-21 : 06:00:57
|
| Hi I need to create a report. Here are the detailsI have a table called SubCat that looks like thisSubCat IDNetwork Support ITProgrammer ITAccountant FinanceBookkeeper FinanceSales Rep MarketingSales Admin MarketingDoctor Medicaletc etc etcI then have another Table Called JobOrderID Candidate Fee Race Gender Category SubCat1 Joe 1000 White Male IT Network Support2 Soap 2300 Indian Female Financial Accountantetc etc etcI need a report (gridview) that when I select The Categort (IT or Financial etc) that I get the following report. It counts how many orders we Placed per subcategory / Gender / Race.SubCategory Black Male Black Femal White Male White Female Indian Male Indian Female etc etcHope this makes sense?? |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-06-21 : 07:02:14
|
| What do you mean when you say report?If that is reporting services or some other package then you will need a fixed resultset format - you will need to specify the number of columns and their headings.If it's a query or something you have more control over (a .net grid) then you can get the values dynamically.==========================================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. |
 |
|
|
SQLNoob81
Starting Member
38 Posts |
Posted - 2011-06-21 : 09:57:00
|
| Hi, Sorry. I need to create a SQL statement that will display the following:ID Candidate Fee Race Gender Category SubCatSubCategory Black_Male Black_Female White_Male White_Female etc Network Support 11 0 5 2Programmer 4 4 7 9DB Administrator 4 3 7 0IT Support 45 5 54 2Hope that helps? |
 |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-06-21 : 10:17:23
|
| Try this - maybe it'll help you think about what you want.select sc.SubCat,BlackMale = sum(case when jo.Race = 'Black' and jo.Gender = 'Male' then 1 else 0 end),BlackFeMale = sum(case when jo.Race = 'Black' and jo.Gender = 'FeMale' then 1 else 0 end)...from SubCat scleft join JobOrder joon sc.SubCat = jo.SubCatgroup by sc.subcat==========================================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. |
 |
|
|
|
|
|