VJay
VJay

Reputation: 49

select with parameters from table

I'm trying to fetch data with additional row values from a table.

The select statement should be fetching,

  1. select * from the table
  2. But the first column should be having a value - 'C001' for each row that we select.

The actual table is as below,

Title           value
-------------   -------
abc_ef_1_123    53.2
abc_ef_1_1      43.2
abc_ef_1_11     23.1
abc_ef_1_12     45.2
abc_ef_1_13     56.4
def_cef_3_23    98.1
def_cef_3_3     53.2
def_cef_3_12    43.2
def_cef_3_13    23.1
def_cef_3_123   45.2

expected result should be as below,

ID        Title           value
-------   -------------   -------
C001      abc_ef_1_123    53.2
C001      abc_ef_1_1      43.2
C001      abc_ef_1_11     23.1
C001      abc_ef_1_12     45.2
C001      abc_ef_1_13     56.4
C001      def_cef_3_23    98.1
C001      def_cef_3_3     53.2
C001      def_cef_3_12    43.2
C001      def_cef_3_13    23.1
C001      def_cef_3_123   45.2

Please assist.

Upvotes: 0

Views: 184

Answers (1)

Lukasz Szozda
Lukasz Szozda

Reputation: 175716

As simple as:

SELECT 'C001' AS id, * FROM tab;

Upvotes: 2

Related Questions