|
Hi i want to convert msaccess pivot query to mssql server 2005 pivot query can anybody help me?
TRANSFORM Sum([Kartella1-meion].[m]) AS ΆθροισμαΤουm
SELECT [Kartella1-meion].[PEL_PRO_CODE], Sum([Kartella1-meion].[m]) AS meion
FROM [Kartella1-meion]
GROUP BY [Kartella1-meion].[PEL_PRO_CODE]
PIVOT Format([HME_PAR],"mmm") In ("Ιαν","Φεβ","Μαρ","Απρ","Μαϊ","Ιουν","Ιουλ","Αυγ","Σεπ","Οκτ","Νοε","Δεκ");
|
|
|
|
|
|
Thanks for the answer .
Issue resolved.
|
|
|
|
|
|
I am writing a utility to copy tables from one DB to another. This can be from MySQL, MS SQL Server, MS Access DB, or SQLite DB to another DB of one of the above types. The program handles any of the above combinations. For example, the user can choose to copy a table from MySQL server to an MS Access database. I am using ADO.NET to write this app.
Currently I create a DataReader using the query "Select * from ", and then call its GetSchemaTable() method to obtain the field info of the source table. This method returns a DataTable that contains each field's basic info such as field name, type, size, whether or not it is a key, etc. These allow me to do the data type match and create the fields in the target DB.
My question is how to obtain the source table's index info. The above DataTable object seems not sufficient for this purpose. Can you give me a pointer as to how this can be done? Thanks!
|
|
|
|
|
There's no unified API for that. You will have to implement it for each of those database systems individually. For SQL-Server you could either query the INFORMATION_SCHEMA or use SQL Server Management Objects (SMO). For MS Access there are also queryable schema-tables (MSys_xxx). No idea regarding the other database systems though, would have to ask Google.
|
|
|
|
|
Hi,
I have employee_benefits MySQL table with the following fields:
employee_benefit_id --- autonumber
employee_id
benefit_category
benefit_description
benefit_amount
I want to loop through all records in the above table and insert the values into salary_slips table which has the following fields:
salary_slip_id --- autonumber
document_id ---- forget this it's just UUID
employee_id -- from employee_id in employee_benefits
slip_month -- from SP variable param_slip_month
slip_year -- from SP variable param_slip_year
and then I want to insert data into salary_slips_details:
salary_slip_details_id --- autonumber
salary_slip_id -- the id from salary_slips table
slip_details_description -- benefit_description from employee_benefits table
slip_details_amount -- benefit_amount from employee_benefits table
How can I do this complicated query please?
Thanks,
Jassim
Technology News @ www.JassimRahma.com
|
|
|
|
|
I can not create database when using Database Configuration Assistant (Oracle 12.1.0).
IMAGE ERROR DESCRIPTION
Help me! Please..
|
|
|
|
|
Do you have McAffee virus on you computer? Deactivate it!
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
|
..and what does the log message say?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
sorry, where i can find log error file in oracle 12c?
|
|
|
|
|
Try the one mentioned in the error.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I have the following SQL table,
ID LogDate Name Department
-----------------------------------------------
1 3/26/2015 7:55 AM Adam HR
2 3/26/2015 7:53 AM Tony Fin
3 3/26/2015 7:59 AM Mark Mang
1 3/26/2015 8:15 AM Adam HR
3 3/26/2015 8:10 AM Mark Mang
2 3/26/2015 7:53 AM Tony Fin
i like to get this output
ID LogDate Name Department
-------------------------------------------------
2 3/26/2015 7:53 AM Tony Fin
1 3/26/2015 7:55 AM Adam HR
3 3/26/2015 7:59 AM Mark Mang
i want to get a single record for each user ordered by min LogDate.
my table name is "DeviceLogs"
|
|
|
|
|
A simple solution would be,
SELECT TOP 1 * FROM DeviceLogs ORDER BY LogDate;
Which will select the top 1 record from your records, ordering them by your column containing LogData, you can add or remove DESC at the end of the ORDER BY clause if it returns the opposite side and so on.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
then is selects just a single record.
i want records of all users to be selected but without repeating.
if userid 1 has more than one log then just select earliest record for user id 1 and ignore other records for him.
|
|
|
|
|
Then you should group your records using GROUP BY clause over your LogTime column.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
SELECT * FROM DeviceLogs GROUP BY LogDate
this gives me error "because it is not contained in either an aggregate function or the GROUP BY clause"
|
|
|
|
|
Well you select all columns and group by LogDate.
Group by makes a single row out of all the rows that have the same LogDate in this example.
But what information is it supposed to put in ?
That's what aggregate functions are for.
However I think you should group by name, where LogDate=the day you want to select by.
You could also group by LogDate and name.
Anything that isn't in group by must be in an aggregate function.
So you have to decide which time you want to have selected (from what I deducted, first log ? ).
A bit unrelated to your question, but why do you have ID's that repeat ?
|
|
|
|
|
Are your Logdates varchars?
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Would this help?
SELECT ID, MIN(LogDate) AS LogDate, Name, Department
FROM yourtable
GROUP BY ID, Name, Department;
Mongo: Mongo only pawn... in game of life.
|
|
|
|
|
SELECT d.ID, d.LogDate, d.Name, d.Department
FROM DeviceLogs d, (SELECT MIN(LogDate) FROM DeviceLogs GROUP BY Name) s
WHERE s.MIN(LogDate) = d.LogDate
ORDER BY d.LogDate;
SELECT ID, MIN(LogDate) AS LogDate, Name, Department
FROM yourtable
GROUP BY ID, Name, Department;
|
|
|
|
|
|
Hi All,
I have written a small sql script to drop a table and recreate it but it is failing, I tried to drop all existing indexes on the table and column then trying to drop the column, but still fails by saying there is one constraint that's missing, and I don't know why but that constraint doesn't exist in database.
Here is the script that I am writing
DECLARE @ConstraintName nvarchar(200);
DECLARE @TableName nvarchar(500)='ApplicationData';
DECLARE @ColumnName nvarchar(500)='ReportingFpl';
SET NOCOUNT ON
SET xact_abort ON
WHILE 0=0 BEGIN
SET @constraintName = (
SELECT TOP 1 constraint_name
FROM information_schema.constraint_column_usage
WHERE table_name = @tableName and column_name = @columnName );
IF @constraintName is null BREAK;
EXEC ('alter table "'+@tableName+'" drop constraint "'+@constraintName+'"');
END
ALTER TABLE dbo.ApplicationData DROP COLUMN ReportingFpl;
GO
Error Message
Msg 5074, Level 16, State 1, Line 16
The index 'IX_ApplicationData_ApplicationId-ReportingFpl_PriorityPoints-ContractorPriorityPoints' is dependent on column 'ReportingFpl'.
Msg 4922, Level 16, State 9, Line 16
ALTER TABLE DROP COLUMN ReportingFpl failed because one or more objects access this column.
But the constraint 'IX_ApplicationData_ApplicationId-ReportingFpl_PriorityPoints-ContractorPriorityPoints' doesn't exist in the constraint table at all.
Can anybody please help me in resolving this issue, any link, any suggestion or code snippet helps greatly.
Thanks in advance.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
Hello sir,
I have dedicated server with 8 Gb RAM.I have developed the CRM when multiple user working at a time Sql server working very slow task is going on suspended.
Sql server 2008 R2 Express Edition
Database Size=6Gb
Maximum Memory=2147483647 Mb
Minimum Memory Per query=1024 kb
Pls.... suggest
|
|
|
|