Can someone convert this english to SQL I have tried several things but no luck.
SELECT CASE WHEN COUNT(person_id) > 3 THEN person_id end FROM table
I am trying to only get the person_id(s) that occur > 3 times in the table.
...
suppose I have this table
id | cash
1 200
2 301
3 101
4 700
and I want to return the first row in which the sum of all the previous cash is greater than a certain value:
So for instance, if I want to return the first row in which the sum of all the previous cash is greater than 500, is should return to row 3
How do I d...
Hi All,
I want to fetch the BalanceAmt of a particular Customer attended by a particular attender. The criteria is that a customer may buy more than one items. Each bought items has been recorded individually. At some cases 'attender' value would be NULL.
Here's my query:
SELECT Customer, AttendedBy, SUM(BalanceAmt) FROM billing GROU...
I'm having difficulty with a query which displays records according to their fill rate.
For instance, a vacancy can have no bookings or some bookings. If a vacancy has bookings, they can be in the form of 'active [1]', 'pending [0]'. The query I have written so far works if the vacancy has booking records but I can't get it to work if ...
I need to execute some SQL that looks like this:
select approve_firm_id,approve_dt,approve_result
from main_approve
group by approve_firm_id
having MAX(approve_dt) and approve_result=0;
it runs (mysql-5.1),
but if I try in the Django model like this:
Approve.objects.annotate(max_dt=Max('approve_dt')).
filter(max_dt__gt=0).filte...
I have a troublesome MySQL query as follows:
SELECT camera_id, ((avg(low_price) + avg(high_price)) / 2) as avg_price
FROM camera_general, camera_products
WHERE camera_id = ir_camera_id
AND dp_post_dt IS NOT NULL
AND dp_post_dt NOT LIKE '0000%'
AND currently_manufactured = 'Yes'
AND ((no_of_sellers >= 0) OR ((TO_DAYS(CURRENT_DATE) - TO_D...
select xx as fieldA from ... group by xxx having fieldA is not null
I found that having has no effect
...
Hi,
I'm struggling to get my query working. Basically, what it should do is only return vacancies that haven't been filled. For example, a vacancy can have a pre-determined limit of 5. To fill this, it will need to have a mixture of 5 active or pending bookings or simply 5 active or 5 pending bookings.
A pending booking is changed to a...
Trying to run the following HQL with NHibernate:
select count(distinct t) as TweetCount
from Tweet t
join t.Tweeter u
left join t.Votes v
left join t.Tags tag
where t.App = :app
having count(distinct v) > 0
But for some reason the having clause is being ignored and it's counting all tweets when only 2 tweets have a vote. I...