If I have a table with say 10 columns and for example, and I want to extract the row where the value of one column changes, for example if the data value in column 3 changes, and I want to get that row and all subsequent rows when the value in col. 3 next changes.
How is the best way to achieve this?
I've tried similar refs, but not quite there.
TIA
This is the general idea (not specifically to Column No 3, but you can edit and implement it as per your need)
Step 1: At Insert / Update: Save checksum per row of the row data. Example of 5 fields (including first field being nullable and second being integer)
OUTER APPLY (
SELECT
v = BINARY_CHECKSUM (
ISNULL(c1, ''),
ISNULL(c2, 0),
c3,
c4,
c5)
) c_sum
Now save this c_sum into a field for the row in your table.
Step 2: AT Select: Select where checksum has changed:
First, recalculate the c_sum as above and lets call the previously saved value as c_sum_current_value
Then match new against old to get only the updated rows:
SELECT
bla, bla
.
FROM bla
.
.
.
WHERE
c_sum_current_value!=c_sum
My Query is like below for Table...,
Create Table t_raw
(
Month nvarchar(255),
Name nvarchar(255),
Clear nvarchar(255),
Contact nvarchar(255),
Viewed nvarchar(255),
Clicks float
)
Insert Into t_raw values('Jan-18','ABC','DTC','dtc#mz.com','GM','2'),
('Feb-18','QSC','FMM','fmm#mp.com','AM','6'),
('Mar-18','ABC','DTC','lta#mz.com','OPS','9'),
('Jan-18','MHY','GNMA','gnma#sr.com','REP','3'),
('Feb-18','VRL','XLR','xlr#vn.com','TUC','5'),
('Mar-18','MHY','GNMA','gnma#sr.com','XEM','7'),
('Jan-18','ABC','DTC','mat#sd.com','SUD','2'),
('Feb-18','MHY','GNMA','mio#fr.com','AFT','4'),
('Mar-18','TOC','ADF','fin#yu.com','BPL','2')
Below is the table:
I am expecting the below output like below.
Can anybody help me achieve this desired output?
Create a blank report and create a Data Source and a Dataset to connect to the data. Add a Matrix to the report. Drag the Name fiield from the Dataset in the "Report Data" window to the first "Rows" field of the matrix and select the Month field using the field selector in the Columns header field. Select the Clicks field in the data cell under the Month header, this should automatically result in a Sum. In the properties window of the Month Column Group change the sort order to an expression like
=CDate(Fields!Month.Value)
Change the width of the Name field to be wide enough to contain the four columns Name, Clear, Contact and Viewed (I chose 12 cm).
Now, right-click the Name header cell and insert a table via context menu. Don't worry about the hights and add an additional column in that table.
Do the same in the Name data cell
The design should now look like this:
In the table next to the Month field (I'll refer to that as "header table"), remove the Data row (and associated groups, when asked):
Then in the table next to the Sum(Clicks) field (I'll refer to that as "data table"), remove in turn the header row:
These steps resolve the problem with the hights.
In the "header table", enter the column names and format them as desired. In the "data table", select the corresponding fields to display. In the properties of the Row Group "Details1" of the "data table". add all 4 fields in the correct order for grouping and sorting.
For the fist 3 fields in the "data table", use the Properties sheet to set the HideDuplicates property to the name of your Dataset.
For the Sum(Clicks) TextBox, set TextAlign to "Center" and VerticalAlign to "Middle".
Oh, and add a total for the Name group of the outer matrix, align everything as desired.
VoilĂ :
Added:
To merge the cells for Name, Clear and Contact do the following:
In the properties of row group "Details1" of the "data table", remove Name, Clear and Contact under Grouping and under Sorting properties, so only Viewed is left. Rename the group to Viewed.
Remove the first three columns of the "data table" (Name, Clear and Contact).
Right-clicking always the topmost row group of the "data table", successivly add parent groups for Contact, Clear and Name.
Single value such as Text, Number, Decimal, is not hard to do, but what about radio options? checkboxes?
Single value UDF
FORM
- Id
- AttributeName
- DataTypeId
FORMVALUE
- Id
- FormId
- UserId (user that entered the value)
- Value
DATATYPE
- Id
- DataTypeName
First of all I would use "atrributes" just for input and move it to normalized table.
Lets do reaserach first:
ComboBox - State (0/1)
CREATE TABLE CHECKBOX(
cb_id,
cb_label,
cb_state bit --0 no 1 yes)
RadioButton - Group with checked state.
Hmm....
CREATE TABLE RadioGroup (
rg_id int primary increment etc,
rg_name,
rg_selectedindex)
Create table RadioVariants
(rv_id,
rv_rd_id,
rv_label -- text to show on site)
)
While parsing query to your application, to every radio button add ra_id.
While saving result u get rv_id whitch represents selected value.
So now lets do a form table
CREATE TABLE Form (fa_id, fa_name)
CREATE TABLE FormControlls (fac_id, fa_id, fa_rg_id, fa_cb_id)
So finnaly you have a form with refers to checkboxes and radiogroup items.
In application you have to set rv_id to radiogroup variant and pass it to UserFormData.
CREATE TABLE UserFormData (ufd_id, ufd_fa_id, fa_rg_id, fa_rg_value --ID of selected variant,
fa_cb_id, fa_cb_value --state of checkbox)
Im late for meeting, but I belive u "catch" the theory.
I have a datagrid, which contains two columns.. second column will contain a dropdown .. The dropdown contains all the DB column names and when i select any DB column field from the dropdown then the field will be mapped to first column and the selected field from the dropdown will no longer exists in the dropdown.
when i clear the field from the first column, then the field will again bind to the dropdown, but the field is displaying at the last in the dropdown, so the field should not be displayed at last, it should display in it's previous place(i.e from the place where the field mapped from dropdown).
So can any one please let me know how to handle this is xaml.cs file.. That will be more helpfull for me...Thanks !!!
Initially i have declared an ObservableCollection OcCols = null;
//Used TableColumnsQuery in swith case case and adding all the column names from the table and then added the columns to OcCols.
TableColumnsQuery is declared as "SELECT COLUMN_NAME FROM information_schema.columns WHERE COLUMNPROPERTY(object_id(TABLE_NAME), COLUMN_NAME, 'IsIdentity')!= 1 and table_name ="
case "TableColumnsQuery", in the case adding all the columns from the table to OcCols and then adding the OcCols to the grid.
((GridViewComboBoxColumn)this.gridMappings.Columns[2]).ItemsSource = OcCols
Gridmappings is the grid name and second column has the combo box\dropdown which i have xplained earlier.
so now how to sort the columnfileds in the combobox/dropdown.
Thanks!!!
I have two tables, user and company, and I have a combo box in which I list all the companies I have in the company table. My question is, how to use databinding in foxpro to display the company name? When I save the information to the database, I only need to save the company ID; same for display, from the company ID I have in my user table, I would like to display the company name.
I tried using the properties :
CmbCompany.controlesource = myTable.companyID
cmbCompany.displaysource = myTable.companyName
but this doesn't work, I missing something!
Set the RowSource for the combo so that it puts the data you want to show in the first column, and the value you want to store in the second. Set BoundColumn to 2 and, if your ID field is numeric or integer, set BoundTo to .T.
I'd do all this in the property sheet, but something like this:
RowSourceType = 6-Fields
RowSource = Company.CompanyName, ID
BoundColumn = 2
BoundTo = .T.
ControlSource = MyTable.CompanyID
Tamar