|
|
Hi,
Apologize if you did not understand my problem..I am describing it again..
I have table which having four column,falconid,priority,affected item and region.
falconid is primary key,priority shows how much critical is problem,affected item shows which application is affecting and user is facing problem,region shows the different time zone
multiple user is raising the tickets from different zone with respect to affected item.that all will save in single table. like below..
falconid priority affecteditem region
1 1 textbook ny
2 1 database ln
3 2 textbook ln
4 1 database zu
5 2 coin ny
6 2 textbook zu
Now I want to calculate at the end of the day,that how many ticket(count*) has been raise for the particular affected item from which zone.. in table there are 3 ticket for textbook but from different region
I want to calculate the number of ticket raised from different region on affected item wise..like below
affecteditem ln zu ny
textbook 1 1 1
database 1 1 0
coin 0 0 1
|
|
|
|
|
I understand, you want to PIVOT priority for each region by affecteditem. You need a PIVOT query, it is not a simple thing therefore I directed you to an ARTICLE that will help explain and guide you through creating the PIVOT query. There are also some excellent examples in BOL that you might want to work through.
I could write the query for you but I already know how to do these and you need to learn, so!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi Rah,
Thanks for the article,I am trying but as I am not the database resource so it will take the time.. I am learning now how pivote works.... but it is urgent for me as i have to demo of project tomarrow,, can u provide me the query on urgent basis.....
Thanks in advance,
Abhishek
|
|
|
|
|
create table #table (affected item varchar, LN int, NY int, Zu int)
insert(table)
select
Affected item,SUM( case region when 'LN" then 1 else 0) LN,SUM( case region when "NY" then 1 else 0) NY,SUM( case region when 'ZU" then 1 else 0) ZU
from tablename groupby affected item
please advice if i am wrong?
Thanks,
Abhishek
|
|
|
|
|
I rried to post a little bit ago but that must have bombed off. I'm using Access 2007 in query design mode
At this point I have gotten to where I show the 24 test records for Material Inventory in the correct storage yards. The SQL statement is:
SELECT MatInv.MatInvID, Location.LocationName, MatInv.LocationID, MatInv.Units, MatInv.CostCenterID, MatInv.Condition, MatInv.TasksID, MatInv.MaterialsID, MatInv.CostCenterID, Materials.MaterialsID, Materials.Material
FROM Location INNER JOIN (Materials INNER JOIN MatInv ON Materials.MaterialsID = MatInv.MaterialsID) ON Location.LocationID = MatInv.LocationID;
Now I need to show where two 2 items of material in each storage yard came from a DIFFERENT CostCenterID than the CostCenterID of the storage yard. The storage yards are costed based upon the lease they are loacted on. There can be several hundred wells for each lease- all with the same CostCenterID. SOMETIMES, material from one well on one lease (one CostCenterID) may be stored in another leases storage yard (another CostCenterID). I need to be able to track it and point it out.
So I add in the table Well and relate the fields Well.CostCenterID to MatInv.CostCenterID and I get 36000+ records. Not the original 24 test records. So obviously the Query designer isn't what I need so I am trying to manipulate things in SQL view- STILL without any luck. Trying to follow info on Access help that is just about useless. Current SQL statement is:
SELECT Well.CostCenterID, Well.Well, MatInv.MatInvID, Location.LocationName, MatInv.LocationID, MatInv.Units, MatInv.CostCenterID, MatInv.Condition, MatInv.TasksID, MatInv.MaterialsID, MatInv.CostCenterID, Materials.MaterialsID, Materials.Material
FROM Well INNER JOIN (Location INNER JOIN (Materials INNER JOIN MatInv ON Materials.MaterialsID = MatInv.MaterialsID) ON Location.LocationID = MatInv.LocationID) ON Well.CostCenterID = MatInv.CostCenterID;
Any assisance is appreciated,
Larry
|
|
|
|
|
This article may help.
Caveat - I use SQL Server not Access
I find it easier to lay out my own joins so they are more human readable. Start with the minimum tables to get the minimum result, then expand on it.
Get a list of material and their storage location with cost center
Get a list of wells and their cost centres
get the relationship between well and material, compare cost centers
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I liked the link- useful. Right on, I had started back with just two tables and worked my way up from there. I finally decided to add another ID field to one of the tables (breaking normalcy rules) but it helped make it an easier sql select statement. I only had to change a small bit of code to make sure that everything gets saved properly to the tables. So it works now- thanks.
Larry
|
|
|
|
|
lemarshall wrote: (breaking normalcy rules)
These should be known as guidlines as they are subject to reality and business requirement. Having said that I alway looks very closely at a design that does not conform to these guidelines, it is usually wrong somewhere.
You got it fixed - always satisfying.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
hi,
i have created database with some fields containing nvarchar data. updated data in unicode kannda language text. I am writing queries like :- select * from table where district='UÀÄ®âUÁð'.It will not retriewing any rows. command executed success.
Thanks
************ S G KORE *******************
-- Modified Saturday, September 18, 2010 3:26 AM
|
|
|
|
|
try: select * from table where district=N'UÀÄ®âUÁð'
nvarchar and ntext types require the N prefix before the opening quote when you're searching for unicode text.
"An eye for an eye only ends up making the whole world blind"
|
|
|
|
|
Thank you Rob Smiley.
Its working
************ S G KORE *******************
|
|
|
|
|
Hey,
I have a table named volleyballsecondround8 which has columns like 'Winner', 'Loser' and 'MatchNo'.
I'd like to make a SELECT statement as it takes the 'Winner' where 'MatchNo'='M20' and puts it ind the [0]. row of my new table, then takes the 'Loser' of 'MatchNo'='M20' and puts it into the second row.
Therefore;
When I execute a query on volleyballsecondround8 like the following:
Select @row := @row + 1 as row,Winner,Loser
from volleyballsecondround8,(SELECT @row := 0) r
Where MatchNo IN('M20','M19','M18','M17') Order
I get e resultant table like:
ROW-Winner-Loser
----------------
1-India-Luxemburg
2-USA-Spain
3-Turkey-Argentina
Where, I want a table like:
ROW-TEAM
-----------
1-India
2-Luxemburg
3-USA
4-Spain
5-Turkey
6-Argentina
any help?
|
|
|
|
|
SELECT Row,
0 AS resultorder,
Winner
FROM volleyballsecondround8
UNION ALL
SELECT Row,
1,
Loser
FROM volleyballsecondround8
ORDER BY Row ASC, resultorder ASC
|
|
|
|
|
thanks for help but I decided to take all the data to a DataTable and then sort it in the C# part of the project, the hard way =)
thanks again
|
|
|
|
|
Simple question I know but I just cannot find a anything that works.
INSERT INTO [Location] ([id],[TZOffset],[Address],[Tel],[Fax],[Contact1],[Contact2],[Contact3],[Company],[Deleted],[Disabled]) VALUES (8,null,N'line1
line2
',N'',N'',1,2,3,null,null,null);
GO
I have tried everything I can find but there is no ESCAPE or CHAR function in SQLCE that I can find. You cannot use Stored Procedures, being CE so it has to be done in a command space.
If I store the CRLF in the raw data and push it using MFC then it works fine.
Any ideas?
Great isn't it. I can use SIN, COT, SQRT but I cannot put CRLF into a string!!?!??!?!
Alan
|
|
|
|
|
Me thinks your data structure is screwed, whenever I seelsomething like contact1, contact2, contact3 I know you are in deep poop. What if there is a fourth contact, woops lets add another column - FAIL
Create another table callemd contacts and a foreign key to this company table.
What has CRLF got to do with your insert statement?
There seems to be a number od problems with your insert statement. There is no comma between line1 and line2. Do comapny, deleted and disabled accept null as valid data.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Well you would be right if that is the way the fields were being used but they are not. There will only be three contacts as these fields hold pointers to entries in a Contact table.
I want to use a single ADDRESS field to store a multiline address rather than have 5 separate fields (one for each line).
There is no comma between line1 & line2 becuase they are stored as "line1\r\nline2 " in the application internals.
Now I can do that everywhere else (CString, Registry etc...) so why is it so unreasonable to want the same thing in SQL CE?
Alan
|
|
|
|
|
Not being a user of CE, and unwilling to install it in case it destabilises something, I can't test his. Have you tried forcing a linefeed manually by inserting chr(10). Then try chr(13) + chr(10), forcing a carriage return and line feed. Seems like your transport layer may be messing with the \r
Thanks for the explanation (one should stick to the Lounge when one returns home pissed) but I still think field1-3 is an incorrect design.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Ok things are getting even wierder than I thought they were to start with.
I have done some testing with my own code and I have observed that INSERT preserves the 0x000D,0x000A when written to the DB but then if I use UPDATE on the same field with the same data I get '?' stored in the DB?!?!?!?
Now this smells to me of a bug in the OLEDB... Anway it looks like I am going to have to restructure my code and DB to provide separate fields for each address line. I then have to glue them together when I retrieve them and split them apart when writing.
You are still getting hung up on the Contact1/2/3. This is simple the variable names I use within the code so I can easily find all the code dealing with the contacts. In presentation they are Primary, Secondary and Reserve. Simples.
Alan
|
|
|
|
|
Instead of multiple fields for the address you might look into storing it as XML data or varchar using XML to structure the address.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Dear experts,
Which version ODP.net is exactly required for oracle 11.2 and .net 2.0?
|
|
|
|
|
|
Hi,
Let me start off by giving some background on the events that have lead up to this issue that I'm having. I started with VS2008 and SQLEXPRESS. A few months later, I installed VS2010 and converted my project. A week or so later, I decided that I wanted to install SQL Server 2008 R2, so I installed that as well, not uninstalling SQLEXPRESS. My application has been running great and the reports were working fine for the past several months. I then rebuilt my entire application. Now I can not get my application to compile and I've been spinning my wheels in the mud for a week.
What I am seeing is the message in VS2010 that states: The report definition is not valid. Details: The report definition has an invalid target namespace 'http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition' which cannot be upgraded.
Not being a SQL Expert from an Admin side I have read a lot of forums which basically said that I needed to get the Report Server running and grant the roles accordingly. The Report Server now works and I can create reports using Report Server R3 no problem, however I'm still getting the error when trying to compile.
In the ReportViewer Tasks in VS2010, where you can select the report, I'm using a local report, not a server report. IE: ApplicationName.Reportname.rdlc
I am guessing the issue is the NameSpace is for a Server report and not a local report, and I should have some type of ConnectString? I really don't know what the problem is.
Any help is greatly appreciated.
*** UPDATE *** - I still have the issue with a brand new application built with VS2010 using the same table stored in SQL Server 2008 R2. Am I restricted to using Server Based reports after installing SQL Server 2008 R2?
<Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition">
<DataSources>
<DataSource Name="KTReunionDataSet">
<ConnectionProperties>
<DataProvider>System.Data.DataSet</DataProvider>
<ConnectString>/* Local Connection */</ConnectString>
</ConnectionProperties>
<rd:DataSourceID>0a8b6f23-4772-446f-9b27-5f180b760bc4</rd:DataSourceID>
</DataSource>
</DataSources>
Glenn
modified on Thursday, September 16, 2010 11:13 PM
|
|
|
|
|
hello,
i am usin sql server 2008.I have database which has been hosted on server i want to know whether they are given full access permission or not. bcoz when i work with local database it works fine. when i connect my server it will not works. like when i right click >> show top 1000 rows menu item will be displayed.it will not in when i connect to server. even i can't view tables listed in database.
|
|
|
|
|