Here is the SQL Fiddle link.
According to my understanding, GROUP BY would return 2 tuples.
MODEL ITEM_TYPE PRICE
---------------------------- -------------------------------------…
How can I write the follow query with Linq in C#?
SELECT MAX(A2.LINHA_PLANILHA)
FROM MD_IMP_FORCA_VENDA_DADOS_A2 A2
WHERE A2.LINHA <> '0'
AND TRIM(A2.SETORES) IS NOT NULL
AND A2.LINHA_PLANILHA <> 1
AND USUARIO = V_USUARIO
GROUP BY…
i dont understand why we can use WHERE clause with date functions. For instance lets take
SELECT name FROM table1
WHERE DATEDIFF(year1,year2) < 10;
And its working. I thought that we cant use WHERE with functions. To do this we should use HAVING…
I need to get dealers ids, which have multiple car's vendors.
By example tables, I need to get id 3.
I'm stuck on this query:
SELECT COUNT(car.id), dealers2cars.dealer_id, car.vendor_id FROM car, dealers2cars
WHERE
dealers2cars.`car_id` =…
Suppose I have a tow SQL tables:
Fathers
id | name
-------------
1 | Clinton
2 | Gates
3 | Bush
4 | Clinton
Sons
id | fatherid | name
---------------------
1 | 1 | bill
2 | 1 …
I'm having a bit of trouble with getting a select statement to work correctly.
I have the following tables:
recipe
recipe_ingredient
pantry
recipe1
ingredient1
Ingredient1
recipe1
ingredient2
Ingredient2
recipe2
ingredient3
I want a…
i want to run sql query (mysql) and i have multiple condition in WHERE & also multiple condition in HAVING,
SQL apply "AND" between WHERE & HAVING, i want to apply "OR" between.
WHERE Condition 1, Condition 2 .... Condition N
{{OR}}
HAVING…
I'm trying to write a SQL query, which says how many logins each user made in their first week.
Assume, for the purpose of this question, that I have a table with at least user_id and login_date. I'm trying to produce an output table with user_id…
Two tables P, W are connected by Group foreign key. The bellow inner SQL returns only the table P 'names' which has only one matching 'type' in W table. The outer SQL displays name and type column values.
Basically i need to retrieve only the…
please i need your help on this
How can i interpret this sql to linq:
SELECT FK_ClassId, LectureDays
FROM tbl_TimeTables
WHERE (FK_ClassId = 11)
group by fk_classid, lecturedays
having count(distinct Period) < 7
Any help will be much appreciated…
I have a table 'FinancialTrans' where only 3 of those fields are needed.
AcctID TransTypeCode DateOfTrans Field 4 Field 5 Field 6....
123 TOLL 2016-06-06
123 TOLL 2016-06-02
123 TOLL 2016-04-28
123 …
My task table has an auto-increment ID field, to my taskitem table has a foreign key 'task_ID'. The taskitem element can have numerous task_IDs (a task can have numerous items).
I need to create a query that selects all task IDs from task WHERE the…
HAVING 0 = COUNT(1)) AS a
What does this mean ?
SELECT outr.*
FROM Orders outr
WHERE
EXISTS ( SELECT *
FROM ( SELECT ol.Orders_ID
FROM Orderlines AS ol
WHERE…