I have a table with 4 columns: place_id, username, counter, last_checkin
I'm writing a check-in based system and I'm trying to get a query that will give me the "mayor" of each place. The mayor is the one with most check-ins, and if there is more than 1 than the the minimum last_checkin wins.
For example, if I have:
place_id, username...
Dear all,
I have two sql script file which are to be scheduled as windows tasks.
1.sql contains this at the begining:
column dat1 new_value DAY_NUMBER;
select 2 dat1 from dual;
While 2.sql contains this at the begining:
column dat1 new_value DAY_NUMBER;
select 1 dat1 from dual;
If I am going to combine this two scri...
I have a system which records some measured values every second. What is the best way to store trend data which are values corresponding to a specific second?
1 day = 86.400 seconds
1 month = 2.592.000 seconds
Around 1000 values to keep track of every seconds.
Currently there are 50 tables grouping the trend data for 20 columns each....
i am actually reading Doctrine Reference: One to Many, Unidirectional with Join table. but this will probably be more of a SQL quesiton. basically, this is supposed to model a one to many, unidirectional relationship. i guess from the PHP code (in that link), its such that 1 user have many phonenumbers.
the question is from the SQL, it ...
Dim id as integer = 1
Dim command as sqlcommand
Dim reader as idatareader
command = db.GetSqlStringCommand("select id, image, caption from profile where id = @id and image IS NOT NULL Order By NEWID()")
db.AddInParameter(command, "@id", DbType.Int32, id)
reader = db.ExecuteReader(Command)
The code is throwing an error i've never seen ...
I'd like to know how to get a subset of data from a table using Linq To SQl Lambda expressions...
Let's say I have a table tbl_Product, with fields ProductId, ProductCode, ProductName, Description, WhyBuyCopy, how do I get only the first three fields when the others are not needed given that retrieving all data takes a second longer (ch...
How to select all records,that may contain specific value that is known, without referring to specific column in SQL expression?
For instance, i know,that some unknown column holds value 'xxx' and there are many columns and records in table.
Thank you.
...
I have a custom menu in Drupal. Here is the code I use to display it inside my theme (page.tpl.php):
<h4>Site Information</h4>
<?php print theme("links", menu_navigation_links("menu-teaser-05")); ?>
Rather than display Site Information I would like to be able to pull out the Menu Title. Short of doing custom SQL/code can anyone help...
I want to update a column col in table tab,whose data is like follows(comma separated, with the heading comma):
,test,oh,whatever,....,
Which can be too long to display,how can I update the column so that only the first 10 words are left?
...
Please help me to create a select query which contains 10 'where' clause and the order should be like that:
the results should be displayed in order of most keywords(where conditions) matched down to least matched.
NOTE: all 10 condition are with "OR".
Please help me to create this query.
i am using ms-sql server 2005
Like:
Select *
...
I use a simple SQL query in Python to grab records from a SQLite 3 database:
cursor.execute ("SELECT due, task FROM tasks WHERE due <> '' ORDER BY due ASC")
rows = cursor.fetchall()
for row in rows:
print '\n%s %s' % (row[0], row[1])
The due field in the database is set to DATE type, so the query re...
i has a table:TestTable, this table only has one field: value,i insert same datas:
value
------------
ccc
aa
111
bbb
------------
i run:
select * from TestTable
can show my result order by:
ccc
aa
111
bbb
now,i want get this result DESC:
bbb
111
aa
ccc
how to create this sql?
select * from TestTable order by (by what?) DESC
...
I have a table
EntryLog(Name String, CheckIn Boolean)
I want to count the number of checkins against each name. How do I write a query to get the result as a single resultset?
...
I need a really simple library (like a 1 file sort of thing) that generates SQL for me. I just need functions that perform INSERTions and SELECTions and that return the actual SQL string, nothing else, no connection thing no compatibility layer, just plain SQL strings from PHP data structures.
Does anything like this exist? Thanks.
...
Dear Friend,
How can i Retrive Root Directory in SQL Server using SQL Query???
Thanks.
...
In our project we are invalidating the cache based on the change in the query output. This is implemented using change notifications. In the Global.asax file in the Application Start block we have also added SqlDependency.Start(ConnectionStr). But still its throwing the following invalid operation exception
Message "When using SqlDepend...
I have three tables with following structure and info:
CREATE TABLE customer (
customer_id mediumint(8) unsigned NOT NULL auto_increment,
name varchar(50) NOT NULL,
PRIMARY KEY (customer_id)
);
INSERT INTO customer VALUES (1, 'Dagmar');
INSERT INTO customer VALUES (2, 'Dietmar');
INSERT INTO customer VALUES (3, 'Sabine');
CREATE...
Hi guys,
im using this query
SELECT DISTINCT pr.competitorID AS compID, pr.age, CONCAT(pr.firstname, ' ', pr.lastname)AS name
, (SELECT participation_reports.points FROM participation_reports WHERE participation_reports.heatEventID=1 AND participation_reports.competitorID=compID LIMIT 1) AS '100m'
, (SELECT participation_reports.poi...
How to convert a column value from varbinary(max) to varchar to read..
...
I would like to build a database of pictures. Each picture may have 1 or more tags, for example: Paris, April 2010, David.
How would you store this information ?
I thought to have a Files table with 1 row per file, and one of the columns would be Tags IDs separated by commas, for example: 2,4,14,15
In other table called Tags I thought ...