对于查询转换-SQL到Hql感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍sql查询结果转换,并为您提供关于5、flinksql表的查询转换、c#–将SQL查询转换为LINQ、hql-HQL中
对于查询转换-SQL到Hql感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍sql查询结果转换,并为您提供关于5、flinksql 表的查询转换、c# – 将SQL查询转换为LINQ、hql-HQL中使用占位符查询mysql数据老是报错...、MySQL到HiveQL转换中的错误,包括DATE_SUB和INTERVAL的有用信息。
本文目录一览:- 查询转换-SQL到Hql(sql查询结果转换)
- 5、flinksql 表的查询转换
- c# – 将SQL查询转换为LINQ
- hql-HQL中使用占位符查询mysql数据老是报错...
- MySQL到HiveQL转换中的错误,包括DATE_SUB和INTERVAL
查询转换-SQL到Hql(sql查询结果转换)
我有这个查询,我需要在hql中将其转换,但我有点困惑,不知道如何编写hql中“ where”子句中出现的条件。
SELECT message FROM p_message WHERE message_id=( SELECT a.scene FROM p_config a INNER JOIN p_rec_type b ON a.email_id=b.email_id AND rec_type=2 WHERE a.email_type=1 )
什么是hql等效于此sql查询?
答案1
小编典典请在HQL查询下面找到:假设p_message和p_config是域对象名称,其他是映射到列的属性。
String hqlQuery =" SELECT message FROM p_message pm WHERE pm.message_id in (SELECT a.scene FROM p_config a INNER JOIN p_rec_type b ON a.email_id=b.email_id AND rec_type =:rectype WHERE a.email_type=:emailTYpe)"; query = session.createQuery(hqlQuery); query.setParameter("rectype", 2); query.setParameter("emailTYpe", 1);
5、flinksql 表的查询转换
package com.jd.data;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.DataTypes;
import org.apache.flink.table.api.Table;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
import org.apache.flink.table.descriptors.FileSystem;
import org.apache.flink.table.descriptors.OldCsv;
import org.apache.flink.table.descriptors.Schema;
import org.apache.flink.types.Row;
import scala.Tuple3;
import static org.apache.flink.table.api.Expressions.$;
public class TableAipDemo03 {
public static void main(String[] args) throws Exception {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(1);
// 1、创建表执行环节
StreamTableEnvironment tableEnv = StreamTableEnvironment.create(env);
String path = "/Users/liuhaijing/Desktop/flinktestword/aaa.txt";
tableEnv.connect(new FileSystem().path(path))
.withFormat(new OldCsv()) // 定义格式化方法
.withSchema(new Schema().field("a", DataTypes.STRING()) // 定义表的结构
.field("b", DataTypes.STRING())
.field("c", DataTypes.STRING())
)
.createTemporaryTable("xxx");
// 表的查询与转换
Table xxx = tableEnv.from("xxx");
// 简单查询
Table select = xxx.select("a, b").filter($("a").isEqual("a"));
Table select2 = select.groupBy($("a"))
.select($("a"), $("a").count().as("count"));
select2.printSchema();
// 可撤回的方式 输出结果前面会有一列 boolean true 表示以这次为准, false为作废
tableEnv.toRetractStream(select2, Row.class ).print();
env.execute("job");
}
}
c# – 将SQL查询转换为LINQ
visit_Id member_Id visit_Date visit_Time visit_DateTime visit_Status values like (accepted,refused)
我有以下SQL查询:
string sql = @"SELECT CONCAT(UPPER(SUBSTRING(visit_Status,1,1)),SUBSTRING(visit_Status FROM 2)) as Status,COUNT('x') AS Visits FROM visits WHERE visit_Date BETWEEN '2001-09-08' AND '2009-09-09' GROUP BY visit_Status";
如何将此sql转换为LINQ?我的实体名称是dbcontext.在此先感谢您的帮助.
解决方法
DateTime dateFrom = new DateTime(2001,9,8); DateTime dateto = new DateTime(2001,9); var query = from v in dbcontext.Visits where v.visit_Date >= dateFrom && v.visit_Date <= dateto group v by v.visit_Status into vg select new { Status = EntityFunctions.Concat(EntityFunctions.toupper(vg.Key[0]),EntityFunctions.SubString(1,EntityFunctions.Length(vg.Key) -1),Visits = vg.Count() }
hql-HQL中使用占位符查询mysql数据老是报错...
mysqlhql
执行语句如下:
session session = hibernateutil.getsession();
string hql = "from category where name=?";
query query = session.createquery(hql);
query.setstring(0, "饮品");
错误:
ava.lang.nosuchmethoderror: org.hibernate.hql.antlr.hqlbaseparser.recover(lantlr/recognitionexception;lantlr/collections/impl/bitset;)v
MySQL到HiveQL转换中的错误,包括DATE_SUB和INTERVAL
也许您可以结合使用Hive date functions <template>
<div>
<!-- MODAL PARA EDITAR ITEM -->
<divid="editarItem" tabindex="-1" role="dialog" aria-labelledby="editarItem" aria-hidden="true">
<divrole="document">
<div>
<div>
<h5id="exampleModalLabel">Editar ítem</h5>
<button type="button"data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div>
<div>
<label for="cantidadEdit">Cantidad</label>
<div>
<div>
<input v-model="item.cantidad" type="number"min="1" tabindex="1" onfocus="this.select();">
</div>
</div>
</div>
<div>
<label for="itemEdit">Stock</label>
<div>
<input type="text"v-model="item.stock" disabled>
</div>
</div>
<div>
<label for="precioEdit">Precio unitario<smallid="porcentajefinalprecio">+ {{item.primer_margen}}%</small></label>
<div>
<input v-model="item.precio" type="text"tabindex="2" onfocus="this.select();">
</div>
</div>
<div>
<label for="">Tipo de impuesto</label>
<div>
<select v-model="item.impuesto"id="imp">
<option v-for="imp in impuestos" v-bind:key="imp.id" v-bind:value="imp.id">{{ imp.nombre }}</option>
</select>
</div>
</div>
<div>
<label for="precioTotalEdit">Subtotal <small id="simboloparatodos">{{item.moneda_id}}</small></label>
<div>
<input type="text" v-model="subtotal"id="precioTotalEdit" onfocus="this.select();" readonly>
</div>
</div>
<div>
<label for="precioigvEdit">I.G.V. </label>
<div>
<input type="text" v-model="igv"id="precioigvEdit" readonly>
</div>
</div>
<div>
<label for="descuentoEdit">Descuento</label>
<div>
<input v-model="item.descuento" type="text"id="descuentoEdit" data-toggle="popover" data-placement="top" data-html="true" data-content="Para montos. Ej: 10<br>Para porcentajes agrega %. Ej: 10%" data-trigger="hover" tabindex="4" onfocus="this.select();">
</div>
</div>
<div>
<label for="precioSubtotalEdit">Total <small id="simboloparatodos">{{ moneda_id }}</small></label>
<div>
<input v-model="total" type="text"id="precioSubtotalEdit" value="0" tabindex="5" onfocus="this.select();">
</div>
</div>
<div>
<label for="precio20Edit">Precio <smallid="porcentajeinicial">+ {{item.primer_margen}}%</small></label>
<div>
<div id="margeninicialx">{{ item.masprimermargen }}</div>
</div>
</div>
<div>
<label for="precio35Edit">Precio <smallid="porcentajefinal">+ {{item.segundo_margen}}%</small></label>
<div>
<div id="margenfinalx"> {{ item.massegundomargen }}</div>
</div>
</div>
<div>
<label for="itemEdit">Item</label>
<div>
<small id="marcaEdit">{{ item.marca }}</small> <a href="#" title="" target="_blank" id="itemEdit">{{ item.nombre }}</a><br><spantitle="códigos" id="codigoedit" v-for="cod in codigos" v-bind:key="cod.id">{{ cod.nombre_codigo }}-{{ cod.pivot.nombre }}<br></span>
</div>
</div>
</div>
<div>
<button type="button"data-dismiss="modal">Cancelar</button>
<button type="button"tabindex="5" @click="anadiritem">Añadir</button>
</div>
</div>
</div>
</div>
<!-- FIN DE MODAL PARA EDITAR ITEM -->
<!-- SECCION SELECCIONAR ITEM Y AGREGAR A LA TABLA -->
<div>
<div>
<div>
<span><i></i></span>
</div>
<div>
<input type="text" id="item"placeholder="Buscar item (Ctrl+.)" v-model.trim="q" @keyup.enter="buscaritem">
</div>
<div>
<buttonid="button-addon2" disabled></button>
</div>
</div>
</div>
<tableid="detailFactura">
<thead>
<tr>
<th>Ítem</th>
<th>Cnt.</th>
<th>Costo U.</th>
<th></th>
<th>
SubTotal
</th>
<th>
I.G.V
</th>
<th><span>
Total
<div id="monedaText"></div>
</span></th>
</tr>
</thead>
<tbody>
<tr v-for="itemtabla in itemstabla" v-bind:key="itemtabla.id">
<td><a href="#" title="" target="_blank">{{ item.nombre }}</a> <small>({{ itemtabla.marca }})</small> </td>
<td><smalltitle="Unidades">{{ itemtabla.unidad }}</small>{{ itemtabla.cantidad }}</td>
<td>{{ itemtabla.precio }}</td>
<td>
<a href="javascript:void(0);"v-on:click="editaritem(itemtabla)"><i></i></a>
<a href="javascript:void(0);"v-on:click="deleteitem(itemtabla.id)"><i></i></a>
</td>
<td>{{ preciosegunmoneda(itemtabla.precio,itemtabla.moneda,itemtabla.cantidad,itemtabla.impuesto,itemtabla.descuento).subtotal }}</td>
<td>{{ preciosegunmoneda(itemtabla.precio,itemtabla.descuento).igv }}</td>
<td>{{ preciosegunmoneda(itemtabla.precio,itemtabla.descuento).total }}</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="2"id="cantidadItems">{{ itemstabla.length }} </td>
<td>ítem(s)</td>
</tr>
</tfoot>
</table>
<!-- FIN DE SECCION SELECCIONAR ITEM Y AGREGAR A LA TABLA -->
</div>
</template>
<script>
import {
required,minLength,maxLength,between
} from 'vuelidate/lib/validators'
import Bloodhound from 'corejs-typeahead/dist/bloodhound';
import typeahead from 'corejs-typeahead/dist/typeahead.jquery';
export default {
name: 'tabla-item',props: {
tienda: Number,},data() {
return {
resource: 'venta',error: false,submitStatus: null,isLoading: false,fullPage: true,q: '',suggestions: null,item: {},}
},created() {
},mounted() {
let contextoVue = this
// Cargar los datos del typeahead en items
this.suggestions = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('title'),queryTokenizer: Bloodhound.tokenizers.whitespace,identify: function (item) {
return item.id;
},remote: {
url: '/item/records/' + this.tienda + '/' + '%QUERY',wildcard: '%QUERY'
}
});
let inputEl = $('.prefetch input');
inputEl.typeahead({
minLength: 1,highlight: true,{
name: 'suggestions',source: this.suggestions,limit: 20,display: 'label',templates: {
suggestion: (data) => {
let codigos = data.codigos
let nuevoscodigos = ""
codigos.forEach(function (valor,indice,array) {
nuevoscodigos = nuevoscodigos + valor.pivot.nombre + ','
});
let nuevoprecio = ((parseFloat(contextoVue.preciosegunmoneda(data.precio,data.moneda,'1',data.impuesto_id).precio) * parseFloat(data.primer_margen) / 100) + parseFloat(contextoVue.preciosegunmoneda(data.precio,data.impuesto_id).precio)).toFixed(2)
return `<div>
<div>
${data.nombre_marca} <span title="Código global"> - ${nuevoscodigos}</span>
<span title="Código de barras"></span>
</div>
<div>
<strong>${data.nombre}</strong>
</div>
<div><div>${contextoVue.moneda_id}
<span id="pricechange">${nuevoprecio}</span></div>
<div><b>Stock</b>:
<b>${data.stock}</b><b></b></div></div></div>`;
}
}
});
// Cuando se hace click en un item
$('.prefetch input').bind('typeahead:selected',function (evt,suggestion) {
$('#editarItem').modal('show')
let preciosegunmoneda = ((parseFloat(contextoVue.preciosegunmoneda(suggestion.precio,suggestion.moneda,suggestion.impuesto_id).precio) * parseFloat(suggestion.primer_margen) / 100) + parseFloat(contextoVue.preciosegunmoneda(suggestion.precio,suggestion.impuesto_id).precio)).toFixed(2)
let massegundomargen = ((parseFloat(contextoVue.preciosegunmoneda(suggestion.precio,suggestion.impuesto_id).precio) * parseFloat(suggestion.segundo_margen) / 100) + parseFloat(contextoVue.preciosegunmoneda(suggestion.precio,suggestion.impuesto_id).precio)).toFixed(2)
contextoVue.item = {
id: suggestion.id,stock: suggestion.stock,nombre: suggestion.nombre,precio: preciosegunmoneda,marca: suggestion.nombre_marca,impuesto: suggestion.impuesto_id,primer_margen: suggestion.primer_margen,segundo_margen: suggestion.segundo_margen,masprimermargen: preciosegunmoneda,massegundomargen: massegundomargen,codigos: suggestion.codigos,cantidad: '1',descuento: '0',moneda: contextoVue.moneda_id,unidad: suggestion.nombre_unidad,}
});
// Fin typeahead items
},updated() {
},computed: {
total() {
return this.item.precio * this.item.cantidad - this.item.descuento
},igv() {
if(this.item.impuesto=="1") {
return (parseFloat(this.total) * 18/100).toFixed(2)
}
else {
return 0
}
},subtotal() {
return (parseFloat(this.total) - this.igv).toFixed(2)
},tipocambio: {
get() {
return this.$store.state.venta.tipocambio
},set(value) {
this.$store.commit('settipocambio',value)
}
},moneda_id: {
get() {
return this.$store.state.venta.moneda_id
},set(value) {
this.$store.commit('setmonedaid',itemstabla: {
get() {
return this.$store.state.itemstabla
},impuestos: {
get() {
return this.$store.state.impuestos
},watch: {
moneda_id: function (val) {
//this.$store.commit('actualizaritemstabla')
},methods: {
submit() {},preciosegunmoneda(precio,moneda,cantidad,impuesto,descuento) {
let total,nuevoprecio,subtotal,igv = 0
if ((this.moneda_id == 'S/' && moneda == 'S/') || (this.moneda_id == '$' && moneda == '$')) {
nuevoprecio = parseFloat(precio).toFixed(2)
total = parseFloat((parseFloat(precio) * cantidad) - descuento).toFixed(2)
igv = parseFloat((parseFloat(total) * (impuesto=='1' ? 18/100 : 0))).toFixed(2)
subtotal = parseFloat(total - igv).toFixed(2)
return {precio: nuevoprecio,total: total,igv: igv,subtotal: subtotal }
}
else if (this.moneda_id == 'S/' && moneda == '$') {
nuevoprecio = parseFloat(precio * this.tipocambio).toFixed(2)
total = parseFloat((parseFloat(precio * this.tipocambio) * cantidad) - descuento).toFixed(2)
igv = parseFloat((parseFloat(total) * (impuesto=='1' ? 18/100 : 0))).toFixed(2)
subtotal = parseFloat(total - igv).toFixed(2)
return {precio: nuevoprecio,subtotal: subtotal }
}
else if (this.moneda_id == '$' && moneda == 'S/') {
nuevoprecio = parseFloat(precio / this.tipocambio).toFixed(2)
total = parseFloat((parseFloat(precio / this.tipocambio) * cantidad) - descuento).toFixed(2)
igv = parseFloat((parseFloat(total) * (impuesto=='1' ? 18/100 : 0))).toFixed(2)
subtotal = parseFloat(total - igv).toFixed(2)
return {precio: nuevoprecio,subtotal: subtotal }
}
},deleteitem(i) {
this.$store.commit('EliminarItemTabla',i);
},editaritem(item) {
$('#editarItem').modal('show')
this.item = item
},anadiritem(event) {
$('#editarItem').modal('hide')
this.$store.commit('setitemstabla',this.item )
},validations: {
form: {
nombre_codigo: {
required,}
}
}
</script>
和date_sub
来做到这一点。
add_months
我们今天的关于查询转换-SQL到Hql和sql查询结果转换的分享就到这里,谢谢您的阅读,如果想了解更多关于5、flinksql 表的查询转换、c# – 将SQL查询转换为LINQ、hql-HQL中使用占位符查询mysql数据老是报错...、MySQL到HiveQL转换中的错误,包括DATE_SUB和INTERVAL的相关信息,可以在本站进行搜索。
本文标签: