How can I get data from these related entities. I want to get these columns only:
Term.Name , related Concept_Term.Weight, related Concept.Id
I wrote the SQL but I don't want to use
select t.Name,ct.ConceptId,ct.Weight from Term t
inner join Concept_Term ct on t.Id=ct.TermId
inner join Concept c on c.Id=ct.ConceptId
where...
I'm creating an SQL statement that will return a month by month summary on sales.
The summary will list some simple columns for the date, total number of sales and the total value of sales.
However, in addition to these columns, i'd like to include 3 more that will list the months best customer by amount spent. For these columns, I nee...
Okay so I have a database field called moderated
It is an ENUM with 3 values:
approved
denied
unmoderated
How can I write a query that counts the amount of each, so I can generate this output:
Approved: 3
Denied: 10
Unmoderated: 23
...
I have a column of database names like so:
testdb_20091118_124925
testdb_20091119_144925
testdb_20091119_145925
ect...
Is there a more elegant way of returning only similar records then using this like expression:
select * from sys.databases where name
LIKE 'testdb[_][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][_][0-...
Is there a way to get the SQL which would be run for a particular find() query, rather than actually running it?
For example:
echo $this->Users->find_sql('all');
// "SELECT User.id, User.username FROM users User WHERE 1=1"
My own situation would be a little more complicated than this, but I hope it illustrates the desired output.
...
I have query like this
DECLARE @A INT
SET @A = 22
SELECT Moo, 1st - 2nd + 100 AS WWW
FROM (
SELECT 1 + Num AS Moo,
((@A-100)*3)+num AS 1st,
((@A-100)*4)+num AS 2nd
FROM tblC
WHERE ColA = 'Atic' AND Num < 7
) AS TTT
How to use CTE to rewrite same query?
...
Hi,
We're getting this error once a day on a script that runs every two hours, but at different times of the day.
ERROR at line 1:
ORA-04068: existing state of packages has been discarded
ORA-04061: existing state of package body "PACKAGE.NAME" has been
invalidated
ORA-06508: PL/SQL: could not find program unit being called:
"PACKAGE.N...
used to check user input like username not a login account.
...
I using this loop to print number
DECLARE @A Int
SET @A = 33
WHILE @A < 55
BEGIN
SELECT @A as sequence
SET @A = @A + 1
END
GO
But problem that with every loop message is printed like example:
sequence
-----------
53
(1 row(s) affected)
How to print in order like this:
34
35
36
37
Can help me with CTE example for this?
...
Hi,
I'm designing a shopping cart. To circumvent the problem of old invoices showing inaccurate pricing after a product's price gets changed, I moved the price field from the Product table into a ProductPrice table that consists of 3 fields, pid, date and price. pid and date form the primary key for the table. Here's an example of what ...
If I run the following query:
select load_cyc_num
, crnt_dnlq_age_cde
, sum(cc_min_pymt_amt) as min_pymt
, sum(ec_tot_bal) as budget
, case when ec_tot_bal > 0 then 'Y' else 'N' end as budget
, case when ac_stat_cde in ('A0P','A1P','ARP','A3P') then 'Y' else 'N' end as arngmnt
, sum(sn_close_bal) as st_bal
from statements
where...
Greetings all,
I see no difference between the two queries below:
query_join = select a.id, b.name, a.telephone, a.description from tb_industry a left outer join tb_sector b on a.sector_id = b.id
query_select = select a.id, b.name, a.telephone, a.description from tb_industry a , tb_sector b WHERE a.sector_id = b.id
The result is ...
Hey,
What's the best way to create an asp.net page with a data matrix. Imagine an excel sheet where the rows have a dynamic amount of cells, but the number of cells must be the same for each row. The default number would be for example 9.
The user should be able to edit, add or remove each row separately. Upon with the appropriate chan...
I have 2 tables, one is supplier and one is supplier_feedback - how can I calculate the average rating for each supplier? I currently have this:
SELECT s.premium, s.supplier_id, s.name, s.phone, s.website,
s.price_low, s.price_high, s.address1, s.address2, s.town,
s.county, s.postcode,
(SUM( f.rating ) / ( COUNT( f.ratin...
I'm looking for a way to optimise the following:
SELECT
(SELECT SUM(amount) FROM Txn_Log WHERE gid=@gid AND txnType IN (3, 20)) AS pendingAmount,
(SELECT COUNT(1) FROM Txn_Log WHERE gid = @gid AND txnType = 11) AS pendingReturn,
(SELECT COUNT(1) FROM Txn_Log WHERE gid = @gid AND txnType = 5) AS pendingBlock
where @gid is ...
How can specify expression in LIKE operator
I want to select all row in table where column Name starts with a-zA-Z followed by # and does not have two dots together (..)
i tries this WHERE NAME LIKE '%[a-zA-Z]#'
...
I'm not sure if this type of question has been answered before. In my database I have a product table and specifications table. Each product can have multiple specifications. Here I need to store the revisions of each product in database in order to query them later on for history purposes.
So I need an efficient way to store the produ...
Why does this simple query return 'ORA-00936: missing expression' (the database is Oracle as you can tell):
SELECT * FROM transactions WHERE id NOT LIKE '1%' AND NOT LIKE '2%'
I feel silly, but what am I doing wrong?
...
How can I return a declared string like ( lastInsertId ) from my MySQL stored procedure and out? It's really annoying I can't return error messegts, complate messages and more out to my code in PHP5.
I hope somebody can help me here, I have search Google around without luck :(
Thanks to everybody.
...
I have an input string in the following format: 12.34
When I call this line:
db.AddInParameter(insertMessageDetailCommand, "AttachmentSize", System.Data.SqlDbType.Decimal , Convert.ToDecimal(this.messageEnvelope.EnvelopeInfo.AttachmentSize));
I get an input string not in the correct format. The server I am deploying to have regional...