SSRS Report table grouping on multiple columns - reporting-services

I'm trying to group my SSRS report based on multiple columns and I'm sure I'm missing something here.
Here is my example
Now I want to group my table based on column 2 (Name) and then expecting a result like below
I tried to group by adding parent group and child group but the result is coming in two different columns. But I want to put it in different rows like above.
Any help much appreciated.

Create a table.
Click the first cell and choose Skill from the dropdown. You should have a single rowgroup (probably called 'details')
Next, right-click the rowgroup and choose "Add Group - Parent Group". Choose "Name" as the Group By field and check the "Add group header" option.
This will add a new column, ignore this for now, we will delete this shortly.
Next, on the group header row, directly above where 'Skill' is, choose "Name" from the dropdown.
Finally, delete the column that was added when you added the parent group. If you are prompted choose "Delete column only" (this will retain the group).
Optionally, format the backcolor of the Name cell and that's it.
If you still cannot get it to work, let me know and I will post a full answer with images.
UPDATED: The long version
I started by creating a new blank report and adding a dataset DataSet1 that recreates your dataset with the following
DECLARE #t TABLE(row_id int, [Name] varchar(10), Skill varchar(10))
INSERT INTO #t VALUES
(1, 'David', 'Oracle'),
(2, 'David', 'Java'),
(3, 'David', 'HTML'),
(4, 'John', 'C#'),
(5, 'John', 'SQL'),
(6, 'John', 'HTML'),
(7, 'John', 'ASP'),
(8, 'Amy', 'Python'),
(10, 'Asa', 'Java'),
(11, 'Asa', 'Oracle')
SELECT * FROM #t
I then inserted a Table and dragged the Skill field onto the first cell.
Next, I right-clicked the "(Details)" row group in the row groups pane and chose "Add Group => Parent Group"
I then chose "Name" for the "Group by" column and checked the "Add group header" option.
The table now looks like this..
Next I clicked in the cell above the Skill cell (this cell is in the [Name] row group) and chose "Name" from the dropdown.
Next I right-clicked the grey column header and chose "Delete columns". I also deleted the 2 blank columns.
I added some formatting to the Name cell so the final table design looks like this.
When I run the report, the output looks like this...
If you still struggle, I suggest replicating the above using the sample dataset I created above from a new blank report and get that going first, then look at the differences in your report.
Hope this helps.

Related

MySQL Insert into another table if the value price is higher than the new price

i have a problem and doesnt find any answer that helps me :/
I have two tables.
First table is items.
It has this rows name, isbn, siteid, price, site, link, imagelink
The 2nd table is "deals". Has the same rows!
If there comes a new price, that is LOWER than the price that shows on "items" table for the item with the same link, than it will create a new deal on deals table.
So the link is what it must be the same. Every link is unique. And if the link is found and the new price i have is lower, than it must be insert into deals
Is that working in one Query?
Here was my try but not working
INSERT INTO deals (name, isbn, siteid, price, site, link, imagelink)
SELECT
(%s, %s, %s, REPLACE(%s, ',', '.'), %s, %s, %s)
from items WHERE price > %s AND link = %s;
To answer directly: you could add a trigger that does this.
But in your situation, I'd say that you shouldn't.
Either create a view that just lists all of the values with a certain price. That has several advantages: if you want to change the price of items, you don't need to repopulate your deals table, and you're not storing redundant data.

insert if not exist without making column unique

I am searching for the answer of this question by many days. There are some answers on stackoverflow and on ther sites which I really don't understand. Basically I need to insert only if cell value for particular column does not exist.
Ex: See below table, if their are some duplicate names present it's ok like 'sandy' and 'edward'. But for some names like 'wilson' I don't want to insert. I don't want to make name column unique at all.
Note : Please don't give any complicated answer or procedural queries, it should be easy to remember.
you should make another column/table to determine which name can't duplicate
Then, you select the name whether can be duplicate or not from that table and then insert based on result
You can make a checkbox at HTML FORM.
You fill form values
If that checkbox checked, then before inserting in database, it will will check if exists then no insertion. If not exists then insert.
If that checkbox is not checked, then insert blindly
try the following:
INSERT INTO info (id, name)
SELECT null, 'wilson' FROM any_other_table_name
WHERE NOT EXISTS (
SELECT name FROM info WHERE name = 'wilson'
) ;
It will not insert if multiple entry.

How to select unique values from one column based on a value in another column?

The structure of the table is that a value in the child_id column can be duplicated but has a different associated parent_id for each duplicate. Say child_id 1 has four parents, then it will have 3 copies of itself in the child_id column, but each duplicate is associated with each of the 3 different parent_id.
Given those conditions, what I'm trying to achieve is to sort by parent_id and remove the unwanted child_id duplicates by picking only one based on the last or closest parent (level of that parent would be -1 the level of the child). Is that possible?
I tried to create a fiddle on sqlfiddle but I keep getting a create script error so I guess I'll just paste the code here:
CREATE TABLE `parent_child_columns` (`id` int auto_increment,
`child_id` int,
`parent_id` int,
`level` int,
PRIMARY KEY (`id`))
INSERT INTO `parent_child_columns` (`child_id`, `parent_id`, `level`)
VALUES (1, 0, 1), (2, 0, 1),
(3, 1, 2), (4, 1, 2),
(5, 3, 3), (5, 1, 3), (6, 3, 3), (6, 1, 3)
SELECT pc.child_id, pc.level
FROM parent_child_columns pc
ORDER BY pc.parent_id
With this query, the duplicates still get picked up so a column is already displayed before another one when it should come AFTER that other one (since its level 1 parent is at the top when sorted ASC). (A parent column can have many child columns.) I can include screencaps of the actual data in my database if necessary.
I'm building a dynamic table header here where you can add an indefinite number of nested columns. There's a bit more stuff going on with how I arrange the rows and columns so if my explanation here is still a bit vague and you can't get a clear picture, please let me know. But a rundown of what I do is basically I try to build row by row and arrange the columns in each child level (or row) based on the order of the parent columns right above them.
What I'm getting:
Expected output is that in the actual table, 1843 should be under 1842, as seen in the database that its parents are 1839 and 1842. I'm only assuming that it's already under 1841 because it gets picked up earlier, but maybe that's not actually the case? Any better ideas as to what might be causing that?
P.S. In the example above I tried to split 1841 so it should have the 2 New Columns under it.
If you want the parent with "-1" the level of the child, then use join:
SELECT pc.*, pcp.id
FROM parent_child_columns pc LEFT JOIN
parent_child_columns pcp
ON pc.parent_id = pcp.child_id AND pcp.level = pc.level - 1
ORDER BY pc.parent_id;

How can I insert my data into two different tables in MySQL?

Hi I'm new in using MySQL, I would like to insert my data into two different tables, I don't know how to do it using a query. All I know from now is how to insert multiple data in one table.
My input Data in 5 textboxes were
textbox1 = Garcia (to be inserted in table1)
textbox2 = Michael (to be inserted in table1)
textbox3 = David (to be inserted in table1)
textbox4 = 24 (to be inserted in table2)
textbox5 = 8888888 (to be inserted in table2)
My table fields looks like this
Table1
Last Name
First Name
Middle NAme
Table2
Age
Contact No.
Since you've not specified a UI language I'm assuming that you simply want the SQL commands to do this.
INSERT INTO Table1 (`Last Name`, `First Name`,`Middle NAme`)
VALUES ("Garcia","Michael", "David");
INSERT INTO Table2 (`Age`, `Contact No.`)
VALUES (24, 8888888);
You've used bad table field names though. If this isn't working it is because you should remove periods and spaces from them all.
Also, it looks like you are just playing around but if you were being serious you'd want to include all of this information in one table and give that table a good name and an ID field.
I agree with with first answer you can have as many insert statement as you need if you are using SQL Server you need to add the word go between statements

How Can I Select Rows from MySQL Without Including Duplicates Across Two Columns

If someone can point me to a pre-existing question here, that'd be great. Turns out I'm having trouble finding this case.
Check out the SQL Fiddle to tinker with it. For the sake of SO search-ability, here is the schema and the question from the fiddle:
In my users table, I have a unique constraint on the
country a user is assigned to (no more than one user
per country). However, they may live wherever they choose.
START QUESTION
I only want to return users where the assigned country and
domicile shows up only once across records, in this case record 4,
where the duplication across columns is also not desired
and there are no duplicates across rows. How?! :)
CREATE TABLE users
(`id` int,
`country` varchar(255),
`domicile` varchar(255), UNIQUE(country)
)
;
INSERT INTO users
(`id`, `country`, `domicile`)
VALUES
# Duplicate across column and row
(1, "usa", "usa"),
(2, "canada", "usa"),
# Duplicate only across columns or no duplication
(3, "mexico", "mexico"),
(4, "uganda", "australia"),
# Duplicate only across rows
(5, "germany", "portugal"),
(6, "france", "portugal"),
(7, "spain", "portugal")
;
Leave aside for the time being that a proper design would make this easier. I'm just trying to work with the hand that's been dealt. ;)
I think this is the simplest way to do it:
SELECT *
FROM users
GROUP BY domicile
HAVING COUNT(*) = 1
FIDDLE
Unlike Eugen's answer, this one does depend on the fact that the country column has a unique constraint, so it only has to check domicile.
If I understand correctly, you want to deduplicate across both country and domicile - so we need 2 steps:
SELECT
MIN(id),
country,
domicile,
COUNT(*) AS domnum
FROM (
SELECT
MIN(id) AS id,
country,
domicile,
COUNT(*) AS counum
FROM users
GROUP BY country
HAVING counum=1
) AS base
GROUP BY domicile
HAVING domnum=1
EDIT
With your test data, deduplication across domicile is sufficient, but I included both steps anyway.
EDIT
SQLfiddle