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
 General SQL Server Forums
 New to SQL Server Programming
 Conditional Row

Author  Topic 

Charles AWI
Starting Member

15 Posts

Posted - 2011-05-23 : 15:26:40
I am trying to add a row to a table when it meets a certain criteria. When one of the current rows has a numerical value for the field "national brand" I would like a row to follow showing that ITEMs information.

Currently I made a report that only shows off brand items, Its designed to show to our customers. I would like to contain information about the national brand, if that generic ITEM has a "national brand" if it does i would like it to spit out the information about the national brand right below the information about the generic brand.

If the generic brand doesn't have a national brand its just 00000

If it does i would like to make another row filled out with the National Brand Information


EX.

catalogcode____ITEMCODE___Size___NATIONAL_Brand___ Price
00001__________12345______5______00000____________1.00
......................................................
00002__________12346______8______00000____________2.00
......................................................
00003__________12347______4______00000____________1.50
......................................................
00004__________12348______5______47532____________2.50
39642__________47532______5______null______________3.50
......................................................
00005__________12349______3______00000____________2.00
......................................................
00006__________12350______1______37634____________3.00
34254__________37634______1______null______________4.00


Does Anyone know how to do conditional Rows? Or how I would be able to do this??



WebFOCUS 7.6

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-05-23 : 16:06:27
I would break up the problem into two parts - first, how to store the information, and second, how to present the information.

With knowing only what you described: details about the national brand should be in a separate table and as you have indicated, the value in the national brand column would be a foreign key from that table.

As for presenting, it depends on what kind of reporting tool you are using. If you are using SQL Reporting Services, for example, optional details rows can be added. If you are using something like a .Net DataTable to present the data, then again, it allows you to present the data in the master-detail format.

For SSRS and for DataTable, you would return the master table information and the details information in two record sets - and they can be linked using the foreign key that you used.

On the other hand, if you are trying to get a query to return the data as SINGLE record set that includes the detail about the national brand, I would seriously recommend against that approach. I say this for various reasons - for example, you would need to line-up the columns of the sub-rows with those of the main rows including data types etc.
Go to Top of Page

Charles AWI
Starting Member

15 Posts

Posted - 2011-05-24 : 09:16:54
Its for WebFOCUS. I beleive I may have found a way to achieve this but it is to early to tell.

WebFOCUS 7.6
Go to Top of Page
   

- Advertisement -