Based on the following table
Area S1 S2 S3 S4
--------------------
A1 5 10 20 0
A2 11 19 15 20
A3 0 0 0 20
I want to generate an output that will give the number of columns not having "0".
So the output would be
Area S1 S2 S3 S4 Count
-------------------------
A1 5 10 20 0 3
A2 11 19 15 20 4
A3 0 ...
I have a MySQL file that represents my database in a specific state that would allow me to test a class I am working on. What I want to do is have PHPUnit clean and rebuild the database from this file for each test or set of tests.
How can I go about that without having to resort to rewriting the data in the XML format that PHPUnit uses...
I have 2 related MySQL tables in a one to many relationship.
Customers: cust_id, cust_name, cust_notes
Orders: order_id, cust_id, order_comments
So, if I do a standard join to get all customers and their orders via PHP, I return something like:
Jack Black, jack's notes, comments about jack's 1st order
Jack Black, jack's notes, comm...
OK, I have txt files that I am parsing and saving into a sql db. The names are formatted like
R306025COMP_272A4075_20090929_080159.txt
However, there are a select few (out of thousands of files) with names that are formatted differently (particularly files that were generated as tests), example
R306025COMP_SU2_TestBottom_20090915_101...
Hi all,
Well I have read ALOT of posts and I can't quite find the perfect answer to my question, (or I have and havn't realised it!:-))
I have a large csv file that I want to read into my program and sve it to a SQL database table.
I'm useing VB2008 and my dabase is SQL2008.
Any help would be appreciated.
Cheers Cookster
...
Continuing with the spirit of using the Stack Exchange Data Explorer to learn SQL, (see: Can we become our own “Northwind” for teaching SQL / databases?), I've decided to try to write a query to answer a simple question (on meta): What % of stackoverflow users have over 10,000 rep?.
Here's what I've done:
Query#1
SELECT COUNT(*)
FROM ...
I am building a poor man's data warehouse using a RDBMS. I have identified the key 'attributes' to be recorded as:
sex (true/false)
demographic classification (A, B, C etc)
place of birth
date of birth
weight (recorded daily): The fact that is being recorded
My requirements are to be able to run 'OLAP' queries that allow me to:
's...
What data type should I use for data that can be very short, eg. html link (think twitter), or very long eg. html blog post (think wordpress).
I am thinking if I use varchar(4000), it maybe too short for a html formated blog entry? but if I use text, it will take up more space and is less efficient?
[update]
i am still condering usin...
CREATE PROCEDURE USP_SEARCH_HOTELS
(
@Text varchar(50),
@Type varchar(40)
)
AS
BEGIN
Declare @Query VARCHAR(60)
IF @Type = 'By Country'
BEGIN
SET @Query = 'Hotel.countryName like '+ @Text+'%'
END
ELSE IF @Type = 'By State'
BEGIN
SET @Query = 'HOTEL.stateName like '+ @Text+'%'
END
ELSE IF @Type='By Property Name...
hey guys, just having a bit of difficulty with a query, i'm trying to figure out how to show the most popular naturopath that has been visited in a centre. My tables look as follows;
Patient(patientId, name, gender, DoB, address, state,postcode, homePhone, businessPhone, maritalStatus, occupation, duration,unit, race, registrationDate ...
Hello,
I have two tables in a master-detail relationship.
The structure is more or less as follows:
Master table:
MasterID, DetailID, date, ...
masterID1, detailID1, 2010/5/1, ....
masterID2, detailID1, 2008/6/14, ...
masterID3, detailID1, 2009/5/25, ...
masterID4, detailID2, 2008/7/24, ...
masterID5, detailID2, 2010/4/1, ...
masterID6...
Ad hoc queries vs stored procedures vs Dynamic SQL. Can anyone say pros and cons?
Best regards, Kristaps
...
Like i said in the topic: I would like to insert as a ClickOnce prerequisites sql server express r2 editions. I can do a similar package.xml and product.xml like that of sql server express that i took from vs2010 but i don't have the public key for SQLEXPRWT_x86_ENU.exe does anyone know how to find the public key ???
...
can any one help me in generating query for the below scenario?
i have twop tables TableA and TableB
TableA has teh follwing columns EMPLOYEEID, SKILLSETCODE,CERTID, LASTNAME, FIRSTNAME, MIDDLEINITIAL
TableB has two columns EMPLOYEEID and key_user
i want to SELECT EMPLOYEEID, SKILLSETCODE,CERTID, LASTNAME, FIRSTNAME, MIDDLEINITIAL ...
Asking a simple question, just want everyone have fun to solve it.
I got 2 tables.
1. Student
2. Course
Student
+----+--------+
| id | name |
+----+--------+
| 1 | User1 |
| 2 | User2 |
+----+--------+
Course
+----+------------+------------+
| id | student_id | course_name|
+----+------------+------------+
| 1 | 1 | ...
I have an sql scenario as follows which I have been trying to improve.
There is a table 'Returns' which is having ids of the returned goods against a shop for an item. Its structure is as below.
Returns
-------------------------
Return ID | Shop | Item
-------------------------
1 Shop1 Item1
2 Shop1 Item1
3 ...
I have a SQL Server 2008 database with > 300 tables. The application I have to design is an Windows Forms app, .NET 3.5, C#.
Which is the best way to work with Linq-to-SQL ?
I intend to make a datacontext for each business entity.
Is there any problem ?
I need to know if this way of working with Linq-to-SQL has any disadvantage or ca...
If I have a table with a schema like this
table(Category, SubCategory1, SubCategory2, Status)
I would like to group by Category, SubCategory1 and aggregate the Status such that
if not all Status values over the group have a certain value Status will be 0 otherwise 1.
So my result set will look like
(Category, SubCategory1, Status)
...
Is it possible to pass a SQL script to some method that Entity Framework has to run it against my model? e.g. equivalent of:
context.ExecuteStoreCommand(<tsql script path>);
Background: I want a way to reset the database during unit tests, and making a call to run the EF generated TSQL script (from Generate Database from Model) seem...
I have two tables A,B which are related to each other (simplified):
A:
+-------+---------+
| id | type |
+-------+---------+
| 1 | apple |
| 2 | orange |
| 3 | banana |
+-------+---------+
B:
+-------+---------+-----------+
| id | a_id | rank |
+-------+---------+-----------+
| 1 | 1 ...