PHP SQL - left join + where + or

I'm improving my search bars in a project's back-office. I want to make a research in the protfolio table, joining the categorytable to include the category's names in the available keywords. Seems simple, but the only message I'll get is : Warni...
more »

2017-01-16 15:01 (1) Answers

Count rows with two columns and each minute

I have a SQL Server 2012 table with sessions and a start and end time in 2. I now need to know how many sessions have been active at each minute, meaning >= starttime and <= endtime. Example Order_strUserId | Order_dtmInitiated | Order_dtmL...
more »

2017-01-16 11:01 (4) Answers

How to sort by month, year in MySQL?

I have column of month and year that data type is varbinary. I tried: SELECT * FROM traffic WHERE '2015'<= year AND year <='2015' AND NOT ( ( 2015= year AND month <05) OR ( 2015= year AND month >11) ) ORDER BY Yea...
more »

2017-01-16 10:01 (4) Answers

Mysql select UNIQUE row on column

I have a table as following:(Ex) id | vid | time ------------------------ 1 | 4 | 1333635317 2 | 4 | 1333635323 3 | 2 | 1333635336 4 | 4 | 1333635343 5 | 5 | 1333635349 I want to be just a row (the last row [ID: 4]) of t...
more »

2017-01-15 21:01 (1) Answers

Foriegn Keys Yah or Nah

Non F-K SCHEMA human human_id | name alien alien_id | name | planet comment comment_id | text 1 hello vote to_id | to_type | who | who_type 1 human 1 alien 1 comment 1 human FK- SCHEM...
more »

2017-01-15 14:01 (1) Answers

Filter rows based on certain conditions

please help me out with a solution to this problem.. table is like this - Type | SubType | Flag | Value -------------------------------- 123 | A1 | Y | 101 -------------------------------- 123 | A2 | Y | 102 --------------...
more »

2017-01-15 05:01 (3) Answers

Convert from varchar into date in SQL Server

This looks easy solution but I can't seem to figure out as to why this is not working for me. I have a column that has data like this: DateField ---------- 12/16/2016 11/06/2016 All I want to do is to convert from varchar into a date column, but I...
more »

2017-01-15 03:01 (4) Answers

SQL: select where either column is matched

I'll illustrate my problem: Look at the table with two columns: Col1 and Col2. ----------------- | Col1 | Col2 | ----------------- | 1a1 | 2b2 | ----------------- | 11b | 22a | ----------------- I am trying to select values that cont...
more »

2017-01-14 20:01 (4) Answers

TSQL - Partition BY if in order

I am trying to partition by [Status] after it's sorted by [Status_DateTime] DESC. So only [Status] that are in a row will be partitioned in order to get the earliest Date for it. /****** Object: Table [dbo].[Order_Status] Script Date: 1/13/2017 ...
more »

2017-01-13 20:01 (2) Answers

Different OUTPUT when using MERGE statement?

I'm using MERGE to insert or update records into a table: MERGE INTO target USING SELECT * FROM @source WHEN MATCHED THEN UPDATE SET ...columns... WHEN NOT MATCHED THEN INSERT ...columns... OUTPUT inserted.* INTO @insertedRecord If the above stat...
more »

2017-01-13 18:01 (2) Answers

Using partitioned indexes with partitioned tables

I'm trying to understand the optimal way to construct composite local partitioned indexes for use with partitioned tables. Here is my example table: ADDRESS id street city state tenant The Address table is list partitioned upon the tenant column....
more »

2017-01-13 18:01 (2) Answers

Getting node value in xml column

Please let me know why the following XML query is not fetching any result. I am trying to get value EffectiveUserName tag. DECLARE @MyXML XML SET @MyXML = '<PropertyList xmlns="urn:schemas-microsoft-com:xml-analysis" xmlns:soap="http://sc...
more »

2017-01-13 18:01 (2) Answers

CASE STATEMENT IN SQL

Select CASE WHEN loc ='J' THEN 'Y' WHEN loc NOT IN ('J') THEN 'N' ELSE 0 END AS loc FROM [prd].[dbo].[GRP] EXCEPT Select location FROM [prd1].[dbo].[GRPO] WHERE VALUE IN('Y','N'); Error: Conversion failed w...
more »

2017-01-13 16:01 (1) Answers

Finding missing numbers in a table

I'd like to generate a query that will produce a list of index values that are missing from a SQL table. So far, what I have is SELECT index - 1 FROM table WHERE index - 1 NOT IN ( SELECT DISTINCT index FROM table) AND index != 1; ...
more »

2017-01-13 15:01 (2) Answers

SQL Command with string as Tablename

private DataTable zGetTableContent(string tablename) { DataTable dt = new DataTable(); Connection.Open(); MessageBox.Show(tablename); Adapter = new OleDbDataAdapter("SELECT * FROM '%" + tablename + "%'", Connection);...
more »

2017-01-13 08:01 (2) Answers

MySQL query to get Average data consumption

We need help in finding data like.. - In how many days "size" value of "type" abc will touch the "total" figure (50 in this example). Size of Type "abc" is increasing daily. There could be multiple entries in single date There could be m...
more »

2017-01-12 12:01 (1) Answers