Using Django 1.1, how could I create a crosstab (pivot table) SQL query using the ORM?
UPDATED:
These are the models and output requirements:
class Store(models.Model):
name = models.CharField(max_length=255)
...
class Order(models.Model):
store = models.ForeignKey(Store, blank=True, null=True, related_name='orders')
description =...
In ms-access database i have a table named tableA
this table has a column called Call_Date which has 4 types of entries
dates ( e.g 10/23/2008 )
-
NA
Blanks ( empty cell )
how can i write a query to select all rows of tableA except those where the Call_Date column has - or NA or Blanks
i tried writing
Select * from tableA where C...
hi guys,
I have following query.
declare @Prm_CourseId int
declare @Prm_SpecializationId int
set @Prm_CourseId=5
set @Prm_SpecializationId=0
declare @WhrStr varchar(500)
set @WhrStr = case @Prm_CourseId
when 0 then
'e.CourseId is null or e.CourseId is not null'
when -1 then
'e.CourseId is null o...
Why can't we use :new and :old columns in a statement level trigger?
...
In ms-access database, is it possible to write an sql query to replace the number in a column with a number obtained by adding 2 to this original number. ie, all numbers in a column should be replaced by the original number plus 2
...
If i want to use Linq-SQL i also have to drag the DB Table unto the designer surface to create the entity classes.
I always like full control in my application and do not like the classes created by dotnet.
Is it possible to provide this connection between Linq and the DB using my own Data Access Layer Entity classes?
How can i get i...
in the ms access database
columnA has date entries
collumnA
01/15/08
02/11/08
12/23/08
how do i write a query to add new column called months.
where months are calculated as
months = no. of months between original date to 01 dec 2009
...
i have 2 tables linked together through the 3rd table
threads: id, name
tags: id, name
thread_tag_map: threads_id, tags_id
its a many to many relationship. i want to select 30 tags that are most popular that is to say the first 30 tags with tags_id which occur the most in thread_tag_map.
i think you understand my question (and sorry ...
Can I combine these two SQL queries into single query?
query1
ALTER TABLE tableA
ADD datam INTEGER;
query2
UPDATE tableA SET datam = DateDiff("m",[call_date],#12/1/2009#);
...
I have this sql
select concat( char(FLOOR(97+ RAND()*26))
, char(FLOOR(97+ RAND()*26))
, FLOOR(100+ RAND()*999)
, char(FLOOR(97+ RAND()*26))) AS randomcode
WHERE NOT EXISTS (
SELECT *
FROM table
WHERE code_felt = randomcode );
But I can't get it to work. D...
Here is the select statement I'm using. The problem happens with the sorting. When it is like below, it only sorts by t2.userdb_user_first_name, doesn't matter if I put that first or second. When I remove that, it sorts just fine by the displayorder field value pair. So I know that part is working, but somehow the combination of the two ...
when i print the sql generated in connection.queries:
i found some sql like this:
SELECT (1) AS `a` FROM `auth_user` WHERE `auth_user`.`id` = 2
what's that mean?
...
in ms-access, how to write a query / DDL to change multiple column names with a single query.
...
Imagine hexagonal space with 3 dimensions.
Each tile has coordinates XYZ.
I need to select a given cell neighbors in the same plane.
With SQL it's looks like:
$tbDir = $y % 2 == 0 ? -1 : 1;
$result = db_query('SELECT x,y,z FROM {cells} WHERE
x = %d AND y = %d AND z = %d OR
x = %d AND y = %d AND z = %d OR
...
Is there a more serious/commercial tool (than this) for generating a simple wpf forms from ms sql table metadata?
...
I have an update statement that updates fields x, y and z where id = xx.
In the table I have a few different x_created_datetime fields (for different portions of the record that are maintained/entered by different folks). I'd like to write a single query that will update this field if is null, but leave it alone if is not null.
So what...
I'm returning results from the following query which is taking too long when running. I'm not sure how to eliminate the where parameters when they are not used in SSRS. All the @variables are strings
select S.SBSB_ID, LTRIM(RTRIM(M.MEME_FIRST_NAME)) + ' ' +
LTRIM(RTRIM(M.MEME_LAST_NAME)) AS Names,
(CASE M.MEME_REL WHEN 'M' THEN 'Subscr...
I want to update a row which has some html tags inside. For instance
src='/imagem.png'></ p></ body>
> UPDATE ISTANBUL_TABLE SET TEXT = '<
> body>< p>< img src='/imagem.png '></
> p></ body>' WHERE 1=1
you see after src=' means the query ends, but it does not end. how can i solve it without using " (double comma). any solution p...
I have an sql column that is a string of 100 Y or Ns eg 'YYNYNYYNNNYYNY...'
What is the easiest way to get the number of Ys in each row.
...
So I'm dividing an integer by a decimal, and storing the result in a decimal column. However, it always drops the fractional component(the part after the decimal point). If I multiply the result by 10 or 100 I get a more accurate result, but dividing again drops the fractional part again.
The two fields I've inserted into were a precisi...